Closed tomvothecoder closed 3 months ago
FYI @jasonb5 and @lee1043.
I think it was a good idea that we replaced .cf.axes
with xc.get_dim_keys()
in #533. I'll need to test if that fixes this issue on the latest main
build.
This looks like it is fixed in PR #533
What happened?
The Regrid2 API breaks if there are multiple mappings to the "Z" axis, specifically for coordinate variables such as
height
which are not considered dimensions.https://github.com/xCDAT/xcdat/blob/104a5d5090ea080c49f07ee149f0ae2b49396a4b/xcdat/regridder/regrid2.py#L94
https://github.com/xCDAT/xcdat/blob/104a5d5090ea080c49f07ee149f0ae2b49396a4b/xcdat/regridder/regrid2.py#L128-L139
In the code above, we use
ds.cf.axes
mapping table and get the first matching list element for each axis ({y[0]: x for x, y in da.cf.axes.items()}
) . Let's say mapping table for Z looks like{"z": ["height", "lev"]}
. Our logic will use element 0height
instead oflev
, resulting inRuntimeError: Could not find axis 'lev', ensure 'lev' exists and the attributes are correct.
What did you expect to happen? Are there are possible answers you came across?
Current workaround: The user needs to drop
height
coordinate variable or any other non-dimensional Z coordinate beforehand.Solution: This should no longer be an issue on the latest
main
commit in PR #533 because we now usexc.get_dim_keys()
which maps axes by index (aka dimensions). -- NEED TO TESTMinimal Complete Verifiable Example (MVCE)
Example
Relevant log output
Anything else we need to know?
No response
Environment
v0.6.1 and all other versions that have Regrid2 with this logic