# RE: [ferret_users] How can I produce a time series of JJA averages (orother intervals) from a monthly time series?

• To: Ansley.B.Manke@xxxxxxxx
• Subject: RE: [ferret_users] How can I produce a time series of JJA averages (orother intervals) from a monthly time series?
• From: Yun.Li@xxxxxxxx
• Date: Thu, 21 Sep 2006 10:24:51 +0800
• Cc: jaison@xxxxxxxxxxxxxxxxxx, oar.pmel.ferret_users@xxxxxxxx
• Domainkey-signature: s=email; d=csiro.au; c=nofws; q=dns;b=F/ElqoI3l6ABlqiP+zS5G8AERbsMNrmIx/rBD7rk9Omx8rwjfW9VX/Hx+MEJ62681XS8nPpZl8UmkfjPGG8FLBNxCa05TyxUrT7E8M2NSdMN7VfiXfRbX1BGo+V3epyc;
• Sender: owner-ferret_users@xxxxxxxxxxxxx
 Dear All,   Thanks to Ansley and Jaison for their help on this thread.   Ansley’s script is for producing the JJA time series without averaging them (i.e. 3 points in each year), and Jaison’s script is for the averaged JJA time series (i.e. one point in each year).   Please note a minor problem in Define a calendar axis in Ansley’s script as follows.   ! Define a calendar axis containing these months. def axis/t0="`uwnd,return=t0`"/units="months" tsummer = just_summer[l=1:`nja`]   yes? def axis/t0="`uwnd,return=t0`"/units="months" tsummer = just_summer[l=1:`nja`]  !-> def axis/t0="14-JAN-1980 14:00:00"/units="months" tsummer = just_summer[l=1:33]   But the t0 should start from “15-JUN-1982” in this example (I am not sure why t0="`uwnd,return=t0`" pick up t0="14-JAN-1980 14:00:00").   There is a way to fix this problem using the following line to redefine the calendar axis, though it is not automatically choose t0.   def axis/t0="14-DEC-1981 14:00:00"/units="months" tsummer = just_summer[l=1:33]   Any suggestion to the automatically choose t0 correctly?   Regards,   Yun     From: Ansley Manke [mailto:Ansley.B.Manke@noaa.gov] Sent: Thursday, 21 September 2006 2:03 AM To: Li, Yun (CMIS, Floreat) Cc: jaison@caos.iisc.ernet.in; oar.pmel.ferret_users@noaa.gov Subject: Re: [ferret_users] How can I produce a time series of JJA averages (or other intervals) from a monthly time series?   Hi all, The examples in the Users List archives work fine, but here's another script, which does not depend on building up a variable with a REPEAT loop and writing an intermediate file.  Just adding to the archives to close this thread... ! Create a time series containing only June,July, Augst data ! from a monthly data set. use monthly_navy_winds ! Get a list of the month numbers representing June ,July, August ! This is correct since the data start in January, otherwise we ! would need an offset let nmon = `uwnd,return=Lend` let tt = t[t=1:`nmon`] let june = if mod(tt,12) ge 6 then tt let june_aug = if mod(june,12) le 8 then june list june_aug ! The number of summer months. let nja = `june_aug[t=@ngd]` let just_summer = compressl(june_aug) list just_summer[L=1:`nja`] ! Now sample the Lth point of uwnd for the summer months let uwnd_jja = samplel(uwnd,just_summer[l=1:`nja`]) ! Define a calendar axis containing these months. def axis/t0="`uwnd,return=t0`"/units="months" tsummer = just_summer[l=1:`nja`] ! Put the sampled summer data on the calendar axis let uwnd_summer = uwnd_jja[gt=tsummer@asn] list/x=180/y=0 uwnd_summer Yun.Li@csiro.au wrote: Hi Jaison,   Thanks for your help. The example is very useful. I have obtained a solution to my problem following the lines of the example.   A minor question is why the extra item "(X=18.8E:18.8E(378.8), Y=91.3S:91.3N)" appears in the title of new variable UWND_JJA (see following lines).   yes? use uwnd_jja_mean.nc yes? show data      currently SET data sets:     1> .\uwnd_jja_mean.nc  (default)  name     title                             I         J         K         L  UWND_JJA JJA Seasonal Mean UWND           1:144     1:73      ...      1:11        (X=18.8E:18.8E(378.8), Y=91.3S:91.3N)     This extra item "(X=18.8E:18.8E(378.8), Y=91.3S:91.3N)" also appeared in my SLP_JJA case. How can I remove it?   Best regards,   Yun   -----Original Message----- From: Jaison Kurian [mailto:jaison@caos.iisc.ernet.in] Sent: Wednesday, 20 September 2006 4:16 PM To: Li, Yun (CMIS, Floreat) Cc: Ansley.B.Manke@noaa.gov; oar.pmel.ferret_users@noaa.gov Subject: RE: [ferret_users] How can I produce a time series of JJA averages (or other intervals) from a monthly time series?   Hi Yun,         Here is an example using monthly_navy_winds dataset. Also see these two mails, which deals with somewhat similar questions :     Hope this helps...   Jaison     !-------Example : JJA seasonal mean from monthly data----------- ! \ cancel mode verify ! Drawbacks : Data should start at January of a year. Otherwise !             "yr_months" variable should be modified accordingly. ! ! monthly navy winds : 16-JAN-1982 to 17-DEC-1992 !-----------------------------------------------------------        use monthly_navy_winds        ! create a mask such that only JJA is valid and all other months      !    are set to missing value        let L_indx    = L[GT=uwnd]      let yr_months = L_indx- 12*INT((L_indx-1)/12)      list yr_months        ! JJA -->  L is 6-8        let mask_other_months = IF yr_months GT 5 AND yr_months LT 9 THEN 1      list yr_months, mask_other_months        ! Apply the mask        let uwnd_masked = uwnd[d=1] * mask_other_months      list/x=60/y=10 uwnd_masked        ! Club the JJA values together        let uwnd_compr  = COMPRESSL(uwnd_masked)      list/x=60/y=10 uwnd_compr        ! 1982-1992 --> 11 years --> 11*3=33 data points      ! we need to average this data points in pairs of 3 to find the      !  seasonal mean. Easy way is to use two abstract axes, one      !  with 33 points (ranging from 1-33) and another one with      !  11 points (ranging from 2-32) and regrid using @AVE.        define axis/t=1:33:1 t33      let uwnd_jja_all = uwnd_compr[gt=t33@ASN]      list/x=60/y=10 uwnd_jja_all        define axis/t=2:32:3 t11  ! for the exact seasonal mean      let uwnd_jja_av  = uwnd_jja_all[gt=t11@AVE]        ! now assign a proper yearly time axis defined over 1982-1992      !  here we dont need any interpolation but the grid change      !  ..so use @ASN regridding        define axis/t=1982:1992:1/units=years tyear      let uwnd_jja  = uwnd_jja_av[gt=tyear@ASN]      list/x=60/y=10 uwnd_jja ! 6.36 7.99 7.12  8.51 9.46 9.32      set var/title="JJA Seasonal Mean UWND"/units="m/s" uwnd_jja           ! save to a NetCDF file for future use        ! sp rm -f uwnd_jja_mean.nc      ! save/file=uwnd_jja_mean.nc/APPEND uwnd_jja   !-------------end of example-------------------------------------     On Wed, 20 Sep 2006 Yun.Li@csiro.au wrote:   > Hi Ansley, > >  > > I am trying to do "Leaving only JJA SLP data" from a monthly NCEP SLP > data "slp.mon.mean.nc". I have looked at > But I could not get a solution because of my poor ferret skills.  Could > you please give me a help here? > >  > > Thanks, > >  > >  > > Yun > >  > >  > >  > >   _____  > > From: Ansley Manke [mailto:Ansley.B.Manke@noaa.gov] > Sent: Wednesday, 20 September 2006 3:02 AM > To: Li, Yun (CMIS, Floreat) > Subject: Re: [ferret_users] How can I produce a time series of JJA > averages (or other intervals) from a monthly time series? > >  > > Hi Yun, > Here are a couple of FAQ's for you to look at - if one of these is the > kind of thing you want to do. If you need help applying the ideas, > please write back to the users list. > > This FAQ makes a "seasonal mask" to pick out data from part of each > year.  It does the problem with units of time in days; but if you're > starting with monthly data you could do a similar thing with months, > with JJA being months 6,7,8.  You could combine this with the COMPRESS > functions to remove the missing data and leave only the JJA data. > > Or, did you have in mind a climatology, averaging all of the JJA data > for all years, and returning just one point?  In that case, see > "climatology, creating" in the Users Guide, and this FAQ for more > examples > > Ansley > > Yun.Li@csiro.au wrote: > > Dear Ferreters, > >  > > I am trying to produce a seasonal time series (such as JJA time series) > from a monthly time series. > >  > > There is an example from the Ferret FAQ on "How can I produce a time > series of annual averages (or other intervals) from a monthly time > series?" > >  > > >  > > I would be most grateful if you can let me know how to produce a > seasonal averaged time series (such as June-July-August average time > series) from a monthly time series by modifying the code used to produce > annual time series in the above web page, that is, > >  > >      yes?  SET DATA monthly_navy_winds > >      yes?  DEFINE AXIS/EDGES/T0=1-jan-1900/UNITS=days tann82_92 = > DAYS1900(X[i=1982:1993:1],1,1) > >      yes?  PLOT/X=180/Y=0 uwnd > >      yes?  PLOT/X=180/Y=0/over uwnd[gt=tann82_92@ave]     ! the above > plot > >  > >  > >  > > Thanks, > >  > > Yun Li > > CSIRO, Australia > > > > > > `-- `` ``~>   ~>   ~>   ~>   ~>   ~>   ~>   ~>   ~>   ~>   ~> `` ``Ansley Manke, NOAA/PMEL   ansley.b.manke@noaa.gov``7600 Sand Point Way NE, Seattle WA``Phone 206-526-6246,  FAX 206-526-6744`` `