Hello everyone,
I am wondering if anyone happens to know how to change a 2-dimensional Xarray Dataset into a 3-dimensional Xarray Dataset by adding a specific time as a dimension coordinates. So far, I can only add the specific time as an extra coordinate. But, I am not sure how to make 'time' as an extra dimension coordinates. Please see the code below,
In [1]: ds_daily2
Out [1]:
<xarray.Dataset>
Dimensions: (lat: 553, lon: 721)
Coordinates:
* lat (lat) float32 28.0208 27.9792 27.9375 27.8958 27.8542 ...
* lon (lon) float32 44.9792 45.0208 45.0625 45.1042 45.1458 ...
Data variables:
CHL1_mean (lat, lon) float64 nan nan nan nan nan nan nan nan nan nan ...
CHL1_flags (lat, lon) float64 9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0 ...
CHL1_error (lat, lon) float64 nan nan nan nan nan nan nan nan nan nan ...In [2]: ds_daily2_new = ds_daily2.assign_coords(time=pd.to_datetime('20170711'))
ds_daily2_new
Out [2]:
<xarray.Dataset>
Dimensions: (lat: 553, lon: 721)
Coordinates:
* lat (lat) float32 28.0208 27.9792 27.9375 27.8958 27.8542 ...
* lon (lon) float32 44.9792 45.0208 45.0625 45.1042 45.1458 ...
time datetime64[ns] 2017-07-11
Data variables:
CHL1_mean (lat, lon) float64 nan nan nan nan nan nan nan nan nan nan ...
CHL1_flags (lat, lon) float64 9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0 ...
CHL1_error (lat, lon) float64 nan nan nan nan nan nan nan nan nan nan ...It would be great if I can make the new Dataset ds_daily2_new to have a dimension (lat: 553, lon: 721, time 1). The reason that I am trying to do this is that eventually I would like to aggregate ds_daily2_new, ds_daily3_new, ds_daily4_new,... into one Dataset along the time dimension. I would gratefully appreciate it if there is any suggestions or comments on this.
Best regards,
Yan