write a grid-based PEST-style factors file.  This file can be used with
        the fac2real() method to write an interpolated structured array

        Parameters
        ----------
        filename : (str)
            factor filename
        points_file : (str)
            points filename to add to the header of the factors file.
            Not used by fac2real() method.  Default is "points.junk"
        zone_file : (str)
            zone filename to add to the header of the factors file.
            Not used by fac2real() method.  Default is "zone.junk"

        Note
        ----
        this method should be called after OrdinaryKirge.calc_factors_grid()

def to_grid_factors_file(self, filename,points_file="points.junk",
                             zone_file="zone.junk"):
        """ write a grid-based PEST-style factors file.  This file can be used with
        the fac2real() method to write an interpolated structured array

        Parameters
        ----------
        filename : (str)
            factor filename
        points_file : (str)
            points filename to add to the header of the factors file.
            Not used by fac2real() method.  Default is "points.junk"
        zone_file : (str)
            zone filename to add to the header of the factors file.
            Not used by fac2real() method.  Default is "zone.junk"

        Note
        ----
        this method should be called after OrdinaryKirge.calc_factors_grid()

        """
        if self.interp_data is None:
            raise Exception("ok.interp_data is None, must call calc_factors_grid() first")
        if self.spatial_reference is None:
            raise Exception("ok.spatial_reference is None, must call calc_factors_grid() first")
        with open(filename, 'w') as f:
            f.write(points_file + '\n')
            f.write(zone_file + '\n')
            f.write("{0} {1}\n".format(self.spatial_reference.ncol, self.spatial_reference.nrow))
            f.write("{0}\n".format(self.point_data.shape[0]))
            [f.write("{0}\n".format(name)) for name in self.point_data.name]
            t = 0
            if self.geostruct.transform == "log":
                t = 1
            pt_names = list(self.point_data.name)
            for idx,names,facts in zip(self.interp_data.index,self.interp_data.inames,self.interp_data.ifacts):
                if len(facts) == 0:
                    continue
                n_idxs = [pt_names.index(name) for name in names]
                f.write("{0} {1} {2} {3:8.5e} ".format(idx+1, t, len(names), 0.0))
                [f.write("{0} {1:12.8g} ".format(i+1, w)) for i, w in zip(n_idxs, facts)]
                f.write("\n")