Skip to content

Instantly share code, notes, and snippets.

@jfburkhart
Last active May 30, 2017 12:18
Show Gist options
  • Save jfburkhart/84c31c2c54a0617e5acca99c5de784ec to your computer and use it in GitHub Desktop.
Save jfburkhart/84c31c2c54a0617e5acca99c5de784ec to your computer and use it in GitHub Desktop.
In [62]: empty = xr.DataArray(zed, dims=['ageclass', 'pointspec', 'time', 'latitude', 'longitude'], coords={'time':taxis, 'latitude': dset.l
...: atitude, 'longitude':dset.longitude})
In [63]: empty
Out[63]:
<xarray.DataArray (ageclass: 1, pointspec: 1, time: 2557, latitude: 360, longitude: 720)>
array([[[[[ 0., ..., 0.],
...,
[ 0., ..., 0.]],
...,
[[ 0., ..., 0.],
...,
[ 0., ..., 0.]]]]])
Coordinates:
* latitude (latitude) float32 -89.75 -89.25 -88.75 -88.25 -87.75 -87.25 ...
* time (time) datetime64[ns] 2007-01-01 2007-01-02 2007-01-03 ...
* longitude (longitude) float32 -178.75 -178.25 -177.75 -177.25 -176.75 ...
Dimensions without coordinates: ageclass, pointspec
In [64]: empty[dict(time=dset.WD_spec001.time[1:])] = np.diff(dset.WD_spec001 + dset.DD_spec001)
ValueError: invalid subkey array(['2008-03-03T00:00:00.000000000', '2008-03-04T00:00:00.000000000',
'2008-03-05T00:00:00.000000000', '2008-03-06T00:00:00.000000000',
'2008-03-07T00:00:00.000000000', '2008-03-08T00:00:00.000000000',
'2008-03-09T00:00:00.000000000', '2008-03-10T00:00:00.000000000',
'2008-03-11T00:00:00.000000000', '2008-03-12T00:00:00.000000000',
'2008-03-13T00:00:00.000000000', '2008-03-14T00:00:00.000000000',
'2008-03-15T00:00:00.000000000', '2008-03-16T00:00:00.000000000',
'2008-03-17T00:00:00.000000000', '2008-03-18T00:00:00.000000000',
'2008-03-19T00:00:00.000000000', '2008-03-20T00:00:00.000000000',
'2008-03-21T00:00:00.000000000', '2008-03-22T00:00:00.000000000',
'2008-03-23T00:00:00.000000000', '2008-03-24T00:00:00.000000000',
'2008-03-25T00:00:00.000000000', '2008-03-26T00:00:00.000000000',
'2008-03-27T00:00:00.000000000', '2008-03-28T00:00:00.000000000',
'2008-03-29T00:00:00.000000000', '2008-03-30T00:00:00.000000000',
'2008-03-31T00:00:00.000000000', '2008-04-01T00:00:00.000000000',
'2008-04-02T00:00:00.000000000', '2008-04-03T00:00:00.000000000',
'2008-04-04T00:00:00.000000000', '2008-04-05T00:00:00.000000000',
'2008-04-06T00:00:00.000000000', '2008-04-07T00:00:00.000000000',
'2008-04-08T00:00:00.000000000', '2008-04-09T00:00:00.000000000',
'2008-04-10T00:00:00.000000000', '2008-04-11T00:00:00.000000000',
'2008-04-12T00:00:00.000000000', '2008-04-13T00:00:00.000000000',
'2008-04-14T00:00:00.000000000', '2008-04-15T00:00:00.000000000',
'2008-04-16T00:00:00.000000000', '2008-04-17T00:00:00.000000000',
'2008-04-18T00:00:00.000000000', '2008-04-19T00:00:00.000000000',
'2008-04-20T00:00:00.000000000', '2008-04-21T00:00:00.000000000',
'2008-04-22T00:00:00.000000000', '2008-04-23T00:00:00.000000000',
'2008-04-24T00:00:00.000000000', '2008-04-25T00:00:00.000000000',
'2008-04-26T00:00:00.000000000', '2008-04-27T00:00:00.000000000',
'2008-04-28T00:00:00.000000000', '2008-04-29T00:00:00.000000000',
'2008-04-30T00:00:00.000000000', '2008-05-01T00:00:00.000000000'], dtype='datetime64[ns]') for integer based array indexing; all subkeys must be slices, integers or sequences of integers or Booleans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment