Re: questions about the detail processes of clmDayTLL and calcDayAnomTLL

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Tue Aug 24 2010 - 23:43:18 MDT

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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Aug 24 23:43:23 2010

This archive was generated by hypermail 2.1.8 : Wed Aug 25 2010 - 11:50:26 MDT