Skip to content

open_mfdataset() on a single file drops the concat_dim #1988

Closed
@WeatherGod

Description

@WeatherGod

When calling xr.open_mfdataset() on a 1 element list of filenames, the concat dimension is never added.

This isn't a MWE at the moment (will make one soon enough), just wanted to get my thoughts down.

from datetime import datetime
import xarray as xr

time_coord = xr.DataArray([datetime.utcnow()], name='time', dims='time')
radmax_ds = xr.open_mfdataset(['foobar.nc'], concat_dim=time_coord)
print(radmax_ds)
<xarray.Dataset>
Dimensions:    (latitude: 5650, longitude: 12050)
Coordinates:
  * latitude   (latitude) float32 13.505002 13.515002 13.525002 13.535002 ...
  * longitude  (longitude) float32 -170.495 -170.485 -170.475 -170.465 ...
Data variables:
    RadarMax   (latitude, longitude) float32 dask.array<shape=(5650, 12050), chunksize=(5650, 12050)>
Attributes:
    start_date:   03/07/2017 01:00
    end_date:     03/07/2017 01:55
    elapsed:      60

Problem description

If there are two files, then there is a time coordinate, and the data array becomes 3D.

Output of xr.show_versions()

I am currently on a recent-ish master of xarray.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions