home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 778083748

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
778083748 MDU6SXNzdWU3NzgwODM3NDg= 4761 Dataset.interp drops boolean variables 14371165 closed 0     0 2021-01-04T13:09:56Z 2021-05-13T15:28:15Z 2021-05-13T15:28:15Z MEMBER      

What happened: Dataset.interp silently drops boolean variables.

What you expected to happen: If I'm interpolating a group of variables I expect to get all of them back in the correct shape with relevant values in them.

If the variables are boolean or object arrays I don't expect it to do linear interpolation because it doesn't make sense but stepwise interpolation like nearest or zero order interpolation should be fine to expect.

Minimal Complete Verifiable Example:

```python import numpy as np a = np.arange(0, 5) b = np.core.defchararray.add("long_variable_name", a.astype(str)) coords = dict(time=da.array([0, 1])) data_vars = dict() for v in b: data_vars[v] = xr.DataArray( name=v, data=np.array([0, 1]).astype(bool), dims=["time"], coords=coords, ) ds1 = xr.Dataset(data_vars)

Print raw data:

print(ds1) Out[3]: <xarray.Dataset> Dimensions: (time: 2) Coordinates: * time (time) int32 0 1 Data variables: long_variable_name0 (time) bool False True long_variable_name1 (time) bool False True long_variable_name2 (time) bool False True long_variable_name3 (time) bool False True long_variable_name4 (time) bool False True

Interpolate:

ds1 = ds1.interp( time=da.array([0, 0.5, 1, 2]), assume_sorted=True, method="nearest", kwargs=dict(fill_value="extrapolate"), )

Print interpolated data:

<xarray.Dataset> Dimensions: (time: 4) Coordinates: * time (time) float64 0.0 0.5 1.0 2.0 Data variables: empty ```

Anything else we need to know?: ds.interp_likeuse ds.reindex in these cases which seems like a good choice in ds.interp as well. But I think that both ds.interp and ds.interp_like should fill by default with nearest value instead of np.nan because we're still requesting interpolation.

Environment:

Output of <tt>xr.show_versions()</tt> xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] python-bits: 64 OS: Windows libhdf5: 1.10.4 libnetcdf: None xarray: 0.16.2 pandas: 1.1.5 numpy: 1.17.5 scipy: 1.4.1 netCDF4: None pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2020.12.0 distributed: 2020.12.0 matplotlib: 3.3.2 cartopy: None seaborn: 0.11.1 numbagg: None pint: None setuptools: 51.0.0.post20201207 pip: 20.3.3 conda: 4.9.2 pytest: 6.2.1 IPython: 7.19.0 sphinx: 3.4.0
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4761/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

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