FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Issue #969 imod5 import recharge by luitjansl · Pull Request #1031 · Deltares/imod-python · GitHub

Issue #969 imod5 import recharge - #1031

Merged
luitjansl merged 29 commits into
imod5_converter_feature_branchfrom
issue_#969_imod5_import_recharge
May 21, 2024
Merged

Issue #969 imod5 import recharge#1031
luitjansl merged 29 commits into
imod5_converter_feature_branchfrom
issue_#969_imod5_import_recharge

Conversation

Copy link
Copy Markdown
Contributor

Fixes #969

Description

implements importing recharge packages from a project file. The recharge can be imported using a planar grid,
in which case it assigns the recharge to the uppermost active cell for each column.
The recharge can also be imported from a non-planar (so fully 3d) grid in which case it is just regridded to the target grid.

Checklist

  • Links to correct issue
  • Update changelog, if changes affect users
  • PR title starts with Issue #nr, e.g. Issue #737
  • Unit tests were added
  • If feature added: Added/extended example

JoerivanEngelen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I have some comments!

Comment thread imod/typing/grid.py
Comment thread imod/mf6/rch.py Outdated
Comment thread imod/tests/test_mf6/test_mf6_rch.py Outdated
luitjansl and others added 6 commits May 14, 2024 16:51
review comment

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
review comment

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
Comment thread imod/mf6/rch.py Outdated
# create an array indicating in which cells rch is active
is_rch_cell = allocate_rch_cells(
ALLOCATION_OPTION.at_first_active,
target_grid,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The active grid (idomain == 1) should be inserted here. This comes from the regridded discretization package. So you therefore require an extra argument to the from_imod5_data method, namely the regridded discretization package.

For an example of the API of the allocate_<pkg>_cells, see: https://deltares.github.io/imod-python/user-guide/09-topsystem.html#allocate-river-cells

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

done

Comment thread imod/tests/test_mf6/test_mf6_rch.py Outdated
@pytest.mark.usefixtures("imod5_dataset")
def test_planar_rch_from_imod5_constant(imod5_dataset, tmp_path):
data = deepcopy(imod5_dataset)
target_grid = data["khv"]["kh"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We do not test if the regridding works now... I don't think we need to that for each package, but having one where it is tested helps I think. Could you add a test where you regrid this case to a very coarse grid?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

in the latest version of this changeset we use the discretization package as the target grid, and it is much finer than the target_grid = data["khv"]["kh"] that was used earlier. So now it is regridding.
That aside, xugrid does as far as I know the same operation, whether the target grid matches the input grid exactly or not. So it goes through the same code path no matter what target grid we provide.

JoerivanEngelen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Some minor comments, approving in advance

Comment thread imod/mf6/rch.py Outdated
def from_imod5_data(
cls,
imod5_data: dict[str, dict[str, GridDataArray]],
discretization_package: StructuredDiscretization,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this can be shortened to:

Suggested change
discretization_package: StructuredDiscretization,
dis_pkg: StructuredDiscretization,

As DIS is an abbreviation used by MODFLOW6 and pkg is a very common abbreviation for "package".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

done

Comment thread imod/mf6/rch.py
Comment on lines +185 to +193
imod5_data: dict
Dictionary with iMOD5 data. This can be constructed from the
:func:`imod.formats.prj.open_projectfile_data` method.
target_grid: GridDataArray
The grid that should be used for the new package. Does not
need to be identical to one of the input grids.
regridder_types: dict, optional
Optional dictionary with regridder types for a specific variable.
Use this to override default regridding methods.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please update docstring with extra dis_pkg/discretization_package argument.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

done

Comment on lines +11 to +17
data = data[0]
# Fix data for ibound as it contains floating values like 0.34, 0.25 etc.
ibound = data["bnd"]["ibound"]
ibound = ibound.where(ibound <= 0, 1)
data["bnd"]["ibound"] = ibound
_load_imod5_data_in_memory(data)
return data

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This cleanup also occurs in the tests test_mf6_dis.py, please remove the ibound cleanup from these tests.

Also: You might get some increased performance by first loading the data into memory and then cleaning up ibound.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

done

luitjansl and others added 4 commits May 21, 2024 11:50
luitjansl merged commit 9b9a2e3 into imod5_converter_feature_branch May 21, 2024
luitjansl deleted the issue_#969_imod5_import_recharge branch May 21, 2024 12:45
This file contains hidden or 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL