-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Xarray with cfgrib backend errors with .where() when drop=True #4733
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
Comments
Paging @alexamici? |
@DanielAdriaansen thanks for reporting, this is a duplicate of ecmwf/cfgrib#157 so I'm going to close this one, and you can follow there. I'm a bit embarrassed as @aurghs identified this bug a while back, but I forgot about it! The fix should be easy, I'll try to make a release shortly. |
Looks like an effective way to fix the bug is in xarray itself, so I reopen the issue. |
Thanks so much for the reply and the swift fix! Much appreciated @alexamici and thanks for the hard work getting GRIB engine support into Xarray! |
(#4737) * Declare only BASIC indexing for cfgrib. Fixes #4733 and ecmwf/cfgrib#157 * Add what's news entry. * Fix RST syntax * Fix ref to PR
What happened:
When loading a HRRR GRIBv2 file in this manner:
ds = xr.open_dataset(gribfile_path,engine='cfgrib',backend_kwargs={'filter_by_keys':{'typeOfLevel':'hybrid'}})
I have trouble using the
.where()
method whendrop=True
. If I setdrop=False
, it works fine. I am attempting to subset via latitude and longitude like this:ds_sub = ds.where((ds.latitude>=40.0)&(ds.latitude<=50.0)&(ds.longitude>=252.0)&(ds.longitude<=280.0),drop=True)
However I receive the following errors:
What you expected to happen:
I expect the dataset to be reduced in the x and y (latitude/longitude) dimensions where
cond=False
from.where()
whendrop=True
.Minimal Complete Verifiable Example:
# Put your MCVE code here
Anything else we need to know?:
I was able to confirm cfgrib is where the issue lies by doing the following:
That correctly gives me:
Dimensions: (hybrid: 50, x: 792, y: 414)
Originally x=1799 and y=1059.
Environment:
Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 19:08:05)
[GCC 7.5.0]
python-bits: 64
OS: Linux
OS-release: 4.9.0-14-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.6
libnetcdf: 4.7.4
xarray: 0.16.1
pandas: 1.1.3
numpy: 1.19.1
scipy: 1.5.2
netCDF4: 1.5.5.1
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.2.1
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: 0.9.8.5
iris: None
bottleneck: None
dask: 2.30.0
distributed: 2.30.0
matplotlib: 3.3.2
cartopy: 0.17.0
seaborn: None
numbagg: None
pint: 0.16.1
setuptools: 49.6.0.post20200917
pip: 20.2.3
conda: None
pytest: None
IPython: None
sphinx: None
The text was updated successfully, but these errors were encountered: