I have an xarray of daily data with a number of variables. I want to extract the maximum q_routed
every year and the corresponding values of other variables on the day that the maximum q_routed
happens.
<xarray.Dataset>
Dimensions: (latitude: 1, longitude: 1, param_set: 1, time: 17167)
Coordinates:
* time (time) datetime64[ns] 1970-01-01 ...
* latitude (latitude) float32 44.5118
* longitude (longitude) float32 -111.435
* param_set (param_set) |S1 b''
Data variables:
ppt (time, param_set, latitude, longitude) float64 ...
pet (time, param_set, latitude, longitude) float64 ...
obsq (time, param_set, latitude, longitude) float64 ...
q_routed (time, param_set, latitude, longitude) float64 ...
The command below gives me the maximum of every variable in a year, but that's not what I want.
ncdat['q_routed'].groupby('time.year').max( )
Trial
I tried this
ncdat.groupby('time.year').argmax('time')
which leads to this error:
ValueError: All-NaN slice encountered
How can I do this?