[ncl-talk] Daily anomaly from monthly climatology

Dennis Shea shea at ucar.edu
Fri Jun 1 11:03:30 MDT 2018


[1] *Big Picture*

You are using **one** year of daily total precipitation to calculate a
**climatology**

By definition, a climatology is the average over some period of time. EG:
In your case, average ten years of  '1 July' values. That is the
climatological mean value.

Even if the code you had written worked, the anomalies would all be 0.0.
Why? You are using only one year of data. The average of one value is the
value itself. Hence, the difference is zero.

[2] *FIX*

Use '*addfiles*' to read multiple years of APHRODITE daily files:
   https://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml

We do not have APHRODITE files so the following is more of a guide.

https://www.ncl.ucar.edu/Document/Functions/Contributed/clmDayTLL.shtml
Example 1 .... modified
===

   dirp = "./"     ; directory where APHRODITE files reside
   filp   = systemfunc("cd "+dirp+" ; ls APHRO_MA_025deg_V1101*nc")
   pthp = dirp + filp
   print(pthp)

   f      = *addfiles*(pthp, "r")
   pre  = f[:]->precip
   printVarSummary(pre)                ; time |? x [lat | ?] x [lon | ?]

  time     = precip&time                      ; time:units = "days
since ?-?-? 00:00:0.0"
   TIME   = *cd_calendar*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml>(time,
0)
   year     = *toint*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/toint.shtml>(
TIME(:,0) )
   month  = *toint*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/toint.shtml>(
TIME(:,1) )
   day      = *toint*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/toint.shtml>(
TIME(:,2) )

   yyyyddd = year*1000 + ddd                                    ;
needed for input

 pClmDay    = *clmDayTLL*(pre, yyyyddd) ; *daily climatology at each
grid point *
 *printVarSummary*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/printVarSummary.shtml>(pClmDay)
            ; [year_day | *366*] x [lat|?]x[lon|?]
                                      ; Coordinates: year_day: [*1..366]*
 pAnom      = *calcDayAnomTLL* (pre, yyyyddd, pClmDay)
 *printVarSummary*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/printVarSummary.shtml>(pAnom_sm)
 *printMinMax* <https://www.ncl.ucar.edu/Document/Functions/Contributed/printMinMax.shtml>(pAnom,
0)

; **NOW** extract the daily anomalies from 'pAnom' for the days of interest

  smdStrt= 19880713
  smdLast= 19880718

*                                        ; opttonal *
;pClmDay_sm = *smthClmDayTLL*(pClmDay, 3) ; you would have to
experiment with 'nhar' *;**printVarSummary*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/printVarSummary.shtml>(pClmDay_sm)


;pAnom_sm   = *calcDayAnomTLL* (pre, yyyyddd, pClmDay_sm)
;pAnom_sm at long_name = "Anomalies from Smooth Daily Climatology"
 *printVarSummary*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/printVarSummary.shtml>(pAnom_sm)
 *printMinMax* <https://www.ncl.ucar.edu/Document/Functions/Contributed/printMinMax.shtml>(pAnom_sm,
0)



On Thu, May 31, 2018 at 11:09 AM, Nabeela Sadaf <nh16 at mails.tsinghua.edu.cn>
wrote:

>
>
>
> -----Original Messages-----
> *From:*"Nabeela Sadaf" <nh16 at mails.tsinghua.edu.cn>
> *Sent Time:*2018-06-01 01:01:07 (Friday)
> *To:* ncl-talk-request at ucar.edu
> *Cc:*
> *Subject:* Daily anomaly from monthly climatology
>
> Hi
>
>
>
> I am using Aphrodite daily data to calculate anomaly of an event i.e.
> 13July1988 to 18July1988 with respect to climatology of JJA during 1988.
>
>
>
> In first step, I selected JJA i.e. 92 time-steps from 1st june till 31st
> August 1988.
>
> Print(ddd)
>
>
>
> Variable: ddd
>
> Type: integer
>
> Total Size: 368 bytes
>
>             92 values
>
> Number of Dimensions: 1
>
> Dimensions and sizes:  [92]
>
> Coordinates:
>
> (0)            153
>
>
>
> (91)     244
>
>
>
> In the second step, I defined event days.
>
>
>
> Print(sddd)
>
>
>
> Variable: sddd
>
> Type: integer
>
> Total Size: 24 bytes
>
>             6 values
>
> Number of Dimensions: 1
>
> Dimensions and sizes:  [6]
>
> Coordinates:
>
> (0)            195
>
> (5)   200
>
>
>
> while printVarSummary(pre) gives
>
> Variable: pre
>
> Type: float
>
> Total Size: 37094400 bytes
>
>             9273600 values
>
> Number of Dimensions: 3
>
> Dimensions and sizes:  [time | 92] x [latitude | 280] x [longitude | 360]
>
> Coordinates:
>
>             time: [ 153.. 244]
>
>             latitude: [-14.875..54.875]
>
>             longitude: [60.125..149.875]
>
>
>
>
>
> PrintVarSummary(xClmDay)
>
> Variable: xClmDay
>
> Type: float
>
> Total Size: 147571200 bytes
>
>             36892800 values
>
> Number of Dimensions: 3
>
> Dimensions and sizes:  [year_day | 366] x [latitude | 280] x [longitude |
> 360]
>
> Coordinates:
>
>             year_day: [1..366]
>
>             latitude: [-14.875..54.875]
>
>             longitude: [60.125..149.875]
>
>
>
> so when I try calcDayAnomTLL it gives following error
>
>
>
> fatal: Subscript out of range, error in subscript #0
>
> fatal: An error occurred reading days
>
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 4562 in
> file $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl
>
>
>
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 87 in
> file P2.ncl
>
>
>
> Although time format is same in all variables but it gives error in
> subscript number 0.
>
>
>
> Can anyone help me? Thanks in advance.
> Attached herewith is the script.
>
>
> Nabeela
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180601/96d2b922/attachment.html>


More information about the ncl-talk mailing list