xCDAT / xcdat

An extension of xarray for climate data analysis on structured grids.
https://xcdat.readthedocs.io/en/latest/
Apache License 2.0
113 stars 12 forks source link

[Feature]: Enable departures calculations for annual data #564

Open pochedls opened 10 months ago

pochedls commented 10 months ago

Is your feature request related to a problem?

The departures calculation does not work for annual data.

# import xcdat
import xcdat as xc
# open dataset
dpath = '/p/user_pub/work/CMIP6/CMIP/E3SM-Project/E3SM-2-0/historical/r1i1p1f1/Amon/ts/gr/v20220830/'
ds = xc.open_mfdataset(dpath)
# get annual averages
ds = ds.temporal.group_average('ts', freq='year')
# calculate annual departures
ds = ds.temporal.departures('ts', freq='year')

ValueError: Incorrect freq argument. Supported frequencies for departures include: ['season', 'month', 'day'].

Describe the solution you'd like

.departures() works for monthly data (freq="month") – it would be useful if this also worked for annual data.

Describe alternatives you've considered

No response

Additional context

I think this would be equivalent to (CDAT using .YEAR): cdutil.YEAR.departures().