I want to take the hourly mean of t2m values after loading multiple .nc files, loaded using xr.open_mfdataset
, but after resampling and taking the mean gives incorrect time dimensions.
I have loaded multiple .nc files using
ds =xr.open_mfdataset("../t2m/*.nc", concat_dim="time", parallel = True)
which has hourly data from 1-1-1979 to 31-12-2019. I wanted to choose the only the month of May and I used
dm = ds.isel(time=(ds.time.dt.month == 5))
I want to take the hourly mean so used the resampling as .resample(time='1D')
which grouped them into 1271 groups, which is correct (since 41years*31days of May = 1271)
But when I used .mean(dim="time")
it is giving the time dimension as
Dimensions: time: 14641
14641 is the number of hours from 01-05-1979 to 31-05-1979 including all the months in between, so it is considering all the hours between these two dates irrespective of month.
After taking the mean the dimension should have been 1271.
What I am doing wrong?