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

allow overriding the grid using a dict or a GridInfo object #56

Open
keewis opened this issue Jun 11, 2024 · 0 comments · May be fixed by #63
Open

allow overriding the grid using a dict or a GridInfo object #56

keewis opened this issue Jun 11, 2024 · 0 comments · May be fixed by #63

Comments

@keewis
Copy link
Collaborator

keewis commented Jun 11, 2024

From #39 (comment) (@benbovy):

If we publicly expose the DGGSInfo classes, we should probably also support passing grid parameters either as separate kwargs or as an instance of a DGGSInfo subclass passed via a grid_info kwarg.

In other words, we want to be able to override the grid parameters when decoding.

This reminds me of the pattern we're using in pint-xarray: obj.pint.quantify() returns a decoded object, and obj.pint.dequantify() serializes it again. Following that, we could do:

ds.dggs.decode()  # read attributes from the default coordinate and decode
ds.dggs.decode(name="zone_ids")  # read attributes from a different coordinate

# override attributes
# option 1a: provide parameters as a dict and look at the default coordinate for cell ids
ds.dggs.decode({"grid_name": "healpix", "resolution": 5, "indexing_scheme": "nested"})
# option 1b: provide parameters as a dict and look at a different coordinate for cell ids
ds.dggs.decode({"grid_name": "healpix", ...}, name="zone_ids")
# option 2a: provide grid info (default coordinate)
ds.dggs.decode(grid_info)
# option 2b: provide grid info (custom coordinate)
ds.dggs.decode(grid_info, name="zone_ids")

(I'm not particularly attached to calling the kwarg name, this could also be ids, coord, coordinate, or anything else we deem better)

If we do override the grid, we might want to replace the attributes of the cell id coordinate with the normalized parameters.

@keewis keewis linked a pull request Sep 26, 2024 that will close this issue
1 task
@keewis keewis mentioned this issue Oct 16, 2024
4 tasks
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

Successfully merging a pull request may close this issue.

1 participant