diff --git a/flopy/export/utils.py b/flopy/export/utils.py index 81d02f0771..e8266787a4 100644 --- a/flopy/export/utils.py +++ b/flopy/export/utils.py @@ -605,7 +605,7 @@ def model_export( prjfile : str or pathlike, optional if `crs` is specified ESRI-style projection file with well-known text defining the CRS for the model grid (must be projected; geographic CRS are not supported). - if fmt is set to 'vtk', parameters of vtk.export_model + if fmt is set to 'vtk', parameters of Vtk initializer """ assert isinstance(ml, ModelInterface) @@ -698,7 +698,7 @@ def package_export( prjfile : str or pathlike, optional if `crs` is specified ESRI-style projection file with well-known text defining the CRS for the model grid (must be projected; geographic CRS are not supported). - if fmt is set to 'vtk', parameters of vtk.export_package + if fmt is set to 'vtk', parameters of Vtk initializer Returns ------- @@ -771,22 +771,6 @@ def package_export( vtkobj.add_package(pak, masked_values=masked_values) vtkobj.write(os.path.join(f, name), kper=kpers) - - """ - vtk.export_package( - pak.parent, - pak.name, - f, - nanval=nanval, - smooth=smooth, - point_scalars=point_scalars, - vtk_grid_type=vtk_grid_type, - true2d=true2d, - binary=binary, - kpers=kpers, - ) - """ - else: raise NotImplementedError(f"unrecognized export argument:{f}") @@ -1049,7 +1033,7 @@ def transient2d_export(f: Union[str, os.PathLike], t2d, fmt=None, **kwargs): max_valid : maximum valid value modelgrid : flopy.discretization.Grid model grid instance which will supercede the flopy.model.modelgrid - if fmt is set to 'vtk', parameters of vtk.export_transient + if fmt is set to 'vtk', parameters of Vtk initializer """ @@ -1209,7 +1193,7 @@ def array3d_export(f: Union[str, os.PathLike], u3d, fmt=None, **kwargs): max_valid : maximum valid value modelgrid : flopy.discretization.Grid model grid instance which will supercede the flopy.model.modelgrid - if fmt is set to 'vtk', parameters of vtk.export_array + if fmt is set to 'vtk', parameters of Vtk initializer """ @@ -1387,7 +1371,7 @@ def array2d_export( max_valid : maximum valid value modelgrid : flopy.discretization.Grid model grid instance which will supercede the flopy.model.modelgrid - if fmt is set to 'vtk', parameters of vtk.export_array + if fmt is set to 'vtk', parameters of Vtk initializer """ assert isinstance( diff --git a/flopy/export/vtk.py b/flopy/export/vtk.py index 45fa2d6633..fd9cbf1232 100644 --- a/flopy/export/vtk.py +++ b/flopy/export/vtk.py @@ -1500,531 +1500,3 @@ def __create_transient_vtk_path(self, path, kper): {:06d} represents the six zero padded stress period time """ return path.parent / f"{path.stem.rstrip('_')}_{kper:06d}{path.suffix}" - - -def export_model( - model, - otfolder: Union[str, os.PathLike], - package_names=None, - nanval=-1e20, - smooth=False, - point_scalars=False, - vtk_grid_type="auto", - true2d=False, - binary=True, - kpers=None, -): - """ - Export model to vtk - - .. deprecated:: 3.3.5 - Use :meth:`Vtk.add_model` - - Parameters - ---------- - model : flopy model instance - flopy model - otfolder : str or PathLike - output folder - package_names : list - list of package names to be exported - nanval : scalar - no data value, default value is -1e20 - array2d : bool - True if array is 2d, default is False - smooth : bool - if True, will create smooth layer elevations, default is False - point_scalars : bool - if True, will also output array values at cell vertices, default is - False; note this automatically sets smooth to True - vtk_grid_type : str - Specific vtk_grid_type or 'auto' (default). Possible specific values - are 'ImageData', 'RectilinearGrid', and 'UnstructuredGrid'. - If 'auto', the grid type is automatically determined. Namely: - * A regular grid (in all three directions) will be saved as an - 'ImageData'. - * A rectilinear (in all three directions), non-regular grid - will be saved as a 'RectilinearGrid'. - * Other grids will be saved as 'UnstructuredGrid'. - true2d : bool - If True, the model is expected to be 2d (1 layer, 1 row or 1 column) - and the data will be exported as true 2d data, default is False. - binary : bool - if True the output file will be binary, default is False - kpers : iterable of int - Stress periods to export. If None (default), all stress periods will be - exported. - """ - warnings.warn("export_model is deprecated, please use Vtk.add_model()") - - if nanval != -1e20: - warnings.warn("nanval is deprecated, setting to np.nan") - if true2d: - warnings.warn("true2d is no longer supported, setting to False") - if vtk_grid_type != "auto": - warnings.warn("vtk_grid_type is deprecated, setting to binary") - - vtk = Vtk( - model, - vertical_exageration=1, - binary=binary, - smooth=smooth, - point_scalars=point_scalars, - ) - - vtk.add_model(model, package_names) - - if not os.path.exists(otfolder): - os.mkdir(otfolder) - - name = model.name - vtk.write(os.path.join(otfolder, name), kper=kpers) - - -def export_package( - pak_model, - pak_name, - otfolder: Union[str, os.PathLike], - vtkobj=None, - nanval=-1e20, - smooth=False, - point_scalars=False, - vtk_grid_type="auto", - true2d=False, - binary=True, - kpers=None, -): - """ - Export package to vtk - - .. deprecated:: 3.3.5 - Use :meth:`Vtk.add_package` - - Parameters - ---------- - pak_model : flopy model instance - the model of the package - pak_name : str - the name of the package - otfolder : str or PathLike - output folder to write the data - vtkobj : VTK instance - a vtk object (allows export_package to be called from - export_model) - nanval : scalar - no data value, default value is -1e20 - smooth : bool - if True, will create smooth layer elevations, default is False - point_scalars : bool - if True, will also output array values at cell vertices, default is - False; note this automatically sets smooth to True - vtk_grid_type : str - Specific vtk_grid_type or 'auto' (default). Possible specific values - are 'ImageData', 'RectilinearGrid', and 'UnstructuredGrid'. - If 'auto', the grid type is automatically determined. Namely: - * A regular grid (in all three directions) will be saved as an - 'ImageData'. - * A rectilinear (in all three directions), non-regular grid - will be saved as a 'RectilinearGrid'. - * Other grids will be saved as 'UnstructuredGrid'. - true2d : bool - If True, the model is expected to be 2d (1 layer, 1 row or 1 column) - and the data will be exported as true 2d data, default is False. - binary : bool - if True the output file will be binary, default is False - kpers : iterable of int - Stress periods to export. If None (default), all stress periods will be - exported. - """ - warnings.warn("export_package is deprecated, use Vtk.add_package()") - - if nanval != -1e20: - warnings.warn("nanval is deprecated, setting to np.nan") - if true2d: - warnings.warn("true2d is no longer supported, setting to False") - if vtk_grid_type != "auto": - warnings.warn("vtk_grid_type is deprecated, setting to binary") - - if not vtkobj: - vtk = Vtk( - pak_model, - binary=binary, - smooth=smooth, - point_scalars=point_scalars, - ) - else: - vtk = vtkobj - - if not os.path.exists(otfolder): - os.mkdir(otfolder) - - if isinstance(pak_name, list): - pak_name = pak_name[0] - - p = pak_model.get_package(pak_name) - vtk.add_package(p) - - vtk.write(os.path.join(otfolder, pak_name), kper=kpers) - - -def export_transient( - model, - array, - output_folder: Union[str, os.PathLike], - name, - nanval=-1e20, - array2d=False, - smooth=False, - point_scalars=False, - vtk_grid_type="auto", - true2d=False, - binary=True, - kpers=None, -): - """ - Export transient arrays and lists to vtk - - .. deprecated:: 3.3.5 - Use :meth:`Vtk.add_transient_array` or :meth:`Vtk.add_transient_list` - - Parameters - ---------- - model : MFModel - the flopy model instance - array : Transient instance - flopy transient array - output_folder : str or PathLike - output folder to write the data - name : str - name of array - nanval : scalar - no data value, default value is -1e20 - array2d : bool - True if array is 2d, default is False - smooth : bool - if True, will create smooth layer elevations, default is False - point_scalars : bool - if True, will also output array values at cell vertices, default is - False; note this automatically sets smooth to True - vtk_grid_type : str - Specific vtk_grid_type or 'auto' (default). Possible specific values - are 'ImageData', 'RectilinearGrid', and 'UnstructuredGrid'. - If 'auto', the grid type is automatically determined. Namely: - * A regular grid (in all three directions) will be saved as an - 'ImageData'. - * A rectilinear (in all three directions), non-regular grid - will be saved as a 'RectilinearGrid'. - * Other grids will be saved as 'UnstructuredGrid'. - true2d : bool - If True, the model is expected to be 2d (1 layer, 1 row or 1 column) - and the data will be exported as true 2d data, default is False. - binary : bool - if True the output file will be binary, default is False - kpers : iterable of int - Stress periods to export. If None (default), all stress periods will be - exported. - """ - warnings.warn( - "export_transient is deprecated, use Vtk.add_transient_array() or " - "Vtk.add_transient_list()" - ) - - if nanval != -1e20: - warnings.warn("nanval is deprecated, setting to np.nan") - if true2d: - warnings.warn("true2d is no longer supported, setting to False") - if vtk_grid_type != "auto": - warnings.warn("vtk_grid_type is deprecated, setting to binary") - if array2d: - warnings.warn( - "array2d parameter is deprecated, 2d arrays are " - "handled automatically" - ) - - if not os.path.exists(output_folder): - os.mkdir(output_folder) - - vtk = Vtk(model, binary=binary, smooth=smooth, point_scalars=point_scalars) - - if array.data_type == DataType.transient2d: - if array.array is not None: - if hasattr(array, "transient_2ds"): - vtk.add_transient_array(array.transient_2ds, name) - else: - d = {ix: i for ix, i in enumerate(array.array)} - vtk.add_transient_array(d, name) - - elif array.data_type == DataType.transient3d: - if array.array is None: - vtk.add_transient_array(array.transient_3ds, name) - - elif array.data_type == DataType.transientlist: - vtk.add_transient_list(array) - - else: - raise TypeError(f"type {type(array)} not valid for export_transient") - - vtk.write(os.path.join(output_folder, name), kper=kpers) - - -def export_array( - model, - array, - output_folder: Union[str, os.PathLike], - name, - nanval=-1e20, - array2d=False, - smooth=False, - point_scalars=False, - vtk_grid_type="auto", - true2d=False, - binary=True, -): - """ - Export array to vtk - - .. deprecated:: 3.3.5 - Use :meth:`Vtk.add_array` - - Parameters - ---------- - model : flopy model instance - the flopy model instance - array : flopy array - flopy 2d or 3d array - output_folder : str or PathLike - output folder to write the data - name : str - name of array - nanval : scalar - no data value, default value is -1e20 - array2d : bool - true if the array is 2d and represents the first layer, default is - False - smooth : bool - if True, will create smooth layer elevations, default is False - point_scalars : bool - if True, will also output array values at cell vertices, default is - False; note this automatically sets smooth to True - vtk_grid_type : str - Specific vtk_grid_type or 'auto' (default). Possible specific values - are 'ImageData', 'RectilinearGrid', and 'UnstructuredGrid'. - If 'auto', the grid type is automatically determined. Namely: - * A regular grid (in all three directions) will be saved as an - 'ImageData'. - * A rectilinear (in all three directions), non-regular grid - will be saved as a 'RectilinearGrid'. - * Other grids will be saved as 'UnstructuredGrid'. - true2d : bool - If True, the model is expected to be 2d (1 layer, 1 row or 1 column) - and the data will be exported as true 2d data, default is False. - binary : bool - if True the output file will be binary, default is False - """ - warnings.warn("export_array is deprecated, please use Vtk.add_array()") - - if nanval != -1e20: - warnings.warn("nanval is deprecated, setting to np.nan") - if true2d: - warnings.warn("true2d is no longer supported, setting to False") - if vtk_grid_type != "auto": - warnings.warn("vtk_grid_type is deprecated, setting to binary") - if array2d: - warnings.warn( - "array2d parameter is deprecated, 2d arrays are " - "handled automatically" - ) - - if not os.path.exists(output_folder): - os.mkdir(output_folder) - - if array.size < model.modelgrid.nnodes: - if array.size < model.modelgrid.ncpl: - raise AssertionError( - "Array size must be equal to either ncpl or nnodes" - ) - - array = np.zeros(model.modelgrid.nnodes) * np.nan - array[: array.size] = np.ravel(array) - - vtk = Vtk(model, binary=binary, smooth=smooth, point_scalars=point_scalars) - - vtk.add_array(array, name) - vtk.write(os.path.join(output_folder, name)) - - -def export_heads( - model, - hdsfile, - otfolder, - text="head", - precision="auto", - verbose=False, - nanval=-1e20, - kstpkper=None, - smooth=False, - point_scalars=False, - vtk_grid_type="auto", - true2d=False, - binary=True, -): - """ - Exports binary head file to vtk - - .. deprecated:: 3.3.5 - Use :meth:`Vtk.add_heads` - - Parameters - ---------- - model : MFModel - the flopy model instance - hdsfile : str, HeadFile object - binary head file path or object - otfolder : str - output folder to write the data - text : string - Name of the text string in the head file. Default is 'head'. - precision : str - Precision of data in the head file: 'auto', 'single' or 'double'. - Default is 'auto'. - verbose : bool - If True, write information to the screen. Default is False. - nanval : scalar - no data value, default value is -1e20 - kstpkper : tuple of ints or list of tuple of ints - A tuple containing the time step and stress period (kstp, kper). - The kstp and kper values are zero based. - smooth : bool - if True, will create smooth layer elevations, default is False - point_scalars : bool - if True, will also output array values at cell vertices, default is - False; note this automatically sets smooth to True - vtk_grid_type : str - Specific vtk_grid_type or 'auto' (default). Possible specific values - are 'ImageData', 'RectilinearGrid', and 'UnstructuredGrid'. - If 'auto', the grid type is automatically determined. Namely: - * A regular grid (in all three directions) will be saved as an - 'ImageData'. - * A rectilinear (in all three directions), non-regular grid - will be saved as a 'RectilinearGrid'. - * Other grids will be saved as 'UnstructuredGrid'. - true2d : bool - If True, the model is expected to be 2d (1 layer, 1 row or 1 column) - and the data will be exported as true 2d data, default is False. - binary : bool - if True the output file will be binary, default is False - """ - warnings.warn("export_heads is deprecated, use Vtk.add_heads()") - - if nanval != -1e20: - warnings.warn("nanval is deprecated, setting to np.nan") - if true2d: - warnings.warn("true2d is no longer supported, setting to False") - if vtk_grid_type != "auto": - warnings.warn("vtk_grid_type is deprecated, setting to binary") - - from ..utils import HeadFile - - if not os.path.exists(otfolder): - os.mkdir(otfolder) - - if not isinstance(hdsfile, HeadFile): - hds = HeadFile( - hdsfile, text=text, precision=precision, verbose=verbose - ) - else: - hds = hdsfile - - vtk = Vtk(model, binary=binary, smooth=smooth, point_scalars=point_scalars) - - vtk.add_heads(hds, kstpkper) - name = f"{model.name}_{text}" - vtk.write(os.path.join(otfolder, name)) - - -def export_cbc( - model, - cbcfile, - otfolder, - precision="single", - verbose=False, - nanval=-1e20, - kstpkper=None, - text=None, - smooth=False, - point_scalars=False, - vtk_grid_type="auto", - true2d=False, - binary=True, -): - """ - Exports cell by cell file to vtk - - .. deprecated:: 3.3.5 - Use :meth:`Vtk.add_cell_budget` - - Parameters - ---------- - model : flopy model instance - the flopy model instance - cbcfile : str - the cell by cell file - otfolder : str - output folder to write the data - precision : str - Precision of data in the cell by cell file: 'single' or 'double'. - Default is 'single'. - verbose : bool - If True, write information to the screen. Default is False. - nanval : scalar - no data value - kstpkper : tuple of ints or list of tuple of ints - A tuple containing the time step and stress period (kstp, kper). - The kstp and kper values are zero based. - text : str or list of str - The text identifier for the record. Examples include - 'RIVER LEAKAGE', 'STORAGE', 'FLOW RIGHT FACE', etc. - smooth : bool - if True, will create smooth layer elevations, default is False - point_scalars : bool - if True, will also output array values at cell vertices, default is - False; note this automatically sets smooth to True - vtk_grid_type : str - Specific vtk_grid_type or 'auto' (default). Possible specific values - are 'ImageData', 'RectilinearGrid', and 'UnstructuredGrid'. - If 'auto', the grid type is automatically determined. Namely: - * A regular grid (in all three directions) will be saved as an - 'ImageData'. - * A rectilinear (in all three directions), non-regular grid - will be saved as a 'RectilinearGrid'. - * Other grids will be saved as 'UnstructuredGrid'. - true2d : bool - If True, the model is expected to be 2d (1 layer, 1 row or 1 column) - and the data will be exported as true 2d data, default is False. - binary : bool - if True the output file will be binary, default is False - """ - warnings.warn("export_cbc is deprecated, use Vtk.add_cell_budget()") - - if nanval != -1e20: - warnings.warn("nanval is deprecated, setting to np.nan") - if true2d: - warnings.warn("true2d is no longer supported, setting to False") - if vtk_grid_type != "auto": - warnings.warn("vtk_grid_type is deprecated, setting to binary") - - from ..utils import CellBudgetFile - - if not os.path.exists(otfolder): - os.mkdir(otfolder) - - if not isinstance(cbcfile, CellBudgetFile): - cbc = CellBudgetFile(cbcfile, precision=precision, verbose=verbose) - else: - cbc = cbcfile - - vtk = Vtk(model, binary=binary, smooth=smooth, point_scalars=point_scalars) - - vtk.add_cell_budget(cbc, text, kstpkper) - fname = f"{model.name}_CBC" - vtk.write(os.path.join(otfolder, fname)) diff --git a/flopy/mf6/mfmodel.py b/flopy/mf6/mfmodel.py index dcab7fdea9..37fa4cadcb 100644 --- a/flopy/mf6/mfmodel.py +++ b/flopy/mf6/mfmodel.py @@ -640,7 +640,7 @@ def export(self, f, **kwargs): modelgrid: flopy.discretization.Grid User supplied modelgrid object which will supercede the built in modelgrid object - if fmt is set to 'vtk', parameters of vtk.export_model + if fmt is set to 'vtk', parameters of Vtk initializer """ from ..export import utils