From 0a85cc1c0d8d186d3fb94b94d89bad7e0c19d46c Mon Sep 17 00:00:00 2001 From: jlarsen Date: Wed, 13 Nov 2024 15:43:30 -0800 Subject: [PATCH] Remove TemporalReference, replaced functionality with ModelTime --- flopy/mbase.py | 17 ++--------------- flopy/mfusg/mfusgdisu.py | 3 --- flopy/modflow/mfdis.py | 2 -- flopy/utils/__init__.py | 1 - flopy/utils/reference.py | 31 ------------------------------- 5 files changed, 2 insertions(+), 52 deletions(-) delete mode 100644 flopy/utils/reference.py diff --git a/flopy/mbase.py b/flopy/mbase.py index f0bfbdaac9..203512b7d5 100644 --- a/flopy/mbase.py +++ b/flopy/mbase.py @@ -684,8 +684,7 @@ def __getattr__(self, item): Returns ------- object, str, int or None - Package object of type :class:`flopy.pakbase.Package`, - :class:`flopy.utils.reference.TemporalReference`, str, int or None. + Package object of type :class:`flopy.pakbase.Package`, str, int, or None Raises ------ @@ -701,12 +700,6 @@ def __getattr__(self, item): if item == "output_packages" or not hasattr(self, "output_packages"): raise AttributeError(item) - if item == "tr": - if self.dis is not None: - return self.dis.tr - else: - return None - if item == "nper": # most subclasses have a nper property, but ModflowAg needs this if self.dis is not None: @@ -1346,16 +1339,10 @@ def __setattr__(self, key, value): self._set_name(value) elif key == "model_ws": self.change_model_ws(value) - elif key == "tr": - assert isinstance(value, discretization.reference.TemporalReference) - if self.dis is not None: - self.dis.tr = value - else: - raise Exception("cannot set TemporalReference - ModflowDis not found") elif key == "start_datetime": if self.dis is not None: self.dis.start_datetime = value - self.tr.start_datetime = value + self.modeltime.set_start_datetime(value) else: raise Exception("cannot set start_datetime - ModflowDis not found") else: diff --git a/flopy/mfusg/mfusgdisu.py b/flopy/mfusg/mfusgdisu.py index 0c284387d2..b95f2f3597 100644 --- a/flopy/mfusg/mfusgdisu.py +++ b/flopy/mfusg/mfusgdisu.py @@ -8,7 +8,6 @@ from ..discretization.unstructuredgrid import UnstructuredGrid from ..pakbase import Package from ..utils import Util2d, Util3d, read1d -from ..utils.reference import TemporalReference from .mfusg import MfUsg ITMUNI = {"u": 0, "s": 1, "m": 2, "h": 3, "d": 4, "y": 5} @@ -443,8 +442,6 @@ def __init__( lenuni=self.lenuni, ) - self.tr = TemporalReference(itmuni=self.itmuni, start_datetime=start_datetime) - self.start_datetime = start_datetime # get neighboring nodes diff --git a/flopy/modflow/mfdis.py b/flopy/modflow/mfdis.py index cb1c103178..20cf8d806e 100644 --- a/flopy/modflow/mfdis.py +++ b/flopy/modflow/mfdis.py @@ -16,7 +16,6 @@ from ..utils import Util2d, Util3d from ..utils.crs import get_crs from ..utils.flopy_io import line_parse -from ..utils.reference import TemporalReference ITMUNI = {"u": 0, "s": 1, "m": 2, "h": 3, "d": 4, "y": 5} LENUNI = {"u": 0, "f": 1, "m": 2, "c": 3} @@ -273,7 +272,6 @@ def __init__( if start_datetime is None: start_datetime = model._start_datetime - self.tr = TemporalReference(itmuni=self.itmuni, start_datetime=start_datetime) self.start_datetime = start_datetime self._totim = None diff --git a/flopy/utils/__init__.py b/flopy/utils/__init__.py index 87e0b6e5c6..ece1430ce9 100644 --- a/flopy/utils/__init__.py +++ b/flopy/utils/__init__.py @@ -51,7 +51,6 @@ from .postprocessing import get_specific_discharge, get_transmissivities from .rasters import Raster from .recarray_utils import create_empty_recarray, ra_slice, recarray -from .reference import TemporalReference from .sfroutputfile import SfrFile from .swroutputfile import ( SwrBudget, diff --git a/flopy/utils/reference.py b/flopy/utils/reference.py deleted file mode 100644 index ea962b5913..0000000000 --- a/flopy/utils/reference.py +++ /dev/null @@ -1,31 +0,0 @@ -"""Temporal referencing for flopy model objects.""" - -__all__ = ["TemporalReference"] - - -class TemporalReference: - """ - For now, just a container to hold start time and time units files - outside of DIS package. - """ - - defaults = {"itmuni": 4, "start_datetime": "01-01-1970"} - - itmuni_values = { - "undefined": 0, - "seconds": 1, - "minutes": 2, - "hours": 3, - "days": 4, - "years": 5, - } - - itmuni_text = {v: k for k, v in itmuni_values.items()} - - def __init__(self, itmuni=4, start_datetime=None): - self.itmuni = itmuni - self.start_datetime = start_datetime - - @property - def model_time_units(self): - return self.itmuni_text[self.itmuni]