I have a 45 years of data named ds in the netCDF(.nc) format. It contains three coordinates: time, latitude and longitude.
print(ds)
<xarray.Dataset>
Dimensions: (latitude: 106, longitude: 193, time: 403248)
Coordinates:
* latitude (latitude) float32 -39.2 -39.149525 ... -33.950478 -33.9
* longitude (longitude) float32 140.8 140.84792 140.89584 ... 149.95209 150.0
* time (time) datetime64[ns] 1972-01-01 ... 2017-12-31T23:00:00
Data variables:
FFDI (time, latitude, longitude) float32 dask.array<shape=(403248, 106, 193), chunksize=(744, 106, 193)>
Attributes:
creationTime: 1525925611
creationTimeString: Wed May 9 21:13:31 PDT 2018
Conventions: COARDS
I need to calculate 95 percentile of FFDI by seasons, namely SON (Sep, Oct, Nov), DJF (Dec, Jan, Feb), MAM (Mar, Apr, May), JJA (Jun, Jul, Aug).
da_ffdi_95th = ds['FFDI'].reduce(np.percentile, dim='time', q=95)
This created a new DataArray object with percentile variables but the time dimension was dropped.
How can groupby be used with the np.percentile function?
ds = xr.tutorial.load_dataset('air_temperature')? This one gives two years of data (variable = air temperature). - alextc