-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b311cb4
commit 71f37c8
Showing
7 changed files
with
109 additions
and
68 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from . import recharge, surface_water | ||
from . import recharge, surface_water, constant_head | ||
from .mfpackages import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Fri Dec 3 11:58:49 2021 | ||
@author: oebbe | ||
""" | ||
|
||
import xarray as xr | ||
import numpy as np | ||
|
||
from .. import util, cache | ||
|
||
@cache.cache_netcdf | ||
def get_chd_at_model_edge(model_ds, idomain): | ||
"""get data array which is 1 at every active cell (defined by idomain) at | ||
the boundaries of the model (xmin, xmax, ymin, ymax). Other cells are 0. | ||
Parameters | ||
---------- | ||
model_ds : xarray.Dataset | ||
dataset with model data. | ||
idomain : xarray.DataArray | ||
idomain used to get active cells and shape of DataArray | ||
Returns | ||
------- | ||
model_ds_out : xarray.Dataset | ||
dataset with chd array | ||
""" | ||
|
||
# add constant head cells at model boundaries | ||
|
||
# get mask with grid edges | ||
xmin = model_ds['x'] == model_ds['x'].min() | ||
xmax = model_ds['x'] == model_ds['x'].max() | ||
ymin = model_ds['y'] == model_ds['y'].min() | ||
ymax = model_ds['y'] == model_ds['y'].max() | ||
|
||
model_ds_out = util.get_model_ds_empty(model_ds) | ||
|
||
if model_ds.gridtype == 'structured': | ||
mask2d = (ymin | ymax | xmin | xmax) | ||
|
||
# assign 1 to cells that are on the edge and have an active idomain | ||
model_ds_out['chd'] = xr.zeros_like(idomain) | ||
for lay in model_ds.layer: | ||
model_ds_out['chd'].loc[lay] = np.where( | ||
mask2d & (idomain.loc[lay] == 1), 1, 0) | ||
|
||
elif model_ds.gridtype == 'unstructured': | ||
mask = np.where([xmin | xmax | ymin | ymax])[1] | ||
|
||
# assign 1 to cells that are on the edge, have an active idomain | ||
model_ds_out['chd'] = xr.zeros_like(idomain) | ||
model_ds_out['chd'].loc[:, mask] = 1 | ||
model_ds_out['chd'] = xr.where(idomain == 1, | ||
model_ds_out['chd'], 0) | ||
|
||
|
||
return model_ds_out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters