Skip to content

save multiple files opened using mfdataset as a single one #7839

Answered by kmuehlbauer
gkb999 asked this question in General
Discussion options

You must be logged in to vote

For the time-problem, you would need to add units (and calendar) attribute. I've tried to prepare the DataArray/Dataset to look like yours.

import xarray as xr
import numpy as np
da = xr.DataArray(np.arange(10), name="time", dims=["time",])
ds = da.to_dataset()
print(ds.time)
ds.time.attrs["units"] = "days since 2012-01-01"
ds.time.attrs["calendar"] = "proleptic_gregorian"
ds = xr.decode_cf(ds)
print(ds)
<xarray.DataArray 'time' (time: 10)>
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
Dimensions without coordinates: time
<xarray.Dataset>
Dimensions:  (time: 10)
Coordinates:
  * time     (time) datetime64[ns] 2012-01-01 2012-01-02 ... 2012-01-10
Data variables:
    *empty*

Update: Please also ref…

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
2 replies
@gkb999
Comment options

@kmuehlbauer
Comment options

Answer selected by gkb999
Comment options

You must be logged in to vote
4 replies
@gkb999
Comment options

@gkb999
Comment options

@kmuehlbauer
Comment options

@kmuehlbauer
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants