-
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
Add via_cf_namespace
option
#19
Conversation
Was typing fast this morning and now realize that my comment above was perhaps a bit presumptuous that you'd want this as part of |
Thanks. How about we
Actually... we already use |
Cool, I like dropping the additional
Right so for time we can do def build_temporal_dimension(ds, name, extent, values, step):
- time = ds.coords[name]
+ time = ds.cf[name] if name in ds.cf.keys() else ds.coords[name]
👍 If time dimension name is None, we never make it to And actually, I think we need to the same thing for X and Y, because they both use the same builder, and if So would ```diff
def build_horizontal_dimension(ds, name, axis, extent, values, step, reference_system):
- da = ds[name]
+ da = ds.cf[name] if name in ds.cf.keys() else ds[name] be okay? |
What I'm trying w/
As such, the accessors I'm looking to use are TL;DR is I think the approach described in #19 (comment) is a good compromise which nudges users in the direction of CF but doesn't default to names which may not exist on otherwise CF-compliant datasets. |
I need to try out cf-xarray, but my ideal API is to rely on it for inferring the right variable name for each dimension coordinate. So right now the README has this example: $ xstac examples/terraclimate/item-template.json \
zarr-https examples/terraclimate/item.json \
--x-dimension=lon --y-dimension=lat --reference-system=4326 I hope that can become $ xstac examples/terraclimate/item-template.json \
zarr-https examples/terraclimate/item.json i.e. we've inferred In terms of implementation, I think that means
if time_dimension is None:
time_dimension = ds.cf["time"].name # TODO: handle the case of it not being there gracefully likewise for
In the case of a dataset like Daymet, the lat / lon variables are 2-D arrays. The latitude / longitude depends on where you're at in the projected x / y space. All the data variables have dimensions |
🤦 Oops I just reset this branch to be equal with |
cf_xarray
"is a lightweight accessor that allows you to interpret CF attributes present on xarray objects."In building automated STAC Item generation for Pangeo Forge, we'd prefer to access dataset attributes via
cf_xarray
's cf namespace, rather than need to know the actual attribute names. (See discussion here.)This PR adds that option. If you'd prefer not to have the added dependency by default, we could make it an optional dependency, and then wrap the module-level import in a try/except.