Closed
Description
I have this xr.Dataset
:
<xarray.Dataset>
Dimensions: (time: 1, x: 200, y: 200)
Coordinates:
* time (time) float64 9.505e+17
Dimensions without coordinates: x, y
Data variables:
Rg (time, y, x) float32 ...
latitude (y, x) float64 ...
longitude (y, x) float64 ...
time datetime64[ns] 2000-02-14
Attributes:
Conventions: CF-1.0
content: HARMONIZED WORLD SOIL DATABASE; first it was aggregated ...
scaling_factor: 20
I want to copy it through time, adding the time dimension at a given daterange
Something like this:
times = pd.date_range('2000-01-01', '2000-12-31', name='time')
ds.time = times[0]
all_data = [ds]
for i, time in enumerate(times[1:]):
ds_t1 = ds.copy()
ds_t1.time = time
all_data.append(ds)
ds = ds_t1
ds = xr.concat(all_data)
So I should have output data like:
<xarray.Dataset>
Dimensions: (time: 366, x: 200, y: 200)
Coordinates:
* time (time) float64 ...
Dimensions without coordinates: x, y
Data variables:
Rg (time, y, x) float32 ...
latitude (y, x) float64 ...
longitude (y, x) float64 ...
time datetime64[ns] 2000-02-14
Attributes:
Conventions: CF-1.0
content: HARMONIZED WORLD SOIL DATABASE; first it was aggregated ...
scaling_factor: 20