# Re: Anomaly Problem

```Hi Brent,

That worked just fine.  Thanks for your help.

Scocks
Atmospheric Sciences
Texas A&M University

Brent A McDaniel wrote:

> Steve,
>
> I'll try to help you out a bit but I don't think I can answer all your
> questions.  First off, the @asn transformation.  I use this very often and
> find it extremely useful.  Basically, it is a blind association.  A
> relevant example would be to subtract out a daily climatology from a bunch
> of yearly data.  Let's call the climat.  dailyclim.nc with the var clim
> and the data files air.1970.nc, air.1971.nc etc with the variable air.
>
> To get the anomalies, you'd do something like:
>
> use dailyclim.nc
> use air.1970.nc
> use air.1971.nc
> let anom70=air[d=2]-clim[d=1,gt=`air[d=2],return=GRID`@asn]
> ...
>
> The way I've defined the anomalies is very handy as you don't have to
> manually enter the grid name of the yearly files, the grid name is
> returned by the `...,return...` statement.  This is very handy when you're
> writing a script to do many years or variables.  The @asn transformation
> simple maps the time from the clim to the time of the var you're mapping
> it to.  In this example, it would take the first point of the climatology
> and set the time to jan-1, 1970 (provided that's what the date
> for l=1 for air.1970.nc is).  The values themselves aren't altered, just
> the time stamp.  You'll notice that I only regridded the time axis, this
> is because my climatologies are fully 3-d, on the same spatial grid as the
> data.  If this wasn't the case, you'd do the same type of thing with the
> other variables.
>
> I hope this helps out with what @asn is doing.  I emailed Ansley a while
> back about increasing the documentation for @asn in the manual as it's
> extremely useful and commonplace and she said it was planned.
>
> &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
> I just re-read your post.  Oftentimes when I'm doing this with ferret,
> when I can break things up into steps, I will.  This seems to help in not
> confusing it with axis/grid problems.  In your case, I would calculate the
> climatology first and save it to a file.  Look at it, see if it looks
> correct, that way you know that step is correct.
>
> Once that's done, you could calculate the precip anomalies by doing
> something like:
> let precipanom=precipclim-avgPrec[`proper stuff to get the right
> grid`@asn]
>
> I hope this helps.
>
> Oh, one other caveat.  If you do it in parts, ie calculate the climatology
> and save to a file, cancel the variables once you saved it to a file.
> Otherwise, ferret can get confused as to what you're referencing.
>
> in other words.
>
> save/file=clim.nc dailyclim
> cancel/var dailyclim
> use clim.nc
>
> will work properly.
>
> --Brent
>
> >
> > I am running into problems calculating seasonal anomalies.
> > Specifically, I created a seasonal climatology for a variable, create an
> > average for the entire time of record for the same variable, then try to
> > take the difference:
> > **********************
> > use climatological_axes.cdf
> > def grid/t=seasonal_reg season_old
> > let tnew =t[g=season_old] - 24*31 ! Move the time axis back 31 days so
> > will  be centered on Ja, Ap, Jy, Oc -- time units are hours
> > def axis/from_data/t/name=tseason_new/units=hours/t0=1-jan-0000/modulo
> > tnew
> > def grid/t=tseason_new season_new
> > **********************
> > set data precip97_01.nc
> > **********************
> > let precip_new=precip[d=2,t=1-sep-1998:31-aug-2001] ! create a new time
> > axis for variable
> >
> > let avgPrec=precip[d=2,t=1-sep-1998:31-aug-2001@ave]    !create avg of
> > precip from 1sep98-31aug01
> >
> > list/x=153w/y=20s precip_new[d=2,gt=season_new@mod, l=4]-avgPrec
> > _______________________________________________________________
> > The result I get from Ferret is:
> >
> > list/x=153w/y=20s precip_new[d=2,gt=season_new@mod, l=4]-avgPrec
> >  **ERROR: illegal limits: AVGPREC is not in the range T=01-JAN
> > 00:12:24:15-DEC-1901 05:49
> >           Axis extremes are T=31-DEC-1996 12:00:31-AUG-2001 12:00
> > list/x=153w/y=20s precip_new[d=2,gt=season_new@mod, l=4]-avgPrec
> > Command file, command group, or REPEAT execution aborted
> >
> >
> > I experimented around with the @asn function using stuff I saw from the
> > mail archives and manual but couldn't get this to work either.  Can
> > anyone help me with this?  Thanks.
> >
> >
> > Scocks
> > TAMU
> >
>
> --
> Brent A. McDaniel
>
> Dept of Earth and Atmospheric Sciences
> Georgia Institute of Technology
> Atlanta, Ga.  USA

```