home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1391699976

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1391699976 I_kwDOAMm_X85S86gI 7108 .sel return errors when using floats for no apparent reason 90059220 closed 0     10 2022-09-30T01:45:44Z 2022-10-05T02:21:16Z 2022-10-05T02:21:15Z NONE      

What happened?

Using floats .sel() on different datasets from the same provider trigger an error. Despite the fact that the concerned dims are all in float32 type (see log).

Attempts with default float, numpy.float32() and numpy.float64() gave the same output.

What did you expect to happen?

Normal behavior of .sel().

Minimal Complete Verifiable Example

```Python import xarray as xr nc_ok = xr.open_dataset('H08_20220929_0000_1H_ROC010_FLDK.02401_02401.nc').load() sub = nc_ok.sel(longitude = slice(161.001, 162.001))

nc_bug = xr.open_dataset('20220925000000-JAXA-L3C_GHRSST-SSTskin-H08_AHI-v2.0_daily-v02.0-fv01.0.nc').load() sub = nc_bug.sel(lon = slice(161.001, 162.001)) ```

MVCE confirmation

  • [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • [ ] Complete example — the example is self-contained, including all data and the text of any traceback.
  • [ ] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • [ ] New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

```Python nc_ok = xr.open_dataset('H08_20220929_0000_1H_ROC010_FLDK.02401_02401.nc').load()

nc_ok.longitude Out[12]: <xarray.DataArray 'longitude' (longitude: 2401)> array([ 80. , 80.05 , 80.1 , ..., 199.9 , 199.95001, 200. ], dtype=float32) Coordinates: * longitude (longitude) float32 80.0 80.05 80.1 80.15 ... 199.9 200.0 200.0 Attributes: long_name: longitude units: degrees_east

nc_bug = xr.open_dataset('20220925000000-JAXA-L3C_GHRSST-SSTskin-H08_AHI-v2.0_daily-v02.0-fv01.0.nc').load()

nc_bug.lon Out[14]: <xarray.DataArray 'lon' (lon: 6001)> array([ 80. , 80.02 , 80.04 , ..., -160.04001, -160.02 , -160. ], dtype=float32) Coordinates: * lon (lon) float32 80.0 80.02 80.04 80.06 ... -160.0 -160.0 -160.0 Attributes: long_name: longitude standard_name: longitude axis: X units: degrees_east valid_min: -180.0 valid_max: 180.0 grid_mapping: Equirectangular comment: geographical coordinates, WGS84 projection

sub = nc_ok.sel(longitude = slice(161.001, 162.001))

sub = nc_bug.sel(lon = slice(161.001, 162.001)) Traceback (most recent call last):

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\pandas\core\indexes\base.py:3800 in get_loc return self._engine.get_loc(casted_key)

File pandas_libs\index.pyx:138 in pandas._libs.index.IndexEngine.get_loc

File pandas_libs\index.pyx:165 in pandas._libs.index.IndexEngine.get_loc

File pandas_libs\hashtable_class_helper.pxi:1577 in pandas._libs.hashtable.Float64HashTable.get_item

File pandas_libs\hashtable_class_helper.pxi:1587 in pandas._libs.hashtable.Float64HashTable.get_item

KeyError: 161.001

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

Cell In [16], line 1 sub = nc_bug.sel(lon = slice(161.001, 162.001))

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\xarray\core\dataset.py:2533 in sel query_results = map_index_queries(

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\xarray\core\indexing.py:183 in map_index_queries results.append(index.sel(labels, **options)) # type: ignore[call-arg]

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\xarray\core\indexes.py:377 in sel indexer = _query_slice(self.index, label, coord_name, method, tolerance)

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\xarray\core\indexes.py:150 in _query_slice indexer = index.slice_indexer(

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\pandas\core\indexes\base.py:6597 in slice_indexer start_slice, end_slice = self.slice_locs(start, end, step=step)

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\pandas\core\indexes\base.py:6805 in slice_locs start_slice = self.get_slice_bound(start, "left")

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\pandas\core\indexes\base.py:6724 in get_slice_bound raise err

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\pandas\core\indexes\base.py:6718 in get_slice_bound slc = self.get_loc(label)

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\pandas\core\indexes\base.py:3802 in get_loc raise KeyError(key) from err

KeyError: 161.001

sub = nc_bug.sel(lon = slice(np.float64(161.001), 162.001)) Traceback (most recent call last):

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\pandas\core\indexes\base.py:3800 in get_loc return self._engine.get_loc(casted_key)

File pandas_libs\index.pyx:138 in pandas._libs.index.IndexEngine.get_loc

File pandas_libs\index.pyx:165 in pandas._libs.index.IndexEngine.get_loc

File pandas_libs\hashtable_class_helper.pxi:1577 in pandas._libs.hashtable.Float64HashTable.get_item

File pandas_libs\hashtable_class_helper.pxi:1587 in pandas._libs.hashtable.Float64HashTable.get_item

KeyError: 161.001 ```

Anything else we need to know?

The data are provided by JAXA P-Tree.

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:50:36) [MSC v.1929 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 140 Stepping 1, GenuineIntel byteorder: little LC_ALL: None LANG: en LOCALE: ('English_New Zealand', '1252') libhdf5: 1.12.1 libnetcdf: 4.8.1 xarray: 2022.6.0 pandas: 1.5.0 numpy: 1.23.3 scipy: 1.9.1 netCDF4: 1.6.0 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.6.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2022.9.1 distributed: None matplotlib: 3.5.2 cartopy: 0.20.2 seaborn: None numbagg: None fsspec: 2022.8.2 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 65.3.0 pip: 22.2.2 conda: None pytest: None IPython: 8.5.0 sphinx: 5.2.1
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7108/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 10 rows from issue in issue_comments
Powered by Datasette · Queries took 0.608ms · About: xarray-datasette