I have array of monthy data. I want to select monthly values starting from october to march like this
my data = starts from [1950-01,1950-02,1950-03, ...]
this is what I want
selection = [1950-10, 1950-11, 1950-12, 1960-1,1960-2, 1960-3, ...] # notice it continues to 1960
thanks
You want something like data.where(data.time.dt.month.isin([1,2,3,10,11,12]), drop=True) I think
Hi yes except that selected series start are ordered from 1,2,3,10,11,12, 1, 2, 3, 10,11, 12 in that order.
what I really want is 10,11,12, 1,2,3 10,11,12,1,2,3 the first 1,2,3 in the data must be igored so from 10,11,12 the next 1,2,3 should start from the following year
Thanks
I normally use something like this, which results in the equivalent of @dcherian's suggestion, but is a bit more direct:
data = data.sel(time=data.time.dt.month.isin([1, 2, 3, 10, 11, 12]))
@mada0007 you can then subset in time to truncate the time series further afterwards:
result = data.sel(time=slice('1950-04', '1960-04'))
Nice! I should use sel more
Hi, the problem here is that I have multiple netcd files and the dats vary accros time.
is there any other way to do this ?
If you use data = xr.open_mfdataset(...), the above solution will work
Thanks to all, it works!
Most helpful comment
I normally use something like this, which results in the equivalent of @dcherian's suggestion, but is a bit more direct:
@mada0007 you can then subset in time to truncate the time series further afterwards: