-
Notifications
You must be signed in to change notification settings - Fork 6
Issue #960 regrid method refactor #1054
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
Conversation
get_regridder_method to parent class
luitjansl
left a comment
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.
some comments/questions
| Object containing regridder methods for the :class:`imod.mf6.ConstantHead` | ||
| package. This can be provided to the ``regrid_like`` method to regrid with | ||
| custom settings. | ||
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.
all these docstrings for each type clutter the source file more than they help. Could you make 1 docstring documenting what the xxxRegridMethod classes,are? If you want to give more information on 1 class , add a short docsring to the xxxRegridMethod class if needed?
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.
Docstrings are required as these functions are public API.
I attempted it, but it didn't yield any satisfactory results, as there are just a bit too many things varying in the docstring:
- class name the regrid method is intended for
- regrid method class name
- an n amount of parameter variables
- in the example, a short name for a variable the package is assigned to, e.g.
chd - in the example, a variable name which gets a custom setting
They are just a bit too much spread out to create a satisfactory template, without introducing significantly more complexity. For example, jinja templates which use dictionaries describing the variable names per RegridMethod class.
| ), # TODO: should be set to barycentric once supported | ||
| "concentration": (RegridderType.OVERLAP, "mean"), | ||
| } | ||
| _regrid_method = ConstantHeadRegridMethod() |
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.
why don't you make it an object variable instead of a class variable? Then tweaking these methods would be very readable:
my_special_ConstantHead_package._regrid_method.concentration = Barycentric
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.
As I wrote in the description:
I kept _regrid_method as a class variable, as it gave problems as an attribute with imod.mf6.Package.from_file classmethod, where attributes are not forwarded.
Fixes #960 and #1000
Description
Adds regrid schemes which replaces the dictionaries under
_regrid_methodwith pydantic dataclasses.Pydantic comes with input validation base on type annotation, so requires no extra code.
See documentation here
This requires pydantic as extra dependency, so is added as dependency.
I kept
_regrid_methodas a class variable, as it gave problems as an attribute withimod.mf6.Package.from_fileclassmethod, where attributes are not forwarded.I created a new namespace:
imod.mf6.regridwhere we can store all Regridding related stuff. Probably good to move other public API there as well later on, namely theimod.mf6.utilities.regridder_types.RegridderTypeandimod.mf6.utilities.regrid.RegridderWeightsCache. As these are more than just utilities: They are essential objects for users to do their regridding at the moment.Checklist
Issue #nr, e.g.Issue #737