geocat.comp.climatologies.month_to_season

geocat.comp.climatologies.month_to_season#

geocat.comp.climatologies.month_to_season(dset, season, time_coord_name=None, keep_attrs=None)#

Computes a user-specified three-month seasonal mean.

This function takes an xarray dataset containing monthly data spanning years and returns a dataset with one sample per year, for a specified three-month season.

Parameters:
  • dset (xarray.Dataset, xarray.DataArray) – The data on which to operate

  • season (str) –

    A string representing the season to calculate: e.g., “JFM”, “JJA”. Valid values are:
    • DJF {December, January, February}

    • JFM {January, February, March}

    • FMA {February, March, April}

    • MAM {March, April, May}

    • AMJ {April, May, June}

    • MJJ {May, June, July}

    • JJA {June, July, August}

    • JAS {July, August, September}

    • ASO {August, September, October}

    • SON {September, October, November}

    • OND {October, November, December}

    • NDJ {November, December, January}

  • time_coord_name (str, optional) – Name for time coordinate to use. Defaults to None and infers the name from the data.

  • keep_attrs (bool, optional) – If True, attrs will be copied from the original object to the new one. If False, the new object will be returned without attributes. Defaults to None which means the attrs will only be kept in unambiguous circumstances.

Returns:

computed_dset (xarray.Dataset, xarray.DataArray) – The computed data

Note

This function requires the number of months to be a multiple of 12, i.e. full years must be provided. Time stamps are centered on the season. For example, seasons=’DJF’ returns January timestamps. If a calculated season’s timestamp falls outside the original range of monthly values, then the calculated mean is dropped. For example, if the monthly data’s time range is [Jan-2000, Dec-2003] and the season is “DJF”, the seasonal mean computed from the single month of Dec-2003 is dropped.

See also

Related NCL Functions: month_to_season