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

Change grid resolution #18

Open
benbovy opened this issue Nov 10, 2023 · 0 comments
Open

Change grid resolution #18

benbovy opened this issue Nov 10, 2023 · 0 comments

Comments

@benbovy
Copy link
Member

benbovy commented Nov 10, 2023

It would be useful to have utility methods to change the grid resolution, very much like this and this.

Proposed behavior

This would be pretty similar to Xarray .reindex(), but here DGGS-aware.

When downgrading the resolution, only the cell coordinate would change with child cell ids replaced by their parent cell id at the given resolution. The resulting coordinate has the same size but may have duplicate labels. Users could then perform aggregation with the method of their choice just by using Xarray's .groupby().

When upgrading the resolution, the new cell coordinate has new labels (child cell ids) and the cell dimension may have an increased size, in which case the values of the data variables must be repeated according to the new cell ids along the cell dimension.

These .change_resolution() utility functions might be actually just what we need in order to align, merge or do other operations with multiple Datasets / DataArrays on the same DGGS but at different resolutions. Those are pretty simple and composable functions.

For simplicity, there would be no regridding or resampling involved here. There are two caveats, though:

  • extenstive vs. intensive quantities: The behavior detailed above is correct for intensive quantities (i.e., independent of the cell area) but not for extensive quantities. For the latter, one generic solution could be to optionally output a "weights" coordinate (same dimension than cells) computed from the cell areas and by counting duplicate cell ids. This weights coordinate could then be used to update the values of certain data variables (simple arithmetic) after upgrading the resolution. Unfortunately, in the case of resolution downgrading weighted groupby is not yet supported in Xarray: compose weighted with groupby, coarsen, resample, rolling etc. pydata/xarray#3937.
  • In some grid systems (like H3), the boundaries of the cells do not match exactly across different resolutions. We might need more advanced regridding in this case, although the solutions above may already provide good enough, first-order approximation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant