Hi,
I have a set of monthly averages of some daily data (three dimensions: x, y and time):
monthly = data.groupby('time.month').mean(dim='time')
I would like to subtract the relevant monthly average from each day of the daily data, to get a sort of 'anomaly compared to monthly average' measure. I've had a look through the documentation, but I'm not sure how best to go about this.
I've tried:
which actually runs fine (I thought it would probably give an error), but produces a DataArray with an extra 'month' dimension:
<xarray.DataArray 'data' (time: 60, y: 1162, x: 1240, month: 2)>
I've also tried to 'upsample' the monthly data to produce daily data with each day's value in the month being constant, but running:
monthly_daily = monthly.resample('1D', dim='month')
gives an error as the month dimension is just an integer (1-12) not a datetime.
What is the best way to go about this?
Cheers,
Robin