-
Notifications
You must be signed in to change notification settings - Fork 2
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
Issue #344 part1 imod refactor primod update #348
Changes from all commits
f799c98
cf68f4c
6292eb0
824974a
f171f74
e8254eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
import numpy as np | ||
import pandas as pd | ||
import xarray as xr | ||
from imod import mf6 | ||
from imod.mf6.mf6_wel_adapter import Mf6Wel | ||
from imod.msw.fixed_format import VariableMetaData | ||
from numpy.typing import NDArray | ||
|
||
|
@@ -38,9 +38,7 @@ class WellSvatMapping(MetaModMapping): | |
_with_subunit = ("wel_id", "svat", "layer") | ||
_to_fill = ("free",) | ||
|
||
def __init__( | ||
self, svat: xr.DataArray, well: mf6.WellDisStructured, index: NDArray[Int] | ||
): | ||
def __init__(self, svat: xr.DataArray, well: Mf6Wel, index: NDArray[Int]): | ||
super().__init__() | ||
self.index = index | ||
self.well = well | ||
|
@@ -55,10 +53,14 @@ def _create_well_id( | |
""" | ||
Get modflow indices, svats, and layer number for the wells | ||
""" | ||
well_cellid = self.well["cellid"] | ||
if len(well_cellid.coords["dim_cellid"]) != 3: | ||
raise TypeError("Coupling to unstructured grids is not supported.") | ||
|
||
# Convert to Python's 0-based index | ||
well_row = self.well["row"] - 1 | ||
well_column = self.well["column"] - 1 | ||
well_layer = self.well["layer"] | ||
well_layer = well_cellid.sel(dim_cellid="layer").data | ||
well_row = well_cellid.sel(dim_cellid="row").data - 1 | ||
well_column = well_cellid.sel(dim_cellid="column").data - 1 | ||
|
||
n_subunit = svat["subunit"].size | ||
|
||
|
@@ -71,7 +73,7 @@ def _create_well_id( | |
layer = np.tile(well_layer, (n_subunit, 1)) | ||
layer_1d = layer[well_active] | ||
|
||
well_id = self.well.dataset.coords["index"] + 1 | ||
well_id = well_cellid.coords["ncellid"] + 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ncellid is actually an zero based index array right? otherwise the +1 is now unnecessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is correct! |
||
well_id_1d = np.tile(well_id, (n_subunit, 1))[well_active] | ||
|
||
return (well_id_1d, well_svat_1d, layer_1d) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ def make_msw_model( | |
|
||
idomain = gwf["GWF_1"]["dis"]["idomain"] | ||
if "layer" in idomain.dims: | ||
idomain_layer1 = idomain.sel(layer=1) | ||
idomain_layer1 = idomain.sel(layer=1, drop=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran into an issue with some tests, where iMOD Python was complaining about faulty coordinates. It turned out as the layer coord was passed on to |
||
if nsubunits is None: | ||
nsubunits = xr.ones_like(idomain) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you sort the dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I defer from that now, as this is a temporary measure. After iMOD Python has been released with the API update, I will revert these changes to the pixi.toml. Instead, I will then pin iMOD Python to be above or higher a specific version number.