write a version 1 pest control file

        Parameters
        ----------
        new_filename : str
            name of the new pest control file
        update_regul : (boolean)
            flag to update zero-order Tikhonov prior information
            equations to prefer the current parameter values

def _write_version1(self,new_filename,update_regul=False):
        """write a version 1 pest control file

        Parameters
        ----------
        new_filename : str
            name of the new pest control file
        update_regul : (boolean)
            flag to update zero-order Tikhonov prior information
            equations to prefer the current parameter values


        """
        self.new_filename = new_filename
        self.rectify_pgroups()
        self.rectify_pi()
        self._update_control_section()
        self.sanity_checks()

        f_out = open(new_filename, 'w')
        if self.with_comments:
            for line in self.comments.get("initial",[]):
                f_out.write(line+'\n')
        f_out.write("pcf\n* control data\n")
        self.control_data.write(f_out)

        # for line in self.other_lines:
        #     f_out.write(line)
        if self.with_comments:
            for line in self.comments.get("* singular value decompisition",[]):
                f_out.write(line)
        self.svd_data.write(f_out)

        #f_out.write("* parameter groups\n")

        # to catch the byte code ugliness in python 3
        pargpnme = self.parameter_groups.loc[:,"pargpnme"].copy()
        self.parameter_groups.loc[:,"pargpnme"] = \
            self.parameter_groups.pargpnme.apply(self.pargp_format["pargpnme"])

        self._write_df("* parameter groups", f_out, self.parameter_groups,
                       self.pargp_format, self.pargp_fieldnames)
        self.parameter_groups.loc[:,"pargpnme"] = pargpnme

        self._write_df("* parameter data",f_out, self.parameter_data,
                       self.par_format, self.par_fieldnames)

        if self.tied is not None:
            self._write_df("tied parameter data", f_out, self.tied,
                           self.tied_format, self.tied_fieldnames)

        f_out.write("* observation groups\n")
        for group in self.obs_groups:
            try:
                group = group.decode()
            except:
                pass
            f_out.write(pst_utils.SFMT(str(group))+'\n')
        for group in self.prior_groups:
            try:
                group = group.decode()
            except:
                pass
            f_out.write(pst_utils.SFMT(str(group))+'\n')

        self._write_df("* observation data", f_out, self.observation_data,
                       self.obs_format, self.obs_fieldnames)

        f_out.write("* model command line\n")
        for cline in self.model_command:
            f_out.write(cline+'\n')

        f_out.write("* model input/output\n")
        for tplfle,infle in zip(self.template_files,self.input_files):
            f_out.write(tplfle+' '+infle+'\n')
        for insfle,outfle in zip(self.instruction_files,self.output_files):
            f_out.write(insfle+' '+outfle+'\n')

        if self.nprior > 0:
            if self.prior_information.isnull().values.any():
                #print("WARNING: NaNs in prior_information dataframe")
                warnings.warn("NaNs in prior_information dataframe",PyemuWarning)
            f_out.write("* prior information\n")
            #self.prior_information.index = self.prior_information.pop("pilbl")
            max_eq_len = self.prior_information.equation.apply(lambda x:len(x)).max()
            eq_fmt_str =  " {0:<" + str(max_eq_len) + "s} "
            eq_fmt_func = lambda x:eq_fmt_str.format(x)
            #  17/9/2016 - had to go with a custom writer loop b/c pandas doesn't want to
            # output strings longer than 100, even with display.max_colwidth
            #f_out.write(self.prior_information.to_string(col_space=0,
            #                                  columns=self.prior_fieldnames,
            #                                  formatters=pi_formatters,
            #                                  justify="right",
            #                                  header=False,
            #                                 index=False) + '\n')
            #self.prior_information["pilbl"] = self.prior_information.index
            # for idx,row in self.prior_information.iterrows():
            #     f_out.write(pst_utils.SFMT(row["pilbl"]))
            #     f_out.write(eq_fmt_func(row["equation"]))
            #     f_out.write(pst_utils.FFMT(row["weight"]))
            #     f_out.write(pst_utils.SFMT(row["obgnme"]) + '\n')
            for idx, row in self.prior_information.iterrows():
                f_out.write(pst_utils.SFMT(row["pilbl"]))
                f_out.write(eq_fmt_func(row["equation"]))
                f_out.write(pst_utils.FFMT(row["weight"]))
                f_out.write(pst_utils.SFMT(row["obgnme"]))
                if self.with_comments and 'extra' in row:
                    f_out.write(" # {0}".format(row['extra']))
                f_out.write('\n')

        if self.control_data.pestmode.startswith("regul"):
            #f_out.write("* regularisation\n")
            #if update_regul or len(self.regul_lines) == 0:
            #    f_out.write(self.regul_section)
            #else:
            #    [f_out.write(line) for line in self.regul_lines]
            self.reg_data.write(f_out)

        for line in self.other_lines:
            f_out.write(line+'\n')

        for key,value in self.pestpp_options.items():
            if isinstance(value,list):
                value  = ','.join([str(v) for v in value])
            f_out.write("++{0}({1})\n".format(str(key),str(value)))

        if self.with_comments:
            for line in self.comments.get("final",[]):
                f_out.write(line+'\n')

        f_out.close()