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 - jan climo ....) I can do (1) easily using the modulo regridding, so far any way of doing (2) has eluded me.
! 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-definied axis ("MONTH_REG") yes? USE climatological_axes yes? CANCEL DATA climatological_axes ! (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
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. If you are unsure of the actual name of your time axis and grid is you can set up a grid with a known name equal to the grid your variable is on by typing yes? define grid/like=MY_VAR NEW_GRID_NAME Then the grid NEW_GRID_NAME will be equal to the grid MY_GRID that MY_VAR is/was on to begin with. Phew. With me so far? A simpiler way to put that is just that NEW_GRID_NAME will be idenitical to MY_GRID in all aspects. Why we need to name this grid will become clear later, when we need to tell FERRET the grid name. > (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 yes? use climatological_axes This will set up the time axes MONTH_REG and MONTH_IRREG. (It also sets up the axis SEASONAL_REG which will not be used here). The difference between these is that 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. Fortunately, we have a handle on this time axis as it is part of the grid NEW_GRID_NAME (and MY_GRID if you know what the orginal grid name is). So, type yes? let MY_ANOMALY = MY_VAR - MY_CLIMATOLOGY[gt=NEW_GRID_NAME@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...
Contributed by Sim Larkin
Last Modified: Feb 10 1997