home / github

Menu
  • Search all tables
  • GraphQL API

issues

Table actions
  • GraphQL API for issues

2 rows where repo = 13221727 and user = 11022336 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date), closed_at (date)

state 2

  • closed 1
  • open 1

type 1

  • issue 2

repo 1

  • xarray · 2 ✖
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
860180906 MDU6SXNzdWU4NjAxODA5MDY= 5175 Feature to retrieve the underlying store skorper 11022336 closed 0     6 2021-04-16T21:23:55Z 2023-09-16T10:19:19Z 2023-09-16T10:19:18Z NONE      

Is your feature request related to a problem? Please describe. It would be useful if I could retrieve the underlying store from an xarray Dataset object. There was previously a workaround that allowed this, but that was recently removed.

python dataset._file_obj.ds # Doesn't work anymore :(

Describe the solution you'd like Ideally I'd like the API to be extended so the underlying store can be retrieved. Something like:

```python

dataset = xr.open_dataset('/path/to/file.nc') nc_dataset = dataset.store type(nc_dataset) <class 'netCDF4._netCDF4.Dataset'> ```

Describe alternatives you've considered I'd be fine using the old workaround if that was still an option. If anyone knows of a different workaround I would be fine with that, but a better long-term solution would be an actual user-facing function for accessing the store.

I might be using the 'store' terminology incorrectly, but hopefully my request is clear with the above example.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/5175/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed xarray 13221727 issue
1421718311 I_kwDOAMm_X85UvbMn 7210 Unable to convert times to datetime when first and last value are masked skorper 11022336 open 0     2 2022-10-25T01:57:04Z 2022-10-27T15:30:57Z   NONE      

What happened?

In the following conditions, I am unable to open a NetCDF file in xarray with mask_and_scale=True and decode_times=True:

  • Unusual timestamp format in time variable units attr, e.g. seconds since 2000-1-1 0:0:0 0
  • First and last value in time matches _FillValue

The following changes to the NetCDF file allows me to open the file in xarray:

  • Update timestamp format in units attr to something more common (e.g. seconds since 2000-01-01T00:00:00)

OR

  • Update first and last value in time variable to value that is not equal to _FillValue

What did you expect to happen?

I should be able to open the NetCDF file with mask_and_scale=True and decode_times=True without errors.

Minimal Complete Verifiable Example

```Python import xarray as xr import numpy as np

fill_val = -99999.0 time_vals = np.random.rand(10) time_vals[0] = fill_val time_vals[-1] = fill_val

data_vars = { 'foo': (['x'], np.random.rand(10)), 'time': ( ['x'], time_vals, { 'units': 'seconds since 2000-1-1 0:0:0 0', '_FillValue': fill_val, 'standard_name': 'time', 'calendar': 'standard' } ), }

ds = xr.Dataset( data_vars=data_vars, coords={'x': (['x'], np.arange(10))} )

nc_out_location = '/path/to/example.nc' ds.to_netcdf(nc_out_location) ds = xr.open_dataset(nc_out_location) # This line results in an error ```

MVCE confirmation

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

Relevant log output

Python dateutil.parser._parser.ParserError: Unknown string format: 2000-1-1 0:0:0 0 ... ValueError: could not convert string to Timestamp ... pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime ... TypeError: unsupported operand type(s) for +: 'cftime._cftime.DatetimeGregorian' and 'NoneType' ... ValueError: unable to decode time units 'seconds since 2000-1-1 0:0:0 0' with "calendar 'standard'". Try opening your dataset with decode_times=False or installing cftime if it is not installed.

Anything else we need to know?

Looking at the code, it seems like this is happening because _decode_cf_datetime_dtype in times.py is only selecting the first and last values from the data, which in this case are masked due to _FillValue.

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.9.1 (default, Jan 8 2021, 17:17:17) [Clang 12.0.0 (clang-1200.0.32.28)] python-bits: 64 OS: Darwin OS-release: 21.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: None LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.0 libnetcdf: 4.7.4 xarray: 2022.10.0 pandas: 1.4.1 numpy: 1.22.3 scipy: 1.8.0 netCDF4: 1.5.7 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.5.1 nc_time_axis: None PseudoNetCDF: None rasterio: 1.2.10 cfgrib: None iris: None bottleneck: None dask: 2022.02.0 distributed: 2022.02.0 matplotlib: 3.5.1 cartopy: None seaborn: None numbagg: None fsspec: 2022.01.0 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 60.10.0 pip: 21.1.1 conda: None pytest: None IPython: None sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7210/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    xarray 13221727 issue

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issues] (
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [number] INTEGER,
   [title] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [state] TEXT,
   [locked] INTEGER,
   [assignee] INTEGER REFERENCES [users]([id]),
   [milestone] INTEGER REFERENCES [milestones]([id]),
   [comments] INTEGER,
   [created_at] TEXT,
   [updated_at] TEXT,
   [closed_at] TEXT,
   [author_association] TEXT,
   [active_lock_reason] TEXT,
   [draft] INTEGER,
   [pull_request] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [state_reason] TEXT,
   [repo] INTEGER REFERENCES [repos]([id]),
   [type] TEXT
);
CREATE INDEX [idx_issues_repo]
    ON [issues] ([repo]);
CREATE INDEX [idx_issues_milestone]
    ON [issues] ([milestone]);
CREATE INDEX [idx_issues_assignee]
    ON [issues] ([assignee]);
CREATE INDEX [idx_issues_user]
    ON [issues] ([user]);
Powered by Datasette · Queries took 87.677ms · About: xarray-datasette