home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 630573329

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
630573329 MDU6SXNzdWU2MzA1NzMzMjk= 4121 decode_cf doesn't work for ancillary_variables in attributes 30388627 closed 0     4 2020-06-04T07:18:34Z 2022-04-18T15:56:22Z 2022-04-18T15:56:22Z NONE      

Sometimes we have one attribute called ancillary_variables which is a list containing several strings. It would be useful to decode them.

MCVE Code Sample

```python import numpy as np import xarray as xr import pandas as pd

temp = 15 + 8 * np.random.randn(2, 2, 3) precip = 10 * np.random.rand(2, 2, 3)

temp = xr.DataArray(temp, dims=['x', 'y', 'time']) precip = xr.DataArray(precip, dims=['x', 'y', 'time'])

lon = [[-99.83, -99.32], [-99.79, -99.23]] lat = [[42.25, 42.21], [42.63, 42.59]]

temp.attrs['ancillary_variables'] = ['precip'] precip.attrs['ancillary_variables'] = ['temp']

ds = xr.Dataset({'temperature': temp, 'precipitation': precip}, coords={'lon': (['x', 'y'], lon), 'lat': (['x', 'y'], lat), 'time': pd.date_range('2014-09-06', periods=3), 'reference_time': pd.Timestamp('2014-09-05')})

ds.to_netcdf('test_ancillary_variables.nc', engine='netcdf4')

ds_new = xr.open_dataset('test_ancillary_variables.nc', decode_cf=True) print(ds_new['temperature']) ```

Expected Output

...... Attributes: ancillary_variables: [<xarray.DataArray (x: 2, y: 2, time: 3)> ......... ]

Versions

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.7.6 | packaged by conda-forge | (default, Mar 23 2020, 23:03:20) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.9.0-8-amd64 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_US.utf8 LOCALE: en_US.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.4 xarray: 0.15.1 pandas: 1.0.4 numpy: 1.18.4 scipy: 1.4.1 netCDF4: 1.5.3 pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: 2.4.0 cftime: 1.1.3 nc_time_axis: None PseudoNetCDF: None rasterio: 1.1.5 cfgrib: None iris: None bottleneck: None dask: 2.14.0 distributed: 2.17.0 matplotlib: 3.2.1 cartopy: 0.18.0 seaborn: None numbagg: None setuptools: 47.1.1.post20200529 pip: 20.1.1 conda: None pytest: None IPython: None sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4121/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
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 0.536ms · About: xarray-datasette