I have a dictionary with 1000 keys and each key has 23 entries, each is an xarray.DataArray. Each entry looks like this:
<xarray.DataArray 'time' (time: 23)>
array(['1861-01-16T12:00:00.000000000', '1861-02-15T00:00:00.000000000',
'1861-03-16T12:00:00.000000000', '1861-04-16T00:00:00.000000000',
'1861-05-16T12:00:00.000000000', '1861-06-16T00:00:00.000000000',
'1861-07-16T12:00:00.000000000', '1861-08-16T12:00:00.000000000',
'1861-09-16T00:00:00.000000000', '1861-10-16T12:00:00.000000000',
'1861-11-16T00:00:00.000000000', '1861-12-16T12:00:00.000000000',
'1862-01-16T12:00:00.000000000', '1862-02-15T00:00:00.000000000',
'1862-03-16T12:00:00.000000000', '1862-04-16T00:00:00.000000000',
'1862-05-16T12:00:00.000000000', '1862-06-16T00:00:00.000000000',
'1862-07-16T12:00:00.000000000', '1862-08-16T12:00:00.000000000',
'1862-09-16T00:00:00.000000000', '1862-10-16T12:00:00.000000000',
'1862-11-16T00:00:00.000000000'], dtype='datetime64[ns]')
Coordinates:
* time (time) datetime64[ns] 1861-02-15 ... 1862-12-16T12:00:00
month (time) int64 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11
I am trying to concatenate all these entries and get a new variable with dimensions ( 1000,23)
which would look like
<xarray.DataArray 'entries','time' (entries:1000,time: 23)>
and then I want to be able to write this into a Netcdf file so to use .to_netcdf.
If I do
tt=xr.concat(entry[0],entry[1])
I get the following:
<xarray.DataArray 'time' (time: 23)>
array(['1861-01-16T12:00:00.000000000', '1861-02-15T00:00:00.000000000',
'1861-03-16T12:00:00.000000000', '1861-04-16T00:00:00.000000000',
'1861-05-16T12:00:00.000000000', '1861-06-16T00:00:00.000000000',
'1861-07-16T12:00:00.000000000', '1861-08-16T12:00:00.000000000',
'1861-09-16T00:00:00.000000000', '1861-10-16T12:00:00.000000000',
'1861-11-16T00:00:00.000000000', '1861-12-16T12:00:00.000000000',
'1862-01-16T12:00:00.000000000', '1862-02-15T00:00:00.000000000',
'1862-03-16T12:00:00.000000000', '1862-04-16T00:00:00.000000000',
'1862-05-16T12:00:00.000000000', '1862-06-16T00:00:00.000000000',
'1862-07-16T12:00:00.000000000', '1862-08-16T12:00:00.000000000',
'1862-09-16T00:00:00.000000000', '1862-10-16T12:00:00.000000000',
'1862-11-16T00:00:00.000000000'], dtype='datetime64[ns]')
Coordinates:
* time (time) datetime64[ns] 1861-01-16T12:00:00 1861-02-15 ... 1862-11-16
month (time) int64 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11
<xarray.DataArray 'time' (time: 23)>
array(['1861-01-16T12:00:00.000000000', '1861-02-15T00:00:00.000000000',
'1861-03-16T12:00:00.000000000', '1861-04-16T00:00:00.000000000',
'1861-05-16T12:00:00.000000000', '1861-06-16T00:00:00.000000000',
'1861-07-16T12:00:00.000000000', '1861-08-16T12:00:00.000000000',
'1861-09-16T00:00:00.000000000', '1861-10-16T12:00:00.000000000',
'1861-11-16T00:00:00.000000000', '1861-12-16T12:00:00.000000000',
'1862-01-16T12:00:00.000000000', '1862-02-15T00:00:00.000000000',
'1862-03-16T12:00:00.000000000', '1862-04-16T00:00:00.000000000',
'1862-05-16T12:00:00.000000000', '1862-06-16T00:00:00.000000000',
'1862-07-16T12:00:00.000000000', '1862-08-16T12:00:00.000000000',
'1862-09-16T00:00:00.000000000', '1862-10-16T12:00:00.000000000',
'1862-11-16T00:00:00.000000000'], dtype='datetime64[ns]')
Coordinates:
* time (time) datetime64[ns] 1861-02-15 ... 1862-12-16T12:00:00
month (time) int64 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11
So how I loop over this and transform the entries of the dictionary into a new dimension for the xarran.DataArray and get the (1000,23) xarray.DataArray ? Thanks !