Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

filled_bars_interp: Fatal: Rain

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.

carinavb

New member
Hello: I'm trying to plot a bar chart of rain and acumulated rain but I get this error:

filled_bars_interp: Fatal: There are no values less than or greater than the chosen reference line.
(0) Cannot draw a bar chart.

My ncl script:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
;***********************************************

procedure change_xaxis(wks,plot,taus,times)
local res2, vpx, vpy, vph, vpw, blank
begin
;
; The times array has values like "15_00","15_03",..., "15_21","16_00".
;
; For every "xx_00" label, we want a major tickmark, and for
; the others we want minor tickmark.
;

;---First, add the major tick marks.
ii = str_match_ind(times,"_00")
values = taus(ii)
labels = str_get_cols(times(ii),0,1)

setvalues plot
"tmXBMode" : "Explicit"
"tmXBValues" : values
"tmXBLabels" : labels
"tmXBLabelFontHeightF" : 0.012
end setvalues

;--Remove these so we can use them again
delete(ii)
delete(values)
delete(labels)
;
; Second, get the locations of where we want minor tickmarks.
; We have to add these by creating a blank plot with a new
; set of tickarks.

; First, retrieve the viewport coordinates. This will be
; used for the blank plot.
;
getvalues plot
"vpXF" : vpx
"vpYF" : vpy
"vpHeightF" : vph
"vpWidthF" : vpw
end getvalues

stimes = str_get_cols(times,3,4)
ii = ind(stimes.ne."00")
values = taus(ii)
labels = stimes(ii)

res2 = True

res2@vpXF = vpx
res2@vpYF = vpy
res2@vpHeightF = vph
res2@vpWidthF = vpw

res2@tmXBMode = "Explicit"
res2@tmXBValues = values
res2@tmXBLabels = labels

res2@tmXBLabelFontHeightF = 0.01 ; Make these labels smaller.
res2@tmXBMajorOutwardLengthF = 0.005 ; Make the lengths smaller
res2@tmXBMajorLengthF = 0.005
; res2@tmXBLabelDeltaF = 0.6 ; Move label away from tickmarks.

res2@tmXBLabelFontColor = "Brown"

res2@tmYROn = False ; Turn off right tickmarks.
res2@tmXTOn = False ; Turn off top tickmarks.
res2@tmYLOn = False ; Turn off left tickmarks.

blank = gsn_blank_plot(wks,res2) ; Create a blank plot.
overlay(plot,blank) ; Overlay on existing plot.

return
end

begin
;***********************************************

a = addfile("wrfout_d01.nc","r")

;-----------------------------------------------------------------------

; Find the ij location for the point if interest
lat = -24.313832
lon = -65.249007
llres = True
llres@ReturnInt = True ; Return integer values
locij = wrf_user_ll_to_ij(a, lon, lat, llres)
locij = locij - 1 ; array pointers in NCL space
locX = locij(0)
locY = locij(1)


; get time information and strip out the day and hour
times_in_file = a->Times
dims = dimsizes(times_in_file)
times = new(dims(0),string)
taus = ispan(1,dims(0),1) ; integer
do i=0,dims(0)-1
times(i) = chartostring(times_in_file(i,8:12))
end do
wks = gsn_open_wks("png","lluvia") ; open a workstation

;-----------------------------------------------------------------------
gsn_define_colormap(wks,"BkBlAqGrYeOrReViWh200")
rain_res = True
rain_exp = wrf_user_getvar(a,"RAINNC",-1)
rain_con = wrf_user_getvar(a,"RAINC",-1)
rain = rain_exp + rain_con

;print (rain)
temp = dimsizes(rain)
print (temp)
nt = temp(0)
;print (nt)
;new_rain = rain(1:nt-1,:,:) - rain(0:nt-2,:,:)
new_rain = new( temp, typeof(rain), -999.0)
new_rain(1:,:,:) = rain(1:nt-1,:,:) - rain(0:nt-2,:,:) ; (1:,:,:) same as (1:nt-1,:,:)
;print (new_rain)

;-----------------------------------------------------------------------
arain_point = rain:),locY,locX)
rain_point = new_rain:),locY,locX)


ar_max=(max(arain_point))+1
r_max=(max(rain_point))+1
rain_nz=floattoint((r_max-0)/2)

res1D = True ; Set basic resources both will use
res1D@vpXF = 0.15 ; The left side of the box location
res1D@vpWidthF = 0.75 ; The Width of the plot box
res1D@vpHeightF = 0.10 ; The height of the plot box
res1D@xyLineThicknesses = 2 ; increase line thickness
res1D@gsnDraw = False ; Don't draw individual plot.
res1D@gsnFrame = False ; Don't advance frame.
res1D@tmYLLabelFontHeightF =0.01
;res1D@trXMinF = min(taus)
;res1D@trXMaxF = max(taus)
res1D@tiYAxisFontHeightF=0.015

res1Dd = True
;res1Dd@gsLineDashPattern = 4
res1Dd@xyDashPattern = 4
res1Dd@xyDashPatterns = (/2,5,12/)
;res1Dd@trXMinF = min(taus)
;res1Dd@trXMaxF = max(taus)
res1Dd@tiYAxisFontHeightF=0.015


rain_res = res1D
rain_res@vpYF = 0.29 ; The top side of the plot box location
rain_res@tiXAxisString = "" ; X axis label.
rain_res@tiYAxisString = "Prec. (mm)" ; Y axis label.
rain_res@trYMinF = 0.0 ; min value on y-axis
rain_res@trYMaxF = r_max ; min value on y-axis
rain_res@xyLineThicknesses = 2
rain_res@gsnDraw = False ; Don't draw individual plot.
rain_res@gsnFrame = False ; Don't advance frame.
rain_res@gsnYRefLine = 0.0 ; create a reference line
rain_res@gsnAboveYRefLineColor = "green" ; above ref line fill green
rain_res@gsnXYBarChart = True ; turn on bar chart
rain_res@tiYAxisFontColor = "green"

arain_res = res1Dd
arain_res@vpYF = 0.29 ; The top side of the plot box loc
arain_res@xyLineColor = "blue" ; set line color
arain_res@trYMinF = 0 ; min value on y-axis
arain_res@trYMaxF = ar_max ; min value on y-axis
arain_res@tiYAxisString = "P.Acum (mm)" ; Y axis label.
arain_res@tiYAxisFontColor = "blue"

print (taus)
print (rain_point)
print (arain_point)
rain_plot = gsn_csm_xy2(wks,taus,rain_point, arain_point,rain_res,arain_res)


change_xaxis(wks,rain_plot,taus,times)


draw(rain_plot)


frame(wks)
;-----------------------------------------------------------------------

end

Someone can guide in what I'm doing wrong?

Best Regards
Carina
 
Hi Carina,

I have tested your script on some of my data. I got the same result as you initially. Then I checked the data and saw that there was actually no precipitation at that point for all the times. I then chose a point that did have precipitation and it worked just fine. I saw that you were printing rain_point and arain_point. If they are all zero, the plot will not work.
 
Top