-
Notifications
You must be signed in to change notification settings - Fork 14
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
[Feature]: Use dimension coordinates from the input data variable in specific xCDAT APIs #314
Comments
TemporalAccessor
.TemporalAccessor
to the input data variable
TemporalAccessor
to the input data variableTemporalAccessor
@tomvothecoder - I'm wondering if this could/should be more general to all dimensions (e.g., also |
Good point @pochedls. Yes, this should be applied to the For accessor classes:
For
|
TemporalAccessor
The proposed solution in this issue actually won't fix the issue of trying to map the desired axis coord variable for a dim because DataArrays can also have multiple coord vars mapped to a dim like Datasets (Datasets shares coords from its DataArrays). Example: import cf_xarray as cf
import xarray as xr
import xcdat as xc
#%%
# Test2 - Remove attributes referring to non-existing bounds
# This file is CF compliant (https://pumatest.nerc.ac.uk/cgi-bin/cf-checker.pl)
"""
- https://github.com/xCDAT/xcdat/issues/285#issuecomment-1209768695
"""
filepath2 = "https://thredds-su.ipsl.fr/thredds/dodsC/ipsl_thredds/omamce/TestCases/XCDAT/thetao_CF.nc"
#%%
ds2 = xr.open_dataset(filepath2)
#%%
# 1. Attempt to get "T" axis coordinate variable in the Dataset
ds2.cf["T"]
# KeyError: "Receive multiple variables for key 'T': {'time_centered', 'time_counter'}. Expected only one. Please pass a list ['T'] instead to get all variables matching 'T'."
#%%
# 2. Check the Dataset's cf_xarray mapping
ds2.cf
"""
Coordinates:
- CF Axes: T: ['time_centered', 'time_counter']
X, Y, Z: n/a
- CF Coordinates: longitude: ['nav_lon']
latitude: ['nav_lat']
* vertical: ['olevel']
time: ['time_centered', 'time_counter']
- Cell Measures: area, volume: n/a
- Standard Names: latitude: ['nav_lat']
longitude: ['nav_lon']
time: ['time_centered', 'time_counter']
- Bounds: n/a
Data Variables:
- Cell Measures: area, volume: n/a
- Standard Names: sea_water_conservative_temperature: ['thetao']
- Bounds: T: ['time_centered_bounds']
time: ['time_centered_bounds']
time_centered: ['time_centered_bounds']
"""
#%%
# 3. Attempt to get "T" axis coordinate variable in the DataArray
ds2.thetao.cf["T"]
# KeyError: "Receive multiple variables for key 'T': {'time_centered', 'time_counter'}. Expected only one. Please pass a list ['T'] instead to get all variables matching 'T'."
#%%
# 4. Check the DataArray's cf_xarray mapping
ds2.thetao.cf
"""
Coordinates:
- CF Axes: T: ['time_centered', 'time_counter']
X, Y, Z: n/a
- CF Coordinates: longitude: ['nav_lon']
latitude: ['nav_lat']
* vertical: ['olevel']
time: ['time_centered', 'time_counter']
- Cell Measures: area, volume: n/a
- Standard Names: latitude: ['nav_lat']
longitude: ['nav_lon']
time: ['time_centered', 'time_counter']
- Bounds: n/a
""" We need to figure out a sensible way of choosing the correct coord var for a dim in a DataArray for This might involve using the dimension name as mentioned here, and making sure this coord var has bounds:
|
Is your feature request related to a problem?
Related #285 and #312, we might need to update how we get the dimension name for a time axis (
self._dim
) inTemporalAccessor()
.Instead of getting the time dimension name from the dataset (which can have multiple time axis):
xcdat/xcdat/temporal.py
Line 149 in 4c51879
We can get just the single time axis for the data variable that is being temporally averaged:
self._dim = get_axis_coord(self._data_var, "T").name
Originally posted by @tomvothecoder in #312 (comment)
Describe the solution you'd like
No response
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: