home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 782335748

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
782335748 MDU6SXNzdWU3ODIzMzU3NDg= 4783 User directories (~) not expanded by open_mfdataset(). 1186928 closed 0     0 2021-01-08T19:08:25Z 2021-01-15T17:22:28Z 2021-01-15T17:22:27Z CONTRIBUTOR      

What happened:

Hi. Perhaps a trivially minor issue, but I have noticed that open_dataset and to_netcdf expand user directories (~), while open_mfdataset does so on file lists, but not on patterns or single files.

What you expected to happen:

I would expect consistent behaviour across all file reading and writing methods.

Minimal Complete Verifiable Example:

```python

import xarray as xr xr.Dataset().to_netcdf('~/dataset.nc') # works xr.open_dataset('~/dataset.nc') # works xr.open_mfdataset(['~/dataset.nc']) # works xr.open_mfdataset('~/dataset.nc') # error Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.9/site-packages/xarray/backends/api.py", line 891, in open_mfdataset raise OSError("no files to open") OSError: no files to open ```

Anything else we need to know?:

This is done by private method _normalize_paths, which is called in open_dataset and to_netcdf but not open_mfdataset.

https://github.com/pydata/xarray/blob/1525fb0b23b8e92420ab428dc3d918a658e92dd4/xarray/backends/api.py#L170-L177

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.9.1 (default, Dec 13 2020, 11:55:53) [GCC 10.2.0] python-bits: 64 OS: Linux OS-release: 5.4.80-2-MANJARO machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_GB.utf8 LOCALE: en_GB.UTF-8 libhdf5: 1.12.0 libnetcdf: 4.7.4 xarray: 0.16.1 pandas: 1.1.5 numpy: 1.19.4 scipy: 1.5.4 netCDF4: 1.5.4 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.2.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.30.0 distributed: None matplotlib: 3.3.3 cartopy: None seaborn: None numbagg: None pint: None setuptools: 51.0.0 pip: 20.2.2 conda: None pytest: 6.1.2 IPython: 7.19.0 sphinx: 3.4.0
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4783/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
  • 0 rows from issue in issue_comments
Powered by Datasette · Queries took 0.499ms · About: xarray-datasette