Re: questions about the detail processes of clmDayTLL and calcDayAnomTLL

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu Aug 26 2010 - 10:05:36 MDT

Hi Xuguang,
The functions in ncl were designed as the author saw fit. In this case,
and I agree with the author, it was decided that to calculate the daily
climatology the day of year would be used as opposed to the calendar day.

Using the calendar day would limit the number of days that would go into
the Feb 29th climatology. For instance, a climatology based on a 10 year
dataset could only have 2 Feb 29th values that go into the climatology
calculation.

I do see the merits of both methods. However, as I stated before a
function does not exist in NCL that will calculate the daily climatology
as you wish. We suggest either altering the existing
clmDayTLL/calcDayAnomTLL functions or using the code snippet I sent you
to develop your own set of functions. I would frankly suggest the latter
method, and just expand it to allow for whatever dimension arrays
(likely 3D) you are operating on.
Good luck,
Adam

On 08/26/2010 03:31 AM, Xuguang Sun wrote:
> Hi, Adam and Dennis,
>
> Thanks a lot for your kind reply.
>
> By your explanation, I think I understand how the two functions works.
>
> But to my opinion, I prefer the arithmetic of calculation of daily climatology by corresponding date (calendar) not the present one in clmDayTLL. What do you think?
>
> Best regards,
>
> Xuguang
>
> --- 10年8月25日,周三, Adam Phillips<asphilli@ucar.edu> 写道:
>
>> 发件人: Adam Phillips<asphilli@ucar.edu>
>> 主题: Re: [ncl-talk] questions about the detail processes of clmDayTLL and calcDayAnomTLL
>> 收件人: "Dennis Shea"<shea@ucar.edu>
>> 抄送: "Xuguang Sun"<sunxg007@yahoo.com.cn>, ncl-talk@ucar.edu
>> 日期: 2010年8月25日,周三,下午1:43
>> Hi Xuguang,
>> It seems that I didn't look at the code of these functions
>> close enough. I
>> mistook what the function day_of_year does. My apologies.
>> Hopefully you
>> tested the functions as I suggested. Dennis is correct.
>> Here is an example
>> of what you may need to do. For example, if you have a 1D
>> array of daily
>> data named "data", and an array the same size of data named
>> "year"
>> containing the year:
>>
>> (This is untested! Please check the end results.)
>>
>> nyr = 30 ; enter the # of years
>> cntr = 0
>> climo_366 = new(366,float)
>> nyr365 = 0
>> nyr366 = 0
>> do gg = 0,nyr-1
>> if (isleapyear(year(cntr))) then
>> climo_366 = data(cntr:cntr+365)
>> nyr366 = nyr366+1
>> cntr = cntr+366
>> else
>> climo_366(:58) = data(cntr:cntr+58)
>> climo_366(60:) =
>> data(cntr+59:cntr+364)
>> nyr365 = nyr365+1
>> cntr = cntr+365
>> end if
>> end do
>> climo_366(:58) = (/ climo_366(:58)/(nyr365+nyr366) /)
>> climo_366(59) = (/ climo_366(59)/nyr366 /)
>> climo_366(60:) = (/ climo_366(60:)/(nyr365+nyr366) /)
>>
>> data_anom = data ; preallocate space for
>> new daily anomaly array
>> cntr = 0
>> do gg = 0,nyr-1
>> if (isleapyear(year(cntr))) then
>> data_anom(cntr:cntr+365) = (/
>> data(cntr:cntr+365) - climo_366 /)
>> cntr = cntr+366
>> else
>> data_anom(cntr:cntr+58) = (/
>> data(cntr:cntr+58) - climo_366(:58) /)
>> data_anom(cntr+59:cntr+364) = (/
>> data(cntr+59:cntr+364)-climo_366(60:)/)
>> cntr = cntr+365
>> end if
>> end do
>> -------------
>> Hope that helps..
>> Adam
>>
>>
>>
>>> You can see the code used
>>> %> less
>> $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl
>>> It does not use calendar date. It uses day of year.
>>> In a leap year it uses the 1st 365 days *regardless
>> of
>>> calrndar date*.
>>> When all 365-day climatology has been computed the
>> 366
>>> day is the average of day 1 and day 365.
>>> Good luck
>>> On 8/20/10 6:50 PM, Xuguang Sun wrote:
>>>> Hi, everyone,
>>>> I'm now trying to calculate the mean annual cycle
>> and anomalies from
>> daily data, and it's very good that NCL has such functions,
>> like
>> clmDayTLL and calcDayAnomTLL, but I'm not very clear about
>> their detail
>> processes.
>>>> I have multi-year daily data with leap and
>> non-leap years included,
>> that
>>>> means there are 365 days in non-leap years and 366
>> days in leap years,
>> and whether 29Feb is included or not is their only
>> difference. If we
>> want to calculate climatological daily mean, I think the
>> right method
>> is
>>>> to add the corresponding day of each year (for
>> example, 28Feb) together
>> and then divide it by the total year number. Especially, as
>> for 29Feb,
>> because it only exists in leap years, we can simply sum
>> them up and
>> then
>>>> divide it by the leap year number. By the above
>> processes I think we
>> can
>>>> obtain the correct climatological daily mean
>> (annual cycle).
>>>> Accordingly, we can get the daily anomalies by
>> subtracting the
>>>> climatological daily mean from the multi-year
>> daily data.
>>>> I don't know whether clmDayTLL and calcDayAnomTLL
>> do the same things
>> for
>>>> daily climatology and anomaly. Does anyone have
>> some ideas?
>>>> Thanks.
>>>> Best regards,
>>>> Xuguang SUN
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options,
>> unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>>
>>
>
>
>

-- 
__________________________________________________
Adam Phillips 
asphilli@ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
Climate and Global Dynamics Division         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 Aug 26 10:05:41 2010

This archive was generated by hypermail 2.1.8 : Thu Sep 09 2010 - 05:56:39 MDT