From 68fd8458dac085e94248b4aa938b889a8b28210d Mon Sep 17 00:00:00 2001 From: mjreno Date: Thu, 15 May 2025 14:42:49 -0700 Subject: [PATCH 1/3] fix netcdf usage of ModelInterface exename --- flopy/export/netcdf.py | 2 +- flopy/export/utils.py | 10 +++++++++- flopy/modflow/mf.py | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/flopy/export/netcdf.py b/flopy/export/netcdf.py index 3b29125b2..00e9e583b 100644 --- a/flopy/export/netcdf.py +++ b/flopy/export/netcdf.py @@ -219,7 +219,7 @@ def __init__( self.global_attributes = {} self.global_attributes["namefile"] = self.model.namefile self.global_attributes["model_ws"] = self.model.model_ws - self.global_attributes["exe_name"] = self.model.exe_name + self.global_attributes["exe_name"] = self.model.exename self.global_attributes["modflow_version"] = self.model.version self.global_attributes["create_hostname"] = socket.gethostname() diff --git a/flopy/export/utils.py b/flopy/export/utils.py index a40af73b9..0289cc15f 100644 --- a/flopy/export/utils.py +++ b/flopy/export/utils.py @@ -1026,7 +1026,15 @@ def transient2d_export(f: Union[str, os.PathLike], t2d, fmt=None, **kwargs): array = t2d.array with np.errstate(invalid="ignore"): - if array.dtype not in [int, np.int32, np.int64]: + from numpy import dtype + if array.dtype not in [ + int, + np.int32, + np.int64, + dtype('float64'), + dtype('int64'), + dtype('int32'), + ]: if mask is not None: array[:, 0, mask] = np.nan array[array <= min_valid] = np.nan diff --git a/flopy/modflow/mf.py b/flopy/modflow/mf.py index a5394d3e6..7ce4ca18b 100644 --- a/flopy/modflow/mf.py +++ b/flopy/modflow/mf.py @@ -140,6 +140,8 @@ def __init__( if self.version == "mf2k": self.glo = ModflowGlobal(self) + self._exename = exe_name + self.lst = ModflowList(self, unitnumber=listunit) # -- check if unstructured is specified for something # other than mfusg is specified From fae027ba3753613334a02b8b241c423a054474f4 Mon Sep 17 00:00:00 2001 From: mjreno Date: Thu, 15 May 2025 14:47:15 -0700 Subject: [PATCH 2/3] ruff reformat --- flopy/export/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flopy/export/utils.py b/flopy/export/utils.py index 0289cc15f..e490c6ea7 100644 --- a/flopy/export/utils.py +++ b/flopy/export/utils.py @@ -1027,13 +1027,14 @@ def transient2d_export(f: Union[str, os.PathLike], t2d, fmt=None, **kwargs): array = t2d.array with np.errstate(invalid="ignore"): from numpy import dtype + if array.dtype not in [ int, np.int32, np.int64, - dtype('float64'), - dtype('int64'), - dtype('int32'), + dtype("float64"), + dtype("int64"), + dtype("int32"), ]: if mask is not None: array[:, 0, mask] = np.nan From 60760f09c4ea5f51b9be815696caa92dbfcbe957 Mon Sep 17 00:00:00 2001 From: mjreno Date: Fri, 16 May 2025 06:42:58 -0700 Subject: [PATCH 3/3] add modeltime property to model interface --- flopy/mbase.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/flopy/mbase.py b/flopy/mbase.py index 40cdbf700..3eff8fb83 100644 --- a/flopy/mbase.py +++ b/flopy/mbase.py @@ -165,6 +165,13 @@ def update_modelgrid(self): ) self._mg_resync = True + @property + @abc.abstractmethod + def modeltime(self): + raise NotImplementedError( + "must define modeltime in child class to use this base class" + ) + @property @abc.abstractmethod def modelgrid(self):