def to_shapefile(self, filename, kstpkper=None, totim=None, mflay=None, attrib_name='lf_data'): """ Export model output data to a shapefile at a specific location in LayerFile instance. Parameters ---------- filename : str Shapefile name to write kstpkper : tuple of ints A tuple containing the time step and stress period (kstp, kper). These are zero-based kstp and kper values. totim : float The simulation time. mflay : integer MODFLOW zero-based layer number to return. If None, then layer 1 will be written attrib_name : str Base name of attribute columns. (default is 'lf_data') Returns ---------- None See Also -------- Notes ----- Examples -------- >>> import flopy >>> hdobj = flopy.utils.HeadFile('test.hds') >>> times = hdobj.get_times() >>> hdobj.to_shapefile('test_heads_sp6.shp', totim=times[-1]) """ plotarray = np.atleast_3d( self.get_data(kstpkper=kstpkper, totim=totim, mflay=mflay).transpose()).transpose() if mflay != None: attrib_dict = { attrib_name + '{0:03d}'.format(mflay): plotarray[0, :, :] } else: attrib_dict = {} for k in range(plotarray.shape[0]): name = attrib_name + '{0:03d}'.format(k) attrib_dict[name] = plotarray[k] from flopy.utils.flopy_io import write_grid_shapefile write_grid_shapefile(filename, self.sr, attrib_dict)
def to_shapefile(self, filename, kstpkper=None, totim=None, mflay=None, attrib_name='lf_data'): """ Export model output data to a shapefile at a specific location in LayerFile instance. Parameters ---------- filename : str Shapefile name to write kstpkper : tuple of ints A tuple containing the time step and stress period (kstp, kper). These are zero-based kstp and kper values. totim : float The simulation time. mflay : integer MODFLOW zero-based layer number to return. If None, then layer 1 will be written attrib_name : str Base name of attribute columns. (default is 'lf_data') Returns ---------- None See Also -------- Notes ----- Examples -------- >>> import flopy >>> hdobj = flopy.utils.HeadFile('test.hds') >>> times = hdobj.get_times() >>> hdobj.to_shapefile('test_heads_sp6.shp', totim=times[-1]) """ plotarray = np.atleast_3d(self.get_data(kstpkper=kstpkper, totim=totim, mflay=mflay) .transpose()).transpose() if mflay != None: attrib_dict = {attrib_name+'{0:03d}'.format(mflay):plotarray[0, :, :]} else: attrib_dict = {} for k in range(plotarray.shape[0]): name = attrib_name+'{0:03d}'.format(k) attrib_dict[name] = plotarray[k] from flopy.utils.flopy_io import write_grid_shapefile write_grid_shapefile(filename, self.sr, attrib_dict)
def to_shapefile(self, filename, kper=None): """ Export stress period boundary condition (MfList) data for a specified stress period Parameters ---------- filename : str Shapefile name to write kper : int MODFLOW zero-based stress period number to return. (default is None) Returns ---------- None See Also -------- Notes ----- Examples -------- >>> import flopy >>> ml = flopy.modflow.Modflow.load('test.nam') >>> ml.wel.to_shapefile('test_hk.shp', kper=1) """ if self.sr is None: raise Exception("MfList.to_shapefile: SpatialReference not set") import flopy.utils.flopy_io as fio if kper is None: keys = self.data.keys() keys.sort() else: keys = [kper] array_dict = {} for kk in keys: arrays = self.to_array(kk) for name, array in arrays.items(): for k in range(array.shape[0]): #aname = name+"{0:03d}_{1:02d}".format(kk, k) n = fio.shape_attr_name(name, length=4) aname = "{}{:03d}{:03d}".format(n, k+1, int(kk)+1) array_dict[aname] = array[k] fio.write_grid_shapefile(filename, self.sr, array_dict)
def to_shapefile(self, filename, kper=0): """ Export stress period boundary condition (mflist) data for a specified stress period Parameters ---------- filename : str Shapefile name to write kper : int MODFLOW zero-based stress period number to return. (default is zero) Returns ---------- None See Also -------- Notes ----- Examples -------- >>> import flopy >>> ml = flopy.modflow.Modflow.load('test.nam') >>> ml.wel.to_shapefile('test_hk.shp', kper=1) """ if self.sr is None: raise Exception("mflist.to_shapefile: SpatialReference not set") import flopy.utils.flopy_io as fio arrays = self.to_array(kper) array_dict = {} for name, array in arrays.items(): for k in range(array.shape[0]): aname = name + "{0:03d}_{1:02d}".format(kper, k) array_dict[aname] = array[k] fio.write_grid_shapefile(filename, self.sr, array_dict)