# How do I calculate climatologies and climatological anomalies?

## Question:

Subject: computing monthly anomalies

What I want to do is this:

Given 6 years of data - 72 months

(1) compute the seasonal cycle ( 12 months - each an average of the 6 Jan, Febs ... etc.)

(2) compute the anomalies from the climatology - 72 months of data - (eg jan 79 minus jan climo ....)

I can do (1) easily using the modulo regridding, so far any way of doing (2) has eluded me.

## Quick example and explanation:

**Compute the climatological anomaly for a time series of zonal winds.
(using the Ferret demo dataset monthly_navy_winds)**

! Example data set: model-generated global winds ! (This data set included with standard Ferret distribution) yes? SET DATA monthly_navy_winds ! Get the climatological axis that you want to use ! Here we will use the pre-defined axis ("MONTH_REG") ! (If the SHOW AXIS returns nothing, see the note at the bottom of this page**) yes? SHOW AXIS month_reg name axis # pts start end MONTH_REG TIME 12mr 16-JAN 06:00 16-DEC 01:20 T0 = 01-JAN-0000 00:00:00 Axis span (to cell edges) = 8765.82 (modulo length = axis span) ! (optional) Set the time range of data to be used in the climatology yes? LET uwnd_of_interest = uwnd[T=15-jan-1983:15-jan-1991] yes? PLOT/X=180/Y=40 uwnd_of_interest

! Compute the climatology and plot over yes? LET uwnd_climatology = uwnd_of_interest[GT=month_reg@MOD] yes? PLOT/X=180/Y=40/OVERLAY uwnd_climatology[T=15-jan-1983:15-jan-1991]

! Subtract to get the anomaly ! Regrid the anomaly back to the original time axis using @asn to guarantee ! success (Subtle interpolation errors may occur on irregular time axes ! if the @asn regridding isn't done.) yes? LET uwnd_anomaly = uwnd - uwnd_climatology[gt=uwnd@asn] yes? PLOT/X=180/Y=40/T=15-jan-1983:15-jan-1991 uwnd_anomaly

but wait, with my dataset, I get an error:

yes? use my_current_data yes? plot/X=180/Y=40 U yes? LET U_climatology = U[GT=month_reg@MOD] yes? PLOT/X=180/Y=40/OVERLAY U_climatology **ERROR: regridding: only @ASN, @LIN, or @NRST regridding between calendar types: NOLEAP, GREGORIAN

The incoming data is on a different calendar, so the regridding operation we defined is not valid. We'll need to use another climatological axis. These calendars are defined automatically in Ferret: MONTH_IRREG, MONTH_REG, MONTH_GREGORIAN, MONTH_NOLEAP, MONTH_360_DAY, MONTH_ALL_LEAP, MONTH_JULIAN. Choose a monthly climatological axis with the same calendar as the source data:

yes? say `U,return=calendar` !-> MESSAGE/CONTINUE NOLEAP NOLEAP ! Define the climatology accordingly, yes? LET U_climatology = U[GT=month_noleap@MOD] yes? PLOT/X=180/Y=40/OVERLAY U_climatology

## Detailed explanation to full question:

There are actually 4 steps to what you want to do:

1) Pick a time region over which you would like to compute a climatology

2) Compute a climatology with a compressed time axis (only 12 points)

3) regrid the climatology on the full time axis (72 points in your case)

4) subtract the original variable from the regrided climatology (at each of the 72 points)

I will walk you through this below. In order to do all this we need to tell ferret the name of the compressed time axis (climatology) grid and the name of the full time axis (72 point) grid.

> What I want to do is this.

> Given 6 years of data - 72 months

Okay, so we have a variable, call it MY_VAR, in a dataset, call it MY_DATASET which has a certain time axis, call it MY_TIME_AXIS (which has 72 points) as part of a grid MY_GRID.

> (1) compute the seasonal cycle ( 12 months - each an average of the 6 Jan, Febs ... etc.)

Okay to do this we can use some regridding tools in FERRET, but first we need a climatology time axis so we type

This will set up the time axes MONTH_REG and MONTH_IRREG. (It also sets up other axes such as SEASONAL_REG which will not be used here). MONTH_IRREG has different sized boxes to reflect the fact that March has 31 days while April has only 30, etc... while MONTH_REG has 12 months of equal size (30 days each).

Now that we have the appropriate time axis, we need to pick out the region of data that over which we would like to calculate the climatology. This is not strictly necessary - by default FERRET will compute the climatology over the entire range of the data set (despite whatever time region is set using SET REGION/T=). However, you may not want the climatology of ALL the data... for example, you might have 1946-1996 data but only want the climatology for the years 1946-1976.

So we set up an intermediate variable, MY_VAR_LIMITED_TIME_RANGE

yes? let MY_VAR_LIMITED_TIME_RANGE = MY_VAR[t="1-jan-1946":"31-dec-1976"]

Okay, now we can set up the climatology

yes? let MY_CLIMATOLOGY = MY_VAR_LIMITED_TIME_RANGE[gt=MONTH_IRREG@mod]

This uses the regridding tool gt=@mod which will average the months and put the result onto the compressed climatology time axis MONTH_IRREG that we set up earlier.

> (2) compute the anomalies from the climatology - 72 months of data - (eg jan 79 - jan climo ....)

Now in order to do this we need the climatology, MY_CLIMATOLOGY, to be on the full time axis of the orginal variable MY_VAR. So once again, we need to regrid, this time from the time axis MONTH_IRREG to the time axis of the full variable.We can use the name of the time variable MY_VAR to specify the full time axis.

So, type

yes? let MY_ANOMALY = MY_VAR - MY_CLIMATOLOGY[gt=MY_VAR@asn] ! or, if you like: yes? let MY_ANOMALY = MY_VAR_LIMITED_TIME_RANGE - MY_CLIMATOLOGY[gt=MY_VAR_LIMITED_TIME_RANGE@asn]

and you are done. MY_ANOMALY will be on the exact same grid as MY_VAR.

Note that we use the @asn regridding transformation to regrid the climatology time axis back onto the full time axis. The reason for doing this is subtle: The climatological axis and the actual year length may not quite match - for example if the climatology contains 365 days in its year and the actual year is a leap year with 366 days. We use @asn to tell Ferret not to worry about this mismatch but to instead use the January value at each January etc... If you don't use the @asn transformation, Ferret will try to account for the different length months, etc... by interpolating which can lead to slightly different values being used for each January, etc...

**NOTE ! Prior to Ferret v6.9, needed to USE and CANCEL this dataset. The next two ! commands not needed in v6.9 and higher. ! The pre-defined climatological axes include all of the ! calendar definions (Gregorian, NOLEAP, LEAP, etc.) ! Or to use additional climatological axes, such as those in the definition datasets ! clim_axes_gregorian.nc. clim_axes_julian.nc, or clim_axes_noleap.nc , use this ! this same sequence: use and cancel the definition dataset. yes? USE climatological_axes yes? CANCEL DATA climatological_axes

*Contributed by Sim Larkin
Last Modified: Feb 10 1997*