From 65bcc8472a6639a88e74527e984f385b9873dd3b Mon Sep 17 00:00:00 2001 From: Joseph D Hughes Date: Fri, 20 Aug 2021 11:42:30 -0500 Subject: [PATCH] refactor(deprecated): remove additional deprecated classes and functions --- autotest/t042_test.py | 1 - flopy/discretization/grid.py | 8 --- flopy/mbase.py | 5 -- flopy/mf6/mfmodel.py | 10 ---- flopy/plot/plotutil.py | 4 -- flopy/utils/__init__.py | 1 - flopy/utils/binarygrid_util.py | 42 --------------- flopy/utils/geometry.py | 36 ------------- flopy/utils/gridgen.py | 17 ------ flopy/utils/postprocessing.py | 68 ------------------------ flopy/utils/util_array.py | 96 ---------------------------------- 11 files changed, 288 deletions(-) delete mode 100644 flopy/utils/binarygrid_util.py diff --git a/autotest/t042_test.py b/autotest/t042_test.py index b41992bbcc..3d15a13255 100644 --- a/autotest/t042_test.py +++ b/autotest/t042_test.py @@ -11,7 +11,6 @@ get_transmissivities, get_water_table, get_gradients, - get_saturated_thickness, ) mf = flopy.modflow diff --git a/flopy/discretization/grid.py b/flopy/discretization/grid.py index 0fd8095709..7dbc0d3c1f 100644 --- a/flopy/discretization/grid.py +++ b/flopy/discretization/grid.py @@ -745,19 +745,11 @@ def attribs_from_namfile_header(self, namefile): elif "xul" in item.lower(): try: xul = float(item.split(":")[1]) - warnings.warn( - "xul/yul have been deprecated. Use xll/yll instead.", - DeprecationWarning, - ) except: pass elif "yul" in item.lower(): try: yul = float(item.split(":")[1]) - warnings.warn( - "xul/yul have been deprecated. Use xll/yll instead.", - DeprecationWarning, - ) except: pass elif "rotation" in item.lower(): diff --git a/flopy/mbase.py b/flopy/mbase.py index 1974ec9519..c4f7a166e4 100644 --- a/flopy/mbase.py +++ b/flopy/mbase.py @@ -347,11 +347,6 @@ def __init__( yll = kwargs.pop("yll", None) self._xul = kwargs.pop("xul", None) self._yul = kwargs.pop("yul", None) - if self._xul is not None or self._yul is not None: - warnings.warn( - "xul/yul have been deprecated. Use xll/yll instead.", - DeprecationWarning, - ) self._rotation = kwargs.pop("rotation", 0.0) self._proj4_str = kwargs.pop("proj4_str", None) diff --git a/flopy/mf6/mfmodel.py b/flopy/mf6/mfmodel.py index 9565d37b8e..60857f31c3 100644 --- a/flopy/mf6/mfmodel.py +++ b/flopy/mf6/mfmodel.py @@ -113,17 +113,7 @@ def __init__( xll = kwargs.pop("xll", None) yll = kwargs.pop("yll", None) self._xul = kwargs.pop("xul", None) - if self._xul is not None: - warnings.warn( - "xul/yul have been deprecated. Use xll/yll instead.", - DeprecationWarning, - ) self._yul = kwargs.pop("yul", None) - if self._yul is not None: - warnings.warn( - "xul/yul have been deprecated. Use xll/yll instead.", - DeprecationWarning, - ) rotation = kwargs.pop("rotation", 0.0) proj4 = kwargs.pop("proj4_str", None) # build model grid object diff --git a/flopy/plot/plotutil.py b/flopy/plot/plotutil.py index 4e5e4806a1..bf7dfa7309 100644 --- a/flopy/plot/plotutil.py +++ b/flopy/plot/plotutil.py @@ -2529,10 +2529,6 @@ def _set_coord_info(mg, xul, yul, xll, yll, rotation): import warnings if xul is not None and yul is not None: - warnings.warn( - "xul/yul have been deprecated. Use xll/yll instead.", - DeprecationWarning, - ) if rotation is not None: mg._angrot = rotation diff --git a/flopy/utils/__init__.py b/flopy/utils/__init__.py index 211c0c3b2d..a590583e0a 100644 --- a/flopy/utils/__init__.py +++ b/flopy/utils/__init__.py @@ -67,4 +67,3 @@ from .optionblock import OptionBlock from .rasters import Raster from .gridintersect import GridIntersect, ModflowGridIndices -from .binarygrid_util import MfGrdFile diff --git a/flopy/utils/binarygrid_util.py b/flopy/utils/binarygrid_util.py deleted file mode 100644 index 67dccd236c..0000000000 --- a/flopy/utils/binarygrid_util.py +++ /dev/null @@ -1,42 +0,0 @@ -""" -Deprecated version of module to read MODFLOW 6 binary grid files (*.grb) that -define the model grid binary output files. This function imports the current -version of MfGrdFile from ..mf6.utils and returns the instantiated object. -This version is deprecated and will be removed. - -""" - -import warnings - -warnings.simplefilter("always", DeprecationWarning) - - -def MfGrdFile(filename, precision="double", verbose=False): - """ - The deprecated MfGrdFile class. - - Parameters - ---------- - filename : str - Name of the MODFLOW 6 binary grid file - precision : string - 'single' or 'double'. Default is 'double'. - verbose : bool - Write information to the screen. Default is False. - - Returns - ------- - mfg : MfGrdFile - MfGrdFile object instantiated using flopy.mf6.utils.MfGrdFile - - """ - - warnings.warn( - "flopy.utils.MfGrdFile has been deprecated and will be " - "removed in version 3.3.5. Use flopy.mf6.utils.MfGrdFile instead.", - category=DeprecationWarning, - ) - - from ..mf6.utils import MfGrdFile as deprecated_MfGrdFile - - return deprecated_MfGrdFile(filename, precision=precision, verbose=verbose) diff --git a/flopy/utils/geometry.py b/flopy/utils/geometry.py index 42c0f7c9e1..5fab41d8ed 100644 --- a/flopy/utils/geometry.py +++ b/flopy/utils/geometry.py @@ -701,42 +701,6 @@ def transform( return xrot, yrot -def shape(pyshp_shpobj): - """ - Convert a pyshp geometry object to a flopy geometry object. - - Parameters - ---------- - pyshp_shpobj : shapefile._Shape instance - - Returns - ------- - shape : flopy.utils.geometry Polygon, Linestring, or Point - - Notes - ----- - Currently only regular Polygons, LineStrings and Points (pyshp types 5, 3, 1) supported. - - Examples - -------- - >>> import shapefile as sf - >>> from flopy.utils.geometry import shape - >>> sfobj = sf.Reader('shapefile.shp') - >>> flopy_geom = shape(list(sfobj.iterShapes())[0]) - - """ - import warnings - - warnings.warn( - "Method will be Deprecated, calling GeoSpatialUtil", - DeprecationWarning, - ) - - from .geospatial_utils import GeoSpatialUtil - - return GeoSpatialUtil(pyshp_shpobj).flopy_geometry - - def get_polygon_area(geom): """ Calculate the area of a closed polygon diff --git a/flopy/utils/gridgen.py b/flopy/utils/gridgen.py index a04e9b5268..5c360b4484 100644 --- a/flopy/utils/gridgen.py +++ b/flopy/utils/gridgen.py @@ -1379,13 +1379,6 @@ def get_cellxy(self, ncells): cellxy[n, 1] = y return cellxy - def get_gridprops(self): - msg = ( - "Use: " - "get_gridprops_disu5, get_gridprops_disu6, get_gridprops_disv" - ) - raise DeprecationWarning(msg) - @staticmethod def gridarray_to_flopyusg_gridarray(nodelay, a): nlay = nodelay.shape[0] @@ -1680,16 +1673,6 @@ def get_gridprops_unstructuredgrid(self): return gridprops - def to_disu6(self, fname, writevertices=True): - raise DeprecationWarning( - "Use: flopy.mf6.ModflowGwfdisu(gwf, **g.get_gridprops_disu6())" - ) - - def to_disv6(self, fname, verbose=False): - raise DeprecationWarning( - "Use: flopy.mf6.ModflowGwfdisv(gwf, **g.get_gridprops_disv())" - ) - def intersect(self, features, featuretype, layer): """ Parameters diff --git a/flopy/utils/postprocessing.py b/flopy/utils/postprocessing.py index f97214f3f3..cf115815fa 100644 --- a/flopy/utils/postprocessing.py +++ b/flopy/utils/postprocessing.py @@ -167,74 +167,6 @@ def get_water_table(heads, nodata, per_idx=None): return np.squeeze(wt) -def get_saturated_thickness(heads, m, nodata, per_idx=None): - """ - Calculates the saturated thickness for each cell from the heads - array for each stress period. - - Parameters - ---------- - heads : 3 or 4-D np.ndarray - Heads array. - m : flopy.modflow.Modflow object - Must have a flopy.modflow.ModflowDis object attached. - nodata : float, list - HDRY value indicating dry cells and/or HNOFLO values. - per_idx : int or sequence of ints - stress periods to return. If None, - returns all stress periods (default). - - Returns - ------- - sat_thickness : 3 or 4-D np.ndarray - Array of saturated thickness - """ - warnings.warn( - "postprocessing.get_saturated_thickness will be deprecated and " - "removed in version 3.3.5. Use grid.saturated_thick(heads).", - PendingDeprecationWarning, - ) - - if not isinstance(nodata, list): - nodata = [nodata] - heads = np.array(heads, ndmin=4) - for mv in nodata: - heads[heads == mv] = np.nan - - top = m.dis.top.array - botm = m.dis.botm.array - top.shape = (1,) + botm.shape[1:] - top = np.concatenate((top, botm[0:-1]), axis=0) - thickness = m.modelgrid.thick - nper, nlay, nrow, ncol = heads.shape - if per_idx is None: - per_idx = list(range(nper)) - elif np.isscalar(per_idx): - per_idx = [per_idx] - - # get confined or unconfined/convertible info - laytyp = m.laytyp - if len(laytyp.shape) == 1: - laytyp.shape = (m.nlay, 1, 1) - is_conf = np.logical_and( - (laytyp == 0), np.full(m.modelgrid.shape, True) - ) - else: - is_conf = laytyp == 0 - - # calculate saturated thickness - sat_thickness = [] - for per in per_idx: - hds = heads[per] - hds = np.where(hds < botm, botm, hds) # for NWT when hds < botm - unconf_thickness = np.where(hds > top, top - botm, hds - botm) - perthickness = np.where(is_conf, thickness, unconf_thickness) - sat_thickness.append(perthickness) - sat_thickness = np.squeeze(sat_thickness) - - return sat_thickness - - def get_gradients(heads, m, nodata, per_idx=None): """ Calculates the hydraulic gradients from the heads diff --git a/flopy/utils/util_array.py b/flopy/utils/util_array.py index c21c62accf..4043bfdec3 100644 --- a/flopy/utils/util_array.py +++ b/flopy/utils/util_array.py @@ -659,38 +659,6 @@ def export(self, f, **kwargs): return export.utils.array3d_export(f, self, **kwargs) - def to_shapefile(self, filename): - """ - Export 3-D model data to shapefile (polygons). Adds an - attribute for each Util2d in self.u2ds - - Parameters - ---------- - filename : str - Shapefile name to write - - Returns - ---------- - None - - See Also - -------- - - Notes - ----- - - Examples - -------- - >>> import flopy - >>> ml = flopy.modflow.Modflow.load('test.nam') - >>> ml.lpf.hk.to_shapefile('test_hk.shp') - """ - warn( - "Deprecation warning: to_shapefile() is deprecated. use .export()", - DeprecationWarning, - ) - self.export(filename) - def plot( self, filename_base=None, @@ -1494,38 +1462,6 @@ def get_zero_2d(self, kper): array_free_format=self.array_free_format, ) - def to_shapefile(self, filename): - """ - Export transient 2D data to a shapefile (as polygons). Adds an - attribute for each unique Util2d instance in self.data - - Parameters - ---------- - filename : str - Shapefile name to write - - Returns - ---------- - None - - See Also - -------- - - Notes - ----- - - Examples - -------- - >>> import flopy - >>> ml = flopy.modflow.Modflow.load('test.nam') - >>> ml.rch.rech.as_shapefile('test_rech.shp') - """ - warn( - "Deprecation warning: to_shapefile() is deprecated. use .export()", - DeprecationWarning, - ) - self.export(filename) - def plot( self, filename_base=None, @@ -2076,38 +2012,6 @@ def export(self, f, **kwargs): return export.utils.array2d_export(f, self, **kwargs) - def to_shapefile(self, filename): - """ - Export 2-D model data to a shapefile (as polygons) of self.array - - Parameters - ---------- - filename : str - Shapefile name to write - - Returns - ---------- - None - - See Also - -------- - - Notes - ----- - - Examples - -------- - >>> import flopy - >>> ml = flopy.modflow.Modflow.load('test.nam') - >>> ml.dis.top.as_shapefile('test_top.shp') - """ - - warn( - "Deprecation warning: to_shapefile() is deprecated. use .export()", - DeprecationWarning, - ) - self.export(filename) - def set_fmtin(self, fmtin): self._format = ArrayFormat( self,