Skip to content

Commit ad30f68

Browse files
mjrenomjreno
authored andcommitted
codegen include longname
1 parent b3df398 commit ad30f68

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

flopy/mf6/utils/codegen/filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def _meta():
320320

321321
def __dfn():
322322
def _var(var: dict) -> List[str]:
323-
exclude = ["longname", "description"]
323+
exclude = ["description"]
324324
name = var["name"]
325325
subpkg = dfn.get("fkeys", dict()).get(name, None)
326326
if subpkg:

flopy/utils/model_netcdf.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ def layered(self):
8282
return res
8383

8484
def open(self, nc_fpth: str) -> None:
85+
"""
86+
Open an existing dataset. Assumes the dataset has been annotated
87+
with the necessary attributes to read and update, including global
88+
attributes modflow_model and modflow_grid.
89+
90+
Args:
91+
nc_fpth (str): Path to an existing NetCDF file.
92+
"""
8593
fpth = Path(nc_fpth).resolve()
8694
self._fname = fpth.name
8795

@@ -95,6 +103,16 @@ def open(self, nc_fpth: str) -> None:
95103
def create(
96104
self, modeltype: str, modelname: str, nc_type: str, fname: str, modelgrid: Grid
97105
) -> None:
106+
"""
107+
Create a new dataset.
108+
109+
Args:
110+
modeltype (str): A model type, e.g. GWF6.
111+
modelname (str): The model name.
112+
nc_type (str): A supported NetCDF file type: mesh2d or structured.
113+
fname (str): The generated NetCDF file name.
114+
modelgrid (Grid): A FloPy derived discretization object.
115+
"""
98116
self._modelname = modelname.lower()
99117
self._modeltype = modeltype.lower()
100118
self._nc_type = nc_type.lower()
@@ -971,10 +989,10 @@ def open_dataset(nc_fpth: str, grid_type: str) -> ModelNetCDFDataset:
971989
ModelNetCDFDataset: A dataset derived from the base class.
972990
"""
973991
nc_dataset = None
974-
dis_str = grid_type.lower()
992+
grid_t = grid_type.lower()
975993

976994
# grid_type corresponds to a flopy.discretization type
977-
if dis_str != "vertex" and dis_str != "structured":
995+
if grid_t != "vertex" and grid_t != "structured":
978996
raise Exception(
979997
"Supported NetCDF discretication types "
980998
'are "vertex" (DISV) and "structured" '
@@ -990,10 +1008,10 @@ def open_dataset(nc_fpth: str, grid_type: str) -> ModelNetCDFDataset:
9901008
else:
9911009
modelname = dataset.attrs["modflow_model"].split(":")[0].lower()
9921010
gridtype = dataset.attrs["modflow_grid"].lower()
993-
if dis_str == "vertex":
1011+
if grid_t == "vertex":
9941012
if gridtype == "layered mesh":
9951013
nc_dataset = DisvNetCDFMesh2d()
996-
elif dis_str == "structured":
1014+
elif grid_t == "structured":
9971015
if gridtype == "layered mesh":
9981016
nc_dataset = DisNetCDFMesh2d()
9991017
elif gridtype == "structured":
@@ -1007,7 +1025,7 @@ def open_dataset(nc_fpth: str, grid_type: str) -> ModelNetCDFDataset:
10071025
raise Exception(
10081026
f"Unable to load netcdf dataset for file grid "
10091027
f'type "{gridtype}" and discretization grid '
1010-
f'type "{dis_str}"'
1028+
f'type "{grid_t}"'
10111029
)
10121030

10131031
return nc_dataset

0 commit comments

Comments
 (0)