Re: DJF averaging

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu, 11 Jun 2009 15:23:29 -0600

Hi Michel,
The answer depends on the time coordinate coordinate variable that's
attached to the data that you want to use. I prefer to work in time
units of YYYYMM, as I find it the easiest format to quickly subset:
sst = b->sst({190001:200012},:,:)

If however, your data comes in with units of "months-since ..." or some
other format, there are two easy options: 1) Convert the time coordinate
variable to something that would be easier to subset, as I show below.
or 2) Use regular subscripting to grab what you want, which is the
method I used in the example I previously sent you.

In many cases, using ut_calendar is the way to go. Here's an example
where I read in a file, and use ut_calendar to switch the time from
units of "hours since 1-1-1 00:00:0.0" to YYYYMM, and then select only
the data I want using coordinate subscripting:

a = addfile("hadsst2_1x1.185001-200812.nc","r")
sstT = a->sst
sstT&time = ut_calendar(sstT&time,1)
sst = sstT({197901:200712},:,:)
delete(sstT)

Adam

Michel.Mesquita_at_bjerknes.uib.no wrote:
> Hi Adam,
>
> Thank you so much for helping me!
> You're right, I meant the function 'month_to_season'. :-)
> I was actually slicing the data first and then applying month_to_season.
> So, I see that the correct way would be the other way around!
> There's something else I'd like to ask you. You said:
>> You can make that more generic instead of coding in the 31:60 if you
>> wish, and that would probably be recommended.
>
> I am not sure how to refer to the exact timesteps I want in NCL. So,
> what I do is to use 'ut_calendar' to find out the indexes to the period
> I want. Is there a more generic way? (for example, in Grads you can
> specific the time directly, 'set time 12JAN79' - or something like that)
>
> Thank you and have a great day!
>
> Kindest regards,
>
> Michel
>
>
> Quoting Adam Phillips <asphilli_at_ucar.edu>:
>
>> Hi Michel,
>> When you say you are using the function month_to_month, do you mean you
>> are using the function month_to_seasonN?
>> http://www.ncl.ucar.edu/Document/Functions/Contributed/month_to_seasonN.shtml
>>
>> As the documentation states, the time dimension must be divisible by
>> 12, and must start in January. Also, the first average (DJF year 0) is
>> actually the average of January and February year 0.
>>
>> So, taking all of that into account, you want to compute the DJF
>> average from 1979-2008, and you want to take into account December
>> 1978...
>>
>> d = addfile("data.nc","r")
>> data = d->slp ; data will be dimensioned time x lat x lon
>>
>> data_temp = month_to_seasonN(data,"DJF")
>> data_djf = data_temp(0,31:60,:,:) ; 31:60 = 1979-2007
>>
>> You can make that more generic instead of coding in the 31:60 if you
>> wish, and that would probably be recommended.
>>
>> Finally, if you want an overall DJF 1979-2007 mean, use dim_avg_Wrap to
>> average over the time dimension of data_djf.
>> http://www.ncl.ucar.edu/Document/Functions/Contributed/dim_avg_Wrap.shtml
>> Good luck,
>> Adam
>>
>>
>>
>> Michel.Mesquita_at_bjerknes.uib.no wrote:
>>> Hi everyone,
>>>
>>> I have a netcdf file with data from 1948 - 2009(march). I want to
>>> calculate the DJF average from 1978(9) to 2007.
>>>
>>> First, I need to slice the data for the period I am working with.
>>> But where should I start this slice if I use the function
>>> month_to_month in NCL? I know this function has to start from January.
>>>
>>> If I start from January 1978 do these values (January and February
>>> 1978) enter in the average calculation? And if I end the data in
>>> December 2008, does that December enter in the calculation? I
>>> assume they don't.
>>>
>>> I really appreciate your help!
>>>
>>> Kindest regards,
>>>
>>> Michel
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>> --
>> --------------------------------------------------------------
>> Adam Phillips asphilli_at_ucar.edu
>> National Center for Atmospheric Research tel: (303) 497-1726
>> ESSL/CGD/CAS fax: (303) 497-1333
>> P.O. Box 3000
>> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
>

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jun 11 2009 - 15:23:29 MDT

This archive was generated by hypermail 2.2.0 : Mon Jun 15 2009 - 08:53:05 MDT