## Name

MONTHS_TO_SEASONS

## Purpose

This function extracts seasonal data from monthly data.

## Category

Calendar

## Calling Sequence

Result = MONTHS_TO_SEASONS( Data, Season [, Seasonlen] )

## Inputs

Data: A vector containing the input time series of monthly data.

It can also be an array where the last dimension is time. The

time dimension must start with a January and end with a

December. Also see OUTPUT below.

Season: The index (January=0,...) value of the middle month of the

season.

Seasonlen: Optional. The number of months in a season. The default

value is "3". If Seasonlen is even the extra month is added

at the end.

## Keyword Parameters

ANOMALY: If set, then the anomaly to the mean over BASEPERIOD is

calculated. If DESEASONALISE is set, then the anomaly from

the mean annual cycle over BASEPERIOD is calculated. The

default is to calculate total values.

BASEPERIOD: A vector of [YEARSTART,YEAREND] defining the period over

which to estimate the seasonal cycle when the ANOMALY or

DESEASONALISE keywords are set. YEARSTART is the first year

index value (month/12) while YEAREND is the last year index

value. e.g. using [10,19] would use the month indices 120

through 239.

CYCLE: If DESEASONALISE is set, then cycle contains a vector or array

(with calendar month as the last dimension) containing the

calculated seasonal cycle. Note this is the total seasonal

cycle if ANOMALY is set, or the seasonal cycle anomaly from

the annual mean if ANOMALY is not set.

DESEASONALISE: If set then the seasonal cycle is removed from the

data before the seasonal values are calculated. This has an

effect if NGOOD is set, because it then removes the bias

arising from missing data in certain months. It can also

effect the end values if the season overlaps years.

NBASEGOOD: The number of years in the base period required to have

good (non-NaN) values in order for the base value to be

calculated. The default is 1.

NGOOD: The number of months in a season required to have good

(non-NaN) values in order to calculate a seasonal value. The

default is NGOOD=Seasonlen.

## Output

Result: Returns the seasonal time series as a vector or an array,

depending on the dimensions of Data. The time dimension will

be shorter by a factor of 12.

CYCLE: See above.

Data: If the DEASONALISE and/or ANOMALY options are set then Data is

returned in a deseasonalised and/or anomaly form.

## Uses

var_type.pro

## Procedure

This function calculates seasonal values based on monthly

values.

## Example

Create a random monthly time series ten years long.

x = randomn( seed, 10*12 )

Calculate values for the summer (June-August).

result = months_to_seasons( x, 6, 3 )

## Modification History

Written by: Daithi A. Stone (stoned@atm.ox.ac.uk), 2000-08-22.

Modified: DAS, 2000-10-02 (debugged).

Modified: DAS, 2004-12-30 (added BASEPERIOD, CYCLE,

DESEASONALISE, NBASEPERIOD, NGOOD keywords; this

required some altering of main algorithm)

Modified: DAS, 2005-04-25 (can now deal with large number of

spatial points)

Modified: DAS, 2005-08-25 (removed use of constants.pro)

Modified: DAS, 2006-01-06 (altered DEASONALISE keyword to not

include taking anomaly; added ANOMALY keyword)

Modified: DAS, 2006-02-14 (streamlined some of the code)

Modified: DAS, 2008-03-18 (allowed larger time dimensions through

long integer indices)