Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse MODFLOW6 input (partially) #688

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
664a98b
Add functionality for writing structured data to DISU
Huite Mar 2, 2022
97135b2
Rename to LowLevel; add pkg conversion to disu
Huite Mar 3, 2022
fd5e743
Make a start with reading MODFLOW6 input files
Huite Apr 4, 2022
e1f2856
Simulation.open() seems to be running.
Huite Apr 4, 2022
c1d1e75
Adjustments:
Huite Apr 6, 2022
b03ca97
Merge branch 'dupuit' into parse-mf6-input
Huite Apr 6, 2022
e24d517
Use package name for storage directory
Huite Apr 8, 2022
18697e2
Intercept NaNs as xarray yreplaces None by NaN when writing to file
Huite Apr 8, 2022
2987e00
Merge branch 'master' into parse-mf6-input
Huite May 4, 2022
c5d1ff4
Do not duplicate entry when replacing exponents when casting to float
Huite May 6, 2022
7ae6e09
Write low level DISU fixes
Huite May 10, 2022
ae7c93d
newline in error message
Huite May 10, 2022
ed7a162
Add a data array reshape in utils
Huite May 10, 2022
f198ee7
More comments on mf6 header sizes in output files
Huite May 10, 2022
e6d54a3
Read DISU head output
Huite May 10, 2022
724cbde
Add name to open_hds_like
Huite May 10, 2022
2b4819d
Uncomment jit statement
Huite May 16, 2022
25cb83d
Warning message formatting
Huite May 16, 2022
fb504bc
Add tests for read_input/common.py and grid_data.py
Huite May 18, 2022
4b590d4
Merge branch 'master' into parse-mf6-input
Huite May 19, 2022
b122897
format
Huite May 19, 2022
92d10b2
Tests for mf6 read_input: grid_data and list_input
Huite May 19, 2022
c8ecda8
Update disu connectivity tests
Huite May 19, 2022
836b63d
Use textwrap for test text content
Huite May 19, 2022
cad182e
Forgot to use a tmp_path fixture
Huite May 19, 2022
032c88a
More unit tests and integration test for mf6 input reading
Huite May 20, 2022
76a6b57
Add logic for reading model input of classes that are DIS, DISV, or D…
Huite May 23, 2022
b6ad9d3
Add logic for reading WellDisStructured
Huite May 23, 2022
355531a
Move dupuit example to a separate repo
Huite May 25, 2022
b7c7b3c
Add to_disu tests
Huite May 25, 2022
e014958
Merge branch 'master' into parse-mf6-input
Huite May 25, 2022
35976e3
Remove unused bas module from mf6
Huite May 25, 2022
ce5ac5e
Ensure the applying the factor doesn't cast to a different type
Huite Jun 14, 2022
aa439d2
Space in warning
Huite Jun 14, 2022
4abab8e
Add angledegx for connection normal in disu from dis method
Huite Jun 14, 2022
9b29cb1
Include angldegx correctly in disu input
Huite Jun 15, 2022
38cdafb
Use node number for DISU list based input, rather than to start numbe…
Huite Jun 20, 2022
72b4842
Add index_col=False to read_text_listinput
Huite Jun 23, 2022
fe172a5
Take 1-based indexing into account for MODFLOW periods
Huite Aug 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion imod/mf6/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from imod.mf6.chd import ConstantHead
from imod.mf6.dis import StructuredDiscretization
from imod.mf6.disu import LowLevelUnstructuredDiscretization
from imod.mf6.disv import VerticesDiscretization
from imod.mf6.drn import Drainage
from imod.mf6.evt import Evapotranspiration
Expand All @@ -18,7 +19,7 @@
from imod.mf6.model import GroundwaterFlowModel
from imod.mf6.npf import NodePropertyFlow
from imod.mf6.oc import OutputControl
from imod.mf6.out import open_cbc, open_hds, read_cbc_headers, read_grb
from imod.mf6.out import open_cbc, open_hds, open_hds_like, read_cbc_headers, read_grb
from imod.mf6.rch import Recharge
from imod.mf6.riv import River
from imod.mf6.simulation import Modflow6Simulation
Expand Down
215 changes: 0 additions & 215 deletions imod/mf6/bas.py

This file was deleted.

39 changes: 39 additions & 0 deletions imod/mf6/dis.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from pathlib import Path

import numpy as np
import xarray as xr

import imod
from imod.mf6.pkgbase import Package, VariableMetaData

from .read_input import read_dis_blockfile


class StructuredDiscretization(Package):
"""
Expand Down Expand Up @@ -60,6 +65,40 @@ def _delrc(self, dx):
else:
raise ValueError(f"Unhandled type of {dx}")

@classmethod
def open(cls, path: str, simroot: Path) -> "StructuredDiscretization":
content = read_dis_blockfile(simroot / path, simroot)
nlay = content["nlay"]

griddata = content["griddata"]
xmin = float(content.get("xorigin", 0.0))
ymin = float(content.get("yorigin", 0.0))
dx = griddata.pop("delr")
dy = griddata.pop("delc")
x = (xmin + np.cumsum(dx)) - 0.5 * dx
y = ((ymin + np.cumsum(dy)) - 0.5 * dy)[::-1]

# Top is a 2D array unlike the others
top = xr.DataArray(
data=griddata.pop("top"),
coords={"y": y, "x": x},
dims=("y", "x"),
)

coords = {"layer": np.arange(1, nlay + 1), "y": y, "x": x}
dims = ("layer", "y", "x")
inverse_keywords = {v: k for k, v in cls._keyword_map.items()}
variables = {"top": top}
for key, value in griddata.items():
invkey = inverse_keywords.get(key, key)
variables[invkey] = xr.DataArray(
value,
coords,
dims,
)

return cls(**variables)

def render(self, directory, pkgname, globaltimes, binary):
disdirectory = directory / pkgname
d = {}
Expand Down
Loading