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

Add classmethod to construct Package objects from iMOD5 data #961

Closed
JoerivanEngelen opened this issue Apr 9, 2024 · 0 comments
Closed
Assignees
Labels
backwards_compatibility Backwards compatibility with iMOD5

Comments

@JoerivanEngelen
Copy link
Contributor

JoerivanEngelen commented Apr 9, 2024

The iMOD5 data model has the following peculiarities we need to deal with:

  • Data for a package can be defined on different grids (extent, grid sizes). Most common is grids with different extents.
  • Boundary conditions can be defined as planar grids, which need to be distributed across layers.

Good to know:

  • Caching is probably less important, as all data is structured
  • iMOD5 variables are defined on layers consistently amongst each other within one system

For iMOD Python this requires the following work:

Add classmethod to Package which can initiate a new package.
In pseudocode:

class Package:
...
    @classmethod
    def from_imod5_package(cls, dis_pkg, **data):
        # target grid is idomain
        target = dis_pkg.dataset["idomain"]
        # Regrid to one consistent dataset
        dataset = cls._regrid_like(target, **data)
        return cls(**dataset_allocated)
...

For the Structured Discretization, the target grid is the smallest grid in the package.
This is picked up in #964
Therefore the method needs to be overloaded:

class StructuredDiscretization:
...
    @classmethod
    def from_imod5_package(cls, **data):
        # Find most fine-grained gridsize in data to regrid to
        # Clip to smallest extent
        target = find_smallest_grid(data)
        # Regrid to one consistent dataset
        dataset = cls._regrid_like(target, **data)

        # Add logic to prepare the dataset in the following way here:
        # IBOUND < 0 -> IDOMAIN = 0
        # TOP 3D -> TOP 2D
        # Thickness <0 -> IDOMAIN = -1

        return cls(**dataset)

further refinement 06-05

This issue focusses on packages that are in the Flow model, and that are not boundary conditions, and that contain grid -data (unlike the buoyancy package for example). This means sto, npf and ic. But npf was covered in a previous issue, so for this one it's sto and ic. for this issue.

@JoerivanEngelen JoerivanEngelen added the backwards_compatibility Backwards compatibility with iMOD5 label Apr 9, 2024
@JoerivanEngelen JoerivanEngelen self-assigned this Apr 22, 2024
@JoerivanEngelen JoerivanEngelen removed their assignment May 1, 2024
@luitjansl luitjansl self-assigned this May 1, 2024
luitjansl added a commit that referenced this issue May 8, 2024
Fixes #961

# Description
implements importing from a imod5 project file for storage and initial
conditions.

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

---------

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards_compatibility Backwards compatibility with iMOD5
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants