[ncl-talk] Heatwave events with different durations calculation
Dennis Shea
shea at ucar.edu
Thu Aug 22 19:06:43 MDT 2019
Makng a separate case for each 'duration' is VERY cumbersome.
You must come up with a method where (i) a 'switch' is set; (ii) as long as
the switch is set, accumulate the 'tx' values and a counter 'txknt'; (iii)
when switch is turned off; average the accumulated values; (iv) reset
counter
See attached script.
*%>* ncl YooRimJung.ncl
--
output
---
yyyy m d tx o du avg
1981 06 29 26 0 00 -99.00
1981 06 30 33 1 *03 34.00*
1981 07 01 34 0 00 -99.00
1981 07 02 35 0 00 -99.00
1981 07 03 30 0 00 -99.00
1981 07 04 33 1 *05 33.00*
1981 07 05 33 0 00 -99.00
1981 07 06 33 0 00 -99.00
1981 07 07 33 0 00 -99.00
1981 07 08 33 0 00 -99.00
1981 07 09 28 0 00 -99.00
1981 07 10 70 *1 02 80.00*
1981 07 11 90 0 00 -99.00
On Wed, Aug 21, 2019 at 3:12 AM YooRim Jung via ncl-talk <ncl-talk at ucar.edu>
wrote:
> 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
>
>
>
> _______________________________________________
> 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/20190822/3f7c2ac7/attachment.html>
-------------- next part --------------
1981 06 29 26 0 00 -99.00
1981 06 30 33 1 03 34.00
1981 07 01 34 0 00 -99.00
1981 07 02 35 0 00 -99.00
1981 07 03 30 0 00 -99.00
1981 07 04 33 1 05 33.00
1981 07 05 33 0 00 -99.00
1981 07 06 33 0 00 -99.00
1981 07 07 33 0 00 -99.00
1981 07 08 33 0 00 -99.00
1981 07 09 28 0 00 -99.00
1981 07 10 70 1 02 80.00
1981 07 11 90 0 00 -99.00
-------------- next part --------------
A non-text attachment was scrubbed...
Name: YooRimJung.ncl
Type: application/octet-stream
Size: 3347 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190822/3f7c2ac7/attachment.obj>
More information about the ncl-talk
mailing list