-
Notifications
You must be signed in to change notification settings - Fork 3
Issue #443 clipping msw model #1478
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
# grid is independent of model grid and we do not want to perform | ||
# transformations on meteo data in this case. | ||
if has_meteogrid_copy and isinstance(pkg, MeteoMapping): | ||
clipped[key] = deepcopy(pkg) |
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.
Is this necessary? You have a clip_box method in the MeteoMapping
class. I would expect either that method to be called here or that that method isn't necessary
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.
The special-case is only necessary when a MeteoGridCopy
is assigned to the model. This object just copies a pointer file mete_grid.inp
which contains paths to a lot of meteo ASCII files, which are commonly very large. In this case, we do not want to clip these large datasets, nor create mappings to clipped meteo grids (as we do not want to clip these). This is a very common usecase for iMOD5 models.
The MeteoMapping.clip_box
method should be called when a MeteoGrid
object is assigned to the model.
return indexer, repeat_stress | ||
|
||
|
||
def clip_time_slice( |
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 like that you refactored out duplicate code and reduced it to this single 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.
Thanks!
timestamps with data. | ||
""" | ||
# First, "pop" and filter. | ||
keys, values = repeat_stress.values.T |
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.
You could rename keys
to times
or period
imod/common/utilities/clip.py
Outdated
keep = (keys >= time_start) & (keys <= time_end) | ||
new_keys = keys[keep] | ||
new_values = values[keep] | ||
# Now detect which "value" entries have gone missing |
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.
The code belonging to this code doesn't look for missing entries but for unique entries right?
The comment confuses me
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've clarified this function with better naming and comments, as it was very confusing
imod/common/utilities/clip.py
Outdated
|
||
# Update the key-value pairs. Discard keys that have been "promoted". | ||
keep = np.isin(new_keys, insert_keys, assume_unique=True, invert=True) | ||
new_keys = new_keys[keep] |
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.
Isn't new_keys equal to insert_keys? and new_values to insert_values?
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've clarified this function with better naming and comments, as it was very confusing
|
Fixes #443 and #364
Description
imod.msw.MetaSwapModel
, this includes a special case forclip_box
method of PrecipitationMapping, and EvapotranspirationMapping: These should not be clipped if aMeteoGridCopy
instance is part of the model. Otherwise nonsensical mappings are generated.imod.msw.MetaSwapModel.clip_box
method to public APIclip_box
method in MeteoMapping, should clip meteo attribute instead of dataset attribute.imod.common.utilities.clip
.meteo
class variable an attribute. This makes more sense. I think I made it a class variable before to please mypy.imod.msw.MeteoGridCopy
Checklist
Issue #nr
, e.g.Issue #737