-
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]: convenience functions to access variable coords #200
Comments
It appears that somewhat of the functionality described above exists, but not as well expanded (and useful) as the example above. >>> ta.coords
Coordinates:
* time (time) datetime64[ns] 1850-01-16T12:00:00 ... 1949-12-16T12:00:00
* plev (plev) float64 1e+05 9.25e+04 8.5e+04 7e+04 ... 1e+03 500.0 100.0
* lat (lat) float64 -89.38 -88.12 -86.88 -85.62 ... 86.88 88.12 89.38
* lon (lon) float64 0.9375 2.812 4.688 6.562 ... 353.4 355.3 357.2 359.1 And this is also available >>> ta.dims
Frozen({'time': 1200, 'bnds': 2, 'plev': 19, 'lat': 144, 'lon': 192}) |
Hi @durack1, to access the coordinates (stored as xarray
If you want to limit your search to just the coordinates:
If you want to access the underlying numpy array of the coordinates, rather than the entire xarray DataArray:
|
@tomvothecoder thanks, my motivation was more to have a standard function that dealt with the various names that certain coordinates may have. |
I just wanted to note that xcdat uses
|
@pochedls this looks like it might get me half way or most of the way there, I presume it works for |
Thanks for chiming in @pochedls. I was also going to mention |
@tomvothecoder @pochedls out of curiosity have you been running timing benchmarks, or is it too early days? In my ~week long dabble in xcdat it seems far slower with IO than what I was getting with cdms2 - should I open another issue, and close this (presuming my |
We haven't benchmarked the Note, From the docstrings (https://xcdat.readthedocs.io/en/latest/generated/xcdat.dataset.open_dataset.html):
I would expect a performance hit when opening a dataset with non-CF compliant time coordinates (e.g., months/years) and The xcdat APIs also automatically generates bounds for supported axes (lat, lon, time) if they don't exist, since most xcdat features require bounds. This is another operation that xarray and cdms2 do not support. If we perform performance benchmarks, we should either:
Afterwards, we can independently benchmark each xcdat helper function such as
I'll open up an issue for performance benchmarking with the aforementioned details and you can close this issue based on your investigation. |
@tomvothecoder thanks for the #200 (comment). I note that |
I note that the file open error in #183 and the correct accessing of axes is related, so worth noting these open issues are related. I also note that I have been hitting many issues in both |
I believe #262 closes this. API: https://xcdat.readthedocs.io/en/latest/generated/xcdat.get_axis_coord.html#xcdat.get_axis_coord |
Is your feature request related to a problem?
This somewhat expands on #199 (which could be closed as a dupe - feel free to do this). Accessing information from loaded variables appears to be a little inconsistent, so for e.g.
So to get the names of the axes I need to call
_coord_names
, which returns the axes in an order that doesn't reflect the dimension ordering which is[time, plev, lat, lon]
(above) rather than{'lon', 'time', 'plev', 'lat'}
(returned by_coord_names
). If we had a,getTime
,.getLevel
,.getLatitude
, and.getLongitude
function (or alternatively another function that could return all dimensions, their names and their order).Such functionality doesn't appear to exist in
xarray
at least from what I have found, the closest is https://docs.xarray.dev/en/latest/generated/xarray.DataArray.get_axis_num.htmlDescribe the solution you'd like
Something like:
And we could implement a similar example for
ta.getTime
,ta.getLatitude
,ta.getLongitude
Describe alternatives you've considered
NA
Additional context
NA
The text was updated successfully, but these errors were encountered: