Precipitation Rate Calculation

From: Sahidul <sahidul_at_nyahnyahspammersnyahnyah>
Date: Thu Jun 10 2010 - 04:23:56 MDT

Dear help,

I am having wrf forecast files saved in 1 hour interval. So I am having
72 files in total. like below
wrfout_d02_2010-06-10_00:00:00
wrfout_d02_2010-06-10_01:00:00
wrfout_d02_2010-06-10_02:00:00
.....
etc.

I would like to calculate accumulated rainfall (RAINC + RAINNC) for every
hourly i.e., for 1st hour, 2nd hour, 3rd hour etc. till 72th hour rainfall.
I mean accumulated rainfall in every hour. So to calculate, 2nd hour
rainfall, I need to substract previous hour(i.e., 1st hour). In the same
way, to calculate 5th hour rainfall, I need to substract 4th hour rainfall.
etc etc.

Following script, I wrote which is reading every wrfout files and plotting
individually. I am not able to substract previous hour rainfall. Could you
please help to solve it by modifying my script.

- - - - - -------- --- --- --- --- ----
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin

datadir = "/casvol5/basantas/cas/WRF3-1/output-wrf/2010053000/"
FILES = systemfunc ("ls -1 " + datadir + "wrfout_d02* " )
numFILES = dimsizes(FILES)

do ifil = 0,numFILES-1
   a = addfile(FILES(ifil)+".nc","r")

; Set some basic resources
  res = True
; res@MainTitle = "REAL-TIME WRF"
  res@InitTime = False
  res@Footer = False

  pltres = True
  mpres = True
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; What times and how many time steps are in the data set?
  FirstTime = True
  times = wrf_user_list_times(a) ; get times in the file
  ntimes = dimsizes(times) ; number of times in the file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  do it = 0,ntimes-1,2 ; TIME LOOP

    print("Working on time: " + times(it) )
    if (FirstTime) then ; Save some times for tracking tendencies
      times_sav = times(it)
    end if
; res@TimeLabel = times(it) ; Set Valid time to use on plots

day = systemfunc("echo "+times(it) +"|cut -c9-10")
yr = systemfunc("echo "+times(it) +"|cut -c1-4")
mon = systemfunc("date '+%b'|tr [a-z] [A-Z]")
hr = systemfunc("echo "+times(it) +"|cut -c12-13")

; wks = gsn_open_wks(type,"rainhr")
 wks = gsn_open_wks("ps","rainhr_"+day+mon+yr+"_"+hr+"Z")
  colors = (/"white","black" \ ; {for/back}ground
            ,"white","azure" \
            ,"green","palegreen","yellowgreen", "greenyellow" \
            ,"yellow","goldenrod","orange","orangered" \
            ,"red","deeppinK", "violet","darkviolet" \
            ,"blueviolet","blue" /)
 gsn_define_colormap(wks, colors)

;gsn_define_colormap(wks,"gui_default")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; First get the variables we will need

  ; Get non-convective, convective and total precipitation
    rain_exp = wrf_user_getvar(a,"RAINNC",it)
    rain_con = wrf_user_getvar(a,"RAINC",it)
    rain_tot = rain_exp + rain_con
; rain_tot@description = "Precipitation Rate"
    rain_tot@description = ""
; rain_tot@units = "mm/hr"

        opts = res
        opts@cnFillOn = True
        opts@mpOutlineBoundarySets = "AllBoundaries"
        mpres@mpOutlineBoundarySets = "National"
        mpres@mpNationalLineThicknessF = 1.5
        mpres@mpNationalLineColor = "Black"
        mpres@mpGeophysicalLineColor = "Black"
        mpres@mpGeophysicalLineThicknessF = 1.5

; set resource for color of contour
;;; opts@cnLevelSelectionMode = "ManualLevels"
;;; opts@cnMinLevelValF = 0.
;;; opts@cnMaxLevelValF = 30.
;;; opts@cnLevelSpacingF = 2.
;;; opts@cnFillOn = True
  opts@cnLevelSelectionMode = "ExplicitLevels" ; explicit [unequal] cn
levels
  opts@cnLevels = (/0,0.1,1,2.5,5,7.5,10,15,20,25,37.5,50/)
  ;;opts@cnLevels =
(/0,0.1,1,2.5,5,7.5,10,15,20,25,37.5,50,75,100,125,150/)
  opts@cnFillOn = True
  opts@cnFillMode = "AreaFill"
; opts@lbOrientation = "Vertical" ; default is horizontal

      ; Total Precipitation (color fill)
        contour_tot = wrf_contour(a,wks,rain_tot,opts)

  ; MAKE PLOTS
        ; Total Precipitation
          plot = wrf_map_overlays(a,wks,contour_tot,pltres,mpres)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    end do ; END OF TIME LOOP
  end do ; END OF TIME LOOP
end
- - - - - -------- --- --- --- --- ----

Thanking you,

with regards,'

Sahidull

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jun 10 10:36:56 2010

This archive was generated by hypermail 2.1.8 : Thu Jun 24 2010 - 14:10:27 MDT