-
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
Issue #1041 import simulation #1059
Issue #1041 import simulation #1059
Conversation
review comment Co-authored-by: Joeri van Engelen <[email protected]>
…version # Conflicts: # imod/mf6/rch.py # imod/tests/fixtures/backward_compatibility_fixture.py # imod/tests/test_mf6/test_mf6_rch.py # imod/tests/test_typing/test_typing_grid.py # imod/typing/grid.py
review comment Co-authored-by: Joeri van Engelen <[email protected]>
review comment Co-authored-by: Joeri van Engelen <[email protected]>
…_simulation # Conflicts: # imod/tests/test_typing/test_typing_grid.py # imod/typing/grid.py
review comment Co-authored-by: Joeri van Engelen <[email protected]>
review comment Co-authored-by: Joeri van Engelen <[email protected]>
review comment Co-authored-by: Joeri van Engelen <[email protected]>
…es/imod-python into issue_#967_drn_conversion
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.
Looks good, approving in advance, since I'm not going to be so active the coming 10 days. My main points are the quite long variable names for the simulation options and the missing docstrings, could you fix/implement those?
default_simulation_allocation_options: SimulationAllocationOptions, | ||
default_simulation_distributing_options: SimulationDistributingOptions, | ||
regridder_types: Optional[dict[str, tuple[RegridderType, str]]] = None, | ||
) -> "GroundwaterFlowModel": |
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.
Please add a docstring to the method, explaining what it does
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.
done, added the docstring
imod/mf6/model_gwf.py
Outdated
default_simulation_allocation_options: SimulationAllocationOptions, | ||
default_simulation_distributing_options: SimulationDistributingOptions, |
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.
These variable names are quite long. I think going with this is fine:
default_simulation_allocation_options: SimulationAllocationOptions, | |
default_simulation_distributing_options: SimulationDistributingOptions, | |
allocation_options: SimulationAllocationOptions, | |
distributing_options: SimulationDistributingOptions, |
The type annotation hints that we are expecting a certain object and you can describe this also in the docstring. Furthermore, the plural options
subtly hints that this is something different then option
used for specific packages.
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.
done
# import npf | ||
npf_pkg = NodePropertyFlow.from_imod5_data(imod5_data, grid, regridder_types) | ||
|
||
# import sto | ||
sto_pkg = StorageCoefficient.from_imod5_data(imod5_data, grid, regridder_types) | ||
|
||
# import initial conditions | ||
ic_pkg = InitialConditions.from_imod5_data(imod5_data, grid, regridder_types) | ||
|
||
# import recharge | ||
rch_pkg = Recharge.from_imod5_data(imod5_data, dis_pkg, regridder_types) |
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.
Nice, this looks very clean and readable!
imod/mf6/model_gwf.py
Outdated
oc = OutputControl(save_head="last", save_budget="last") | ||
result["oc"] = oc |
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.
To be more consistent with iMOD5, we can make the user responsible for this.
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.
done
imod/mf6/simulation.py
Outdated
default_simulation_allocation_options: SimulationAllocationOptions, | ||
default_simulation_distributing_options: SimulationDistributingOptions, |
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.
idem, long argument name.
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.
done
default_simulation_allocation_options: SimulationAllocationOptions, | ||
default_simulation_distributing_options: SimulationDistributingOptions, | ||
regridder_types: Optional[dict[str, tuple[RegridderType, str]]] = None, | ||
) -> "Modflow6Simulation": |
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.
Please also add a docstring for this method.
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.
done
@dataclass() | ||
class SimulationAllocationOptions: |
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.
Looks good!
@@ -0,0 +1,40 @@ | |||
from dataclasses import dataclass |
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.
FYI: changing the dataclass to pydantic dataclass, would be as easy as:
from dataclasses import dataclass | |
from pydantic.dataclasses import dataclass |
You can make this change when PR #1054 is merged, probably not for this PR.
|
||
|
||
@pytest.mark.usefixtures("imod5_dataset") | ||
def test_import_from_imod5(imod5_dataset, tmp_path): |
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.
Are we also going to add a test to see if it runs? Or do we assume our validation is good enough to capture all input mistakes, and save some precious CI time? I'm open to both options.
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 tried if it runs (it does), but I didn't add it to the test because that adds 20 seconds or so to the test run time.
Fixes #1041
Description
Adds a function that imports a simulation from an imod5 project file. It creates a simulation, containing 1 GroundwaterFlowModel, containing the packages for which we support importing currently. This includes the mandatory flow packages like NPF and STO, and some boundary conditions (like DRN and RCH) but not yet CHD or WEL.
Checklist
Issue #nr
, e.g.Issue #737