-
Notifications
You must be signed in to change notification settings - Fork 3
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
Improve output #297
Merged
Merged
Improve output #297
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
33b51e5
Add add_nans-argument to nlmod.gwf.output.get_heads_da
rubencalje 2c06e5c
Add parameters for hdry and hnoflo
rubencalje 0613819
Add test for a transport model and geotop
rubencalje 0cb0ee4
Add test for nlmod.plot.map_array
rubencalje f324a2e
Add modpath test (and add support for structured grids)
rubencalje b130a1f
Test if docs complete without geotop notebook
rubencalje d5b545e
Fix notebooks
rubencalje 6f2e28b
Revert "Test if docs complete without geotop notebook"
rubencalje 3e443c6
Only refine Lek at the boundary
rubencalje 92796b6
Increase speed of notebooks
rubencalje d9a45e1
Update path of model of notebook 17 (so it is in gitignore)
rubencalje 9a01d6d
Change hhnk url, which failed in test
rubencalje 5e92c20
Handle comments from @dbrakenhoff
rubencalje File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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 |
---|---|---|
|
@@ -77,7 +77,7 @@ def _get_time_index(fobj, ds=None, gwf_or_gwt=None): | |
return tindex | ||
|
||
|
||
def _create_da(arr, modelgrid, times): | ||
def _create_da(arr, modelgrid, times, add_nans=True, hdry=-1e30, hnoflo=1e30): | ||
"""Create data array based on array, modelgrid, and time array. | ||
|
||
Parameters | ||
|
@@ -88,6 +88,12 @@ def _create_da(arr, modelgrid, times): | |
flopy modelgrid object | ||
times : list or array | ||
list or array containing times as floats (usually in days) | ||
add_nans : bool, optional | ||
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. Nothing major, but maybe |
||
If True, sets dry/no-flow cells to nan. The default is True. | ||
hdry : float, optional | ||
The value of dry cells. The default is -1e30. | ||
hnoflo : float, optional | ||
The value of no-flow cells. The default is 1e30. | ||
|
||
Returns | ||
------- | ||
|
@@ -99,10 +105,9 @@ def _create_da(arr, modelgrid, times): | |
dims, coords = get_dims_coords_from_modelgrid(modelgrid) | ||
da = xr.DataArray(data=arr, dims=("time",) + dims, coords=coords) | ||
|
||
# set dry/no-flow to nan | ||
hdry = -1e30 | ||
hnoflo = 1e30 | ||
da = da.where((da != hdry) & (da != hnoflo)) | ||
if add_nans: | ||
# set dry/no-flow to nan | ||
da = da.where((da != hdry) & (da != hnoflo)) | ||
|
||
# set local time coordinates | ||
da.coords["time"] = ds_time_idx(times) | ||
|
@@ -168,7 +173,7 @@ def _get_heads_da( | |
stacked_arr = stacked_arr[:, :, 0, :] | ||
|
||
# create data array | ||
da = _create_da(stacked_arr, modelgrid, hobj.get_times()) | ||
da = _create_da(stacked_arr, modelgrid, hobj.get_times(), **kwargs) | ||
|
||
return da | ||
|
||
|
@@ -263,10 +268,12 @@ def _get_flopy_data_object(var, ds=None, gwml=None, fname=None, grbfile=None): | |
extension = "_gwt.ucn" | ||
else: | ||
raise (ValueError(f"Unknown variable {var}")) | ||
msg = f"Load the {var}s using either ds, {ml_name} or fname" | ||
assert ((ds is not None) + (gwml is not None) + (fname is not None)) == 1, msg | ||
|
||
if fname is None: | ||
if ds is None: | ||
if gwml is None: | ||
msg = f"Load the {var}s using either ds, {ml_name} or fname" | ||
raise (ValueError(msg)) | ||
# return gwf.output.head(), gwf.output.budget() or gwt.output.concentration() | ||
return getattr(gwml.output, var)() | ||
fname = os.path.join(ds.model_ws, ds.model_name + extension) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This will work on vertex grids as well, do we want to check for that?
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.
Added check, also in xy_to_icell2d. But I think we should improve these methods, as they will give a wrong result in variable gridsizes, where the closest centre of the cell in not equal to the cell the point is in.