[ncl-talk] "Hourly " and "daily average precipitation" from WRF-Chem files

Setareh Rahimi setareh.rahimi at gmail.com
Sun Dec 10 08:00:25 MST 2023


Dear all,

I need to calculate *hourly precipitation* from WRF-Chem output files. In
order, to do this I used the below equation:
(rainTot(nt,:,:) - rainTot(nt-1,:,:))

However, I received these error messages:

fatal:Subscript out of range, error in subscript #0

fatal:An error occurred reading rainTot

fatal:["Execute.c":8637]:Execute: Error occurred at or near line 70 in file
precip

Would you please advise me on how to remove these error messages? (the
script is attached).

I have also another question, how can I calculate the daily average
precipitation, please?

Many thanks in advance.

Best wishes,


-- 
S.Rahimi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20231210/ab361844/attachment.htm>
-------------- next part --------------
begin


  f       = addfile ("wrfout_d02_2021-01-28_00:00:00","r")
  rainc   = f->RAINC                 ; (Time, south_north, west_east)
  rainnc  = f->RAINNC     
  u10     = f->U10                   ; (Time, south_north, west_east)
  v10     = f->V10                    

  times   = wrf_user_getvar(f,"times",-1)
  ntim    = dimsizes(times)          ; # time steps

;
; Use NCL operator > to make sure all values >=0.0
; Sum components and assign attributes
;
  rainc   = rainc  > 0.0         
  rainnc  = rainnc > 0.0
  rainTot = rainc + rainnc          
  rainTot at description = "Total Precipitation"
  rainTot at units       =  rainc at units

  wks = gsn_open_wks("png","WRF_lc")

  colors = (/"white","azure"          \ 
            ,"green","palegreen","yellowgreen", "greenyellow" \
            ,"yellow","goldenrod","orange","orangered"        \
            ,"red","deeppinK", "violet","darkviolet"          \
            ,"blueviolet","blue"                              /)
  
  res                       = True             ; plot mods desired
  res at gsnMaximize           = True             ; maximize size
  res at gsnScalarContour      = True               ; contours desired
  res at gsnLeftString         = "Wind Vectors (m/s)"
  res at gsnRightString        = "Total Precipitation (mm)"

  res at cnFillOn              = True             ; color plot desired
  res at cnFillPalette         = colors           ; define colors for contour plot
  res at cnLinesOn             = False            ; turn off contour lines
  res at cnLineLabelsOn        = False            ; turn off contour labels
  res at cnFillMode            = "RasterFill"     ; raster
  res at cnLevelSelectionMode  = "ExplicitLevels" ; explicit [unequal] cn levels
  res at cnLevels              = (/0, 0.01,0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,1 /)

  res at vcGlyphStyle          = "WindBarb"
  res at vcRefLengthF          = 0.025            ; ref vec length
  res at vcMinDistanceF        = 0.025            ; larger means sparser
  res at vcWindBarbTickLengthF = 0.4              ; default 0.3
  res at vcRefAnnoOn           = False
  
  res = wrf_map_resources(f,res)
  res at gsnAddCyclic          = False            ; regional data: not cyclic 
  res at tfDoNDCOverlay        = True

  res at mpFillOn                    = False
  res at mpGeophysicalLineColor      = "black"    ; wrf_map_resources uses "gray"
  res at mpUSStateLineColor          = "black"
  res at mpGeophysicalLineThicknessF = 2.0        ; wrf_map_resources uses 0.5
  res at mpUSStateLineThicknessF     = 2.0
;
; Plot one time and level for demo
; .  create u and v on a common grid for visualization: nothing fancy
;
  nt = 12
do nt=0,ntim-1                               ; uncomment to loop
     res at tiMainString             = times(nt)
     
     plot = gsn_csm_vector_scalar_map(wks,u10(nt,:,:),v10(nt,:,:),(rainTot(nt,:,:) - rainTot(nt-1,:,:)),res)
end do

end


More information about the ncl-talk mailing list