-
Notifications
You must be signed in to change notification settings - Fork 224
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
xarray DataArray attributes breaking grdimage #1578
Comments
Hi @reint-fischer, thanks for trying out PyGMT! So the As to why it's not working, could you please provide the output of |
hi @weiji14 , sorry for the confusion, I updated my original post. The crucial part that I forgot is the multiplying by 1: Relating to the datacube message I have tried alternative ways of selecting the data, but I always have a 2D slice as input and it only works when the attributes are not there. I should also note again that the multiplication by 1 is a good workaround for me, so the bug is not very urgent, it just took me a while to figure it out and I think it would be nice to prevent people from running into this in the future. Thanks for replying so quickly |
Ah I see what's going on now. So this is the same issue as mentioned in #524 (comment). Long story short, the error happens because Your multiplying by 1 workaround (which is very smart by the way!) works because it resets Lines 30 to 39 in 5cb1035
We'll need to update it to fallback nicely when msl = ds['msl'].isel(time=i)
msl.encoding.pop("source") # removes link to NetCDF file
fig.grdimage(grid=msl) To help us out a little, do you have a link to a publicly available dataset like the ERA5 NetCDF file you used? Would make it easier for us to test things out. Edit: I've opened a bugfix at #1581, hopefully we'll get this fixed by the next PyGMT v0.5.0 release coming end of Oct. |
@reint-fischer, the bugfix has been merged at #1581 so |
Description of the problem
When trying to plot a timeslice of a field from an open xarray DataSet with the coordinates time, latitude, and longitude, I get a warning indicating the presence of a datacube, and a ValueError in accessors.py expecting 2 values but getting none. I found that this problem disappears when I perform an operation on the DataArray, e.g. multiplying with
1
. The only thing that seems to change with this operation is that the attributes in xarray are dropped.Full code that generated the error
Using the original DataArray:
Breaks:
Using the DataArray multiplied by 1:
Works:
Full error message
System information
Please paste the output of
python -c "import pygmt; pygmt.show_versions()"
:The text was updated successfully, but these errors were encountered: