-
Notifications
You must be signed in to change notification settings - Fork 344
Description
flopy 3.3.5
python 3.10.5
Model grid geographic reference information can be loaded from files. No such option exists for model temporal reference information.
Current Behavior
Default behavior for flopy.discretization.Grid classes is to read from the following references in order:
- usgs.model.reference
- NAM file (header comment)
- defaults
The .modflow.Modflow class creates .discretization.ModelTime and (sub-classes of) .discretization.Grid objects for it's modeltime and modelgrid attributes (respectively).
The ModelTime object does not support reading from the above references like it's Grid counterpart does. Additionally, the .utils.reference.TemporalReference does not support reading from file either.
Existing behavior for reading temporal information exists in the Grid class in it's read_usgs_model_reference_file and attribs_from_namfile_header methods. Currently, temporal information is not used. Moving these methods to .utils.reference, and adjusting them to be functions that return dict could allow their use in the ModelTime class as well.
Proposed Change
- Create 2 functions,
read_usgs_model_reference_fileandread_attribs_from_namfile_headerin.utils.reference. Use the following signatures.def read_usgs_model_reference_file(reffile: str="usgs.model.reference") -> dict:def read_attribs_from_namfile_header(namefile: str)-> dict:
- Alter 2 existing methods in
.discretization.Grid. Adjust these methods to use the.utils.referecefunctions created above. Changes would be made oread_usgs_model_reference_fileandattribs_from_namfile_headermethods. - Add 2 methods in
.discretization.ModelTimeclass to mirror the API for theGridclass.
Files changed would be:
flopy/discretization/grid.pyflopy/discretization/modeltime.pyflopy/utils/reference.py
Let me know if you see any complications here that I am ignorant to. If there are none seen, I can submit a pull request.
Cheers
Minimum Reproducible Example Files
example.nam
# Name file for MODFLOW-NWT, generated by Flopy version 3.3.5.
LIST 2 example.list
DIS 11 example.dis
example.dis
# DIS package for MODFLOW-NWT generated by Flopy 3.3.5
1 1 1 5 4 2
0
CONSTANT 1.000000E+00 #delr
CONSTANT 1.000000E+00 #delc
CONSTANT 1.000000E+00 #model_top
CONSTANT 0.000000E+00 #botm layer 1
1.000000 1 1.000000 SS
1.000000 1 1.000000 SS
1.000000 1 1.000000 SS
1.000000 1 1.000000 SS
1.000000 1 1.000000 SS
usgs.model.reference
# Hypothetical, non-zero for demonstration
xul 2.022
yul 3.14
rotation 42
# Set non-typical
time_units days
start_date 1/1/2000
start_time 00:00:00
read_example.py
import flopy
model = flopy.modflow.Modflow.load('example.nam')
model.modelgrid.load_coord_info('example.nam') # No api available for temporal data
print(model.modeltime.start_datetime)
# 1-1-1970
print(model.modelgrid)
# xll:2.691130606358858; yll:2.3968551745226057; rotation:42.0; units:meters; lenuni:2