-
Notifications
You must be signed in to change notification settings - Fork 44
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
Using DataArray for xarray Accessor, attribute promotion #184
Comments
Can you provide a code snippet reproducing the error? Supporting both versions should not be a problem. |
I tried it with this one, which raises the above error:
The same actually also happens if a
Does this have a specific reason? I mean, in principle the variables could have different projections, the question is only if that makes sense... |
I'm still not sure to understand the issue and how it relates to xarray v0.16. The code you sent never worked, because your data array does not have any coordinate to parse. This works for example: import xarray as xr
import salem
print(xr.__version__)
xrda = xr.DataArray(dims=('x', 'y'),
coords={'x':[1, 2], 'y':[1, 2]},
attrs={'pyproj_srs': 'epsg:32632'})
xrda.salem output:
Can you be more specific?
I think I never thought of a situation where data arrays of a different dataset have different projections, and I don't think that I ever encountered such a dataset (it would be super confusing). That being said, the current implementation of crs attrs in salem is suboptimal, because it always needs one: i.e. if you do things manually, you need to add the crs as attribute to all variables and all datasets you want to parse / plot. This was one of the reason to wrap Lines 943 to 946 in 697762b
|
See also: #62 (but I don't think I'll ever come to implementing this tbh...) |
Ohhhhh.....sure, ouch! Sorry for this utterly bad example code.
The problem is indeed as you said that |
Thanks! Yes OK so at core it is the same problem as #62 - closing this if you agree. |
When using an xr.DataArray to instantiate the xarray Accessor, there should be an explicit
promote_attrs=True
passed toto_dataset
for the latest releases of xarray:salem/salem/sio.py
Line 412 in 697762b
Otherwise, instatiating the accessor fails, because the projection info in the attributes is not passed and defining the grid fails:
This seems to be untested, since all tests for xarray-dev pass (last run 2 months ago, but code was added 7 months ago to xarray).
I'm not sure if you maybe want to specify an older xarray version as default for salem, or make the change and require xarray=0.16.
The text was updated successfully, but these errors were encountered: