Closed ccallahan45 closed 10 months ago
I'm running into a similar issue with a different dataset (temperature and precipitation data) when trying to aggregate over US counties with a shapefile. The same files used to work fine on a previous version of xagg.
Same issue here
Hey all - sorry for the delay. Could one of you post example files that cause this issue? I'm having trouble reproducing the bug locally. (and let me know what version of xagg
you're using)
Here are a couple of files and a minimum working example that (at least for me) produced the bug. I'm using xagg version 0.3.1 installed from conda-forge. xagg_mwe.zip
I think the problem may be lines 230-237 of xagg/aux.py:
bnds_tmp = xr.DataArray(data=np.zeros((ds.dims[var],2))*np.nan,
dims=[var,'bnds'],
coords=[ds[var],np.arange(0,2)])
# Assign all non-edge bounds as just half of the distance from the center
# of each pixel to the center of the next pixel
bnds_tmp[1:,:] = xr.concat([ds[var]-0.5*ds[var].diff(var),
ds[var]+0.5*ds[var].diff(var)],dim='bnd').transpose(var,'bnd')
Note the 'bnds' dimension to create bnds_tmp
, then referred to as 'bnd' when it's assigned.
Yeah that looks plausible, thanks @simonmoulds @ccallahan45 . The really weird thing is I still can't replicate the problem locally, even with @ccallahan45 's replication data.
Running xa.aux.get_bnds()
with and without the change to bnds
in 230-237 doesn't change anything for me (the following code block runs fine, for example). This is weird, because the second bnds_tmp[1:,:] =
with bnd
coordinates instead of bnds
below should be failing on my machine, but something in xarray is letting that go through.
bnds_tmp[1:,:] = xr.concat([ds[var]-0.5*ds[var].diff(var),
ds[var]+0.5*ds[var].diff(var)],dim='bnds').transpose(var,'bnds')
a = bnds_tmp.copy()
bnds_tmp[1:,:] = xr.concat([ds[var]-0.5*ds[var].diff(var),
ds[var]+0.5*ds[var].diff(var)],dim='bnd').transpose(var,'bnd')
b = bnds_tmp.copy()
xr.testing.assert_allclose(a,b)
In any case, let me fix those lines, and hopefully that'll fix this issue.
Could someone for whom this error occurs locally test the new release #52 locally and make sure it works? Thanks!
Thanks @ks905383 - this is now working for me.
Hello, I was running into the same issue mentioned in this thread, and didn't realize that I didn't have the latest version of xagg installed. I used the installation instructions on the github page: conda install -c conda-forge xagg==0.3.1
But I see the version of xagg with the fix is version 0.3.1.1
I recommend to please update the github page installation instructions
Fixed, thanks for pointing that out.
Hello!
I attempted to run
xa.pixel_overlaps
using tropical cyclone wind data and a shapefile (GeoDataFrame) of US state boundaries. I received the following error: "ValueError: new dimensions ('lat', 'bnds') must be a superset of existing dimensions ('lat', 'bnd')".Based on the traceback, this appears to be occurring when the latitude and longitude bounds are created. The creation of the "bnds_tmp" variable appears to concatenate a variable with the dimension "bnds" to a variable with the dimension "bnd."
Full error message is included here:
thanks!