[ncl-talk] Heatwave events with different durations calculation

YooRim Jung yrjungfla at gmail.com
Wed Aug 21 03:11:38 MDT 2019


Hello,
I am attempting to calculate heatwave(Tmax >= 33C) events with different
durations  (any consecutive days:    >=2 days, 3days, ... 30days).
I am trying to make a code using the daily Tmax data (Ascii) as follows and
I'd like to write output in the following format.
But, my source code is very limited and too complicated.
Could you let me know the best way to make a simple code?
Thank you.


INPUT Data sample
===========================================================
Station1
Year Month  Day  Tmax
1981    6       29      26
1981    6       30      33
1981    7         1      34
1981    7         2      35
1981    7         3      30
1981    7         4      33
1981    7         5      33
1981    7         6      33
1981    7         7      33
1981    7         8      33
1981    7         9      28
.........
Station2
.........

OUTPUT Data sample
===========================================================
Station1
Year Month  Day  Tmax         Onset    Duration    AvgTmax
1981    6       29      26                0              0                0
1981    6       30      33                1              3
 (33+34+35)/3
1981    7         1      34                0              0                0
1981    7         2      35                0              0                0
1981    7         3      30                0              0                0
1981    7         4      33                1              5
(33+33+33+33+33)/5
1981    7         5      33                0              0
0
1981    7         6      33                0              0
0
1981    7         7      33                0              0                0
1981    7         8      33                0              0
0
1981    7         9      28                0              0                0
.........
Station2
.........

NCL Code
===========================================================
nd = (/31,28,31,30,31,30,31,31,30,31,30,31/)

jrec = -1
do year    = 1981, 1982
do month = 1, 12
do day     = 0, nd(month-1)
      jrec = jrec + 1
do stn      = 0, ns-1           ; ns : # of observation station

     ;;;; duration >2 days
           if(tmax(stn,jrec).ge.33 .and. tmax(stn,jrec+1).ge.33) then
                  hyy(stn,0) = year
                    ; heatwave onset day (year)
                  hmm(stn,0) = month
              ; heatwave onset day  (month)
                  hdd(stn,0) = day
                  ; heatwave onset day   (day)
                  hindex(stn,0) = 1
                   ; if hw onset day, marked as 1
                  htx(stn,0)  = (tmax(stn,jrec)+tmax(stn,jrec+1)) / hdr
  ; tmax average with duration 2dys
           end if

    ;;;; duration >3 days
           if(tmax(stn,jrec).ge.33 .and. tmax(stn,jrec+1).ge.33 .and.
tmax(stn,jrec+2).ge.33 ) then
                  hyy(stn,1) = year
                    ; heatwave onset day (year)
                  hmm(stn,1) = month
              ; heatwave onset day  (month)
                  hdd(stn,1) = day
                  ; heatwave onset day   (day)
                  hindex(stn,1) = 1
                   ; if hw onset day, marked as 1
                  htx(stn,1)  =
(tmax(stn,jrec)+tmax(stn,jrec+1)+tmax(stn,jrec+2)) / hdr      ; tmax
average with duration 3dys
            end if

 ;;;; duration >4 days
           if(tmax(stn,jrec).ge.33 .and. tmax(stn,jrec+1).ge.33 and.
tmax(stn,jrec+2).ge.33 and. tmax(stn,jrec+3).ge.33) then
                  hyy(stn,2) = year
                    ; heatwave onset day (year)
                  hmm(stn,2) = month
              ; heatwave onset day  (month)
                  hdd(stn,2) = day
                  ; heatwave onset day   (day)
                  hindex(stn,2) = 1
                   ; if hw onset day, marked as 1
                  htx(stn,2)  =
(tmax(stn,jrec)+tmax(stn,jrec+1)+tmax(stn,jrec+2)+tmax(stn,jrec+3)) / hdr
    ; tmax average with duration 4dys
           end if

;;;; duration >30 days
           .........

end do
end do
end do
end do


Sincerely,
YR
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190821/7c2e04b8/attachment.html>


More information about the ncl-talk mailing list