-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support generating individual pyramid levels #84
Conversation
CodSpeed Performance ReportMerging #84 will not alter performanceFalling back to comparing Summary
|
@@ -1,5 +1,6 @@ | |||
# flake8: noqa | |||
|
|||
from .core import pyramid_coarsen, pyramid_reproject | |||
from .coarsen import pyramid_coarsen | |||
from .reproject import pyramid_reproject |
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.
Splitting these up is a nice touch.
---------- | ||
ds : xarray.Dataset | ||
The dataset to coarsen. | ||
factors : list[int] |
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.
Not sure if it's worth it in this PR, but I wonder if it would be useful to have some checking on these input factors in the future.
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.
Agreed! since this is focused on the pyramid_reproject, I think it would work better as a separate PR
ndpyramid/reproject.py
Outdated
def level_reproject( | ||
ds: xr.Dataset, | ||
*, | ||
projection: typing.Literal['web-mercator', 'equidistant-cylindrical'] = 'web-mercator', |
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.
This type hinting is neat! I like that it saves a check on the projection being on of a set of values.
for k, da in ds.items(): | ||
if clear_attrs: | ||
da.attrs.clear() | ||
if len(da.shape) == 4: |
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.
Should this be ≥ 4? or should there be another case if we shave ds.shape == 5?
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 think it would break for 5+ dim datasets. Perhaps we should add a check and raise an informative error as a separate PR
Co-authored-by: Raphael Hagen <norlandrhagen@gmail.com>
This separates out the reprojection of individual levels into a separate function, as a pre-req for #74 and pangeo-forge/pangeo-forge-recipes#669.