Issue with wrf_map_overlays()

From: A.J. Eiserloh <arthur.eiserloh_at_nyahnyahspammersnyahnyah>
Date: Fri Sep 13 2013 - 19:48:48 MDT

Hi all,

I am trying to plot data from my wrf_out file for every time period. For
every time I want to make 3 plots with wrf_map_overlays() ( Plot 1:
sfc_temp.,wind vectors,and sfc. pressure; Plot2: sfc dew points and wind
vectors; and Plot 3: relative humidity and wind vectors). Also, I am using
the gsn_shapefile_polylines() function to add county outlines with a
shapefile after I create each plot. The first plot is created with wind
vectors and everything is fine and the way I want it to look but the last
two will not add the wind vectors and I am confused why not if the first
plot worked. I get NHL Also I should let you know that I have my own
modified version of WRFUserARW.ncl just to make the titles of the variables
a little bit bigger. I will attatch an example of my first and second
plots. Notice how my plot is missing the wind vectors. The same is for
plot3. My script gives me the fatal: NhlAddOverlay errors after it creates
the first plot (See below):

*My script* (it's kind of long but the end of it is where I am having the
issue):

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW_ajcontours.ncl"
load "./gsn_shapefile_polylines.ncl"

begin
;
print("Working on WRF Surface1")
; The WRF ARW input file.
; This needs to have a ".nc" appended, so just do it.
  a = addfile("./wrfout_d03_2013-08-17_00:00:00.nc","r")

; We generate plots, but what kind do we prefer?
  type = "ps"
  type@wkOrientation = "landscape"
  wks = gsn_open_wks(type,"plt_Surface1")

; Set some basic resources
  res = True
  res@MainTitle = " "
  res@Footer = False
  MTOPosF = -0.05

  res@gsnDraw=False
  res@gsnFrame=False

  pltres = True
  mpres = True
  mpres@gsnMaximize = True
  mpres@mpGeophysicalLineColor = "black"
  mpres@mpNationalLineColor = "black"
  mpres@mpUSStateLineColor = "black"
  mpres@mpLimbLineColor = "black"
  mpres@mpPerimLineColor = "black"
  mpres@mpOutlineBoundarySets = "AllBoundaries"
  mpres@mpDataBaseVersion = "HighRes"
  mpres@mpDataSetName = "Earth..4"
  mpres@mpGeophysicalLineThicknessF = 2
  mpres@mpUSStateLineThicknessF = 2
  mpres@mpNationalLineThicknessF = 2
  pltres@pmLabelBarDisplay= "Always"
  pltres@PanelPlot = True
  pltres@LatLonOverlay = 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,1
; do it = 0,ntimes-1 ; 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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; First get the variables we will need

    slp = wrf_user_getvar(a,"slp",it) ; slp
      wrf_smooth_2d( slp, 3 ) ; smooth slp

    tc = wrf_user_getvar(a,"tc",it) ; 3D tc
    td = wrf_user_getvar(a,"td",it) ; 3D td
    u = wrf_user_getvar(a,"ua",it) ; 3D U at mass points
    v = wrf_user_getvar(a,"va",it) ; 3D V at mass points
    td2 = wrf_user_getvar(a,"td2",it) ; Td2 in C
    tc2 = wrf_user_getvar(a,"T2",it) ; T2 in Kelvin
       tc2 = tc2-273.16 ; T2 in C
    u10 = wrf_user_getvar(a,"U10",it) ; u at 10 m, mass point
    v10 = wrf_user_getvar(a,"V10",it) ; v at 10 m, mass point

    p = wrf_user_getvar(a, "pressure",it) ; pressure is our vertical
coordinate
    rh = wrf_user_getvar(a,"rh",it) ; relative humidity
    ps = wrf_user_getvar(a,"PSFC",it) ; pressure is our vertical coordinate
   psfc = ps/100.

    tf2 = 1.8*tc2+32. ; Turn temperature into Fahrenheit
      tf2@description = "Surface Temperature"
      tf2@units = "F"
    td_f = 1.8*td2+32. ; Turn temperature into Fahrenheit
      td_f@description = "Surface Dew Point Temp"
      td_f@units = "F"
    u10 = u10*1.94386 ; Turn wind into knots
    v10 = v10*1.94386
      u10@units = "kts"
      v10@units = "kts"

      rh_opt = (/ 1, 983, 1013/)
      rh_plane = wgt_vert_avg_beta(p,rh,psfc,0,rh_opt)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Plotting Time
      res@InitTime = False
      res@ValidTime = False
      res@NoHeaderFooter = True
      tt=ps
      tt@description = " Init " + times(0) +" / Valid " + times(it)
      tt@units = "UTC"
      opts=res
      opts@ContourParameters = (/1., 2., 1./)
      opts@cnFillColors = -1
      opts@lbTitleOn = False
      opts@cnInfoLabelOn = False
      title = wrf_contour(a,wks,tt,opts)
      delete(opts)

    ; Plotting options for T
      opts = res
      opts@cnFillOn = True
      opts@ContourParameters = (/ -10., 105., 5./)
      opts@cnFillColors =
(/19,20,21,22,23,24,25,26,27,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19/)
      opts@lbOrientation = "Vertical"
      opts@pmLabelBarSide = "Right"
      opts@pmLabelBarOrthogonalPosF= -0.075
      opts@lbTitleOn = False
      opts@lbBottomMarginF = 0
      opts@lbTopMarginF = 0
      opts@lbLabelAlignment = "InteriorEdges"
      opts@lbLabelOffsetF = 0.06
      contour_tc = wrf_contour(a,wks,tf2,opts)
      delete(opts)

     freeze=False
     if(any(tf2.lt.0.0)) then
       freeze = True
       opts=res
       opts@cnFillOn = False
       opts@cnLevelSelectionMode = "ExplicitLevels"
       opts@cnLevels = (/31.99,32.0,32.01/)
       opts@cnMonoLineColor = False
       opts@cnMonoLineDashPattern = True
       opts@cnLineDashPattern = 2
       otps@cnExplicitLineLabelsOn = True
       opts@cnLineLabelStrings = (/" ","32"," "/)
       opts@cnLineColors = (/-1,24,-1/)
     fz_line = wrf_contour(a,wks,tf2,opts)
     delete(opts)
     end if

    ; Plotting options for Td
      opts = res
      opts@cnFillOn = True
      opts@cnLinesOn = True
      opts@cnLineLabelsOn = True
      opts@ContourParameters = (/0., 65., 5./)
      opts@cnFillColors = (/17,16,15,14,13,12,11,10,9,8,7,6,5,4,27/)
      opts@cnLineLabelBackgroundColor = -1
      opts@lbOrientation = "Vertical"
      opts@pmLabelBarSide = "Right"
      opts@pmLabelBarOrthogonalPosF= -0.075
      opts@lbTitleOn = False
      opts@cnLineLabelsOn = False
      opts@cnConstFLabelOn = False
      opts@cnInfoLabelOn = False
      opts@cnLineLabelPerimOn = False
      opts@lbTitleOn = False
      opts@lbBottomMarginF = 0
      opts@lbTopMarginF = 0
      opts@lbLabelAlignment = "InteriorEdges"
      opts@lbLabelOffsetF = 0.06

      contour_td = wrf_contour(a,wks,td_f,opts)
      delete(opts)

    ; Plotting options for SLP
      opts = res
      opts@cnLineColor = "Blue"
      opts@cnHighLabelsOn = True
      opts@cnLowLabelsOn = True
      opts@ContourParameters = (/ 900., 1100., 1. /)
      opts@cnLineLabelBackgroundColor = -1
      opts@gsnContourLineThicknessesScale = 2.0
      opts@cnInfoLabelOn = False
      opts@cnLineLabelFontHeightF = 0.01
      opts@cnLineLabelPerimOn = False
      contour_psl = wrf_contour(a,wks,slp,opts)
      delete(opts)

    ; Plotting options for RH
      opts = res
      opts@cnFillOn = True
      opts@pmLabelBarOrthogonalPosF = -0.1
      opts@ContourParameters = (/ 50., 100., 10./)
      opts@cnFillColors = (/0,9,8,7,6,5,4,27,0/)
      opts@lbOrientation = "Vertical"
      opts@pmLabelBarSide = "Right"
      opts@pmLabelBarOrthogonalPosF= -0.075
      opts@lbTitleOn = False
      opts@cnConstFLabelOn = False
      opts@FieldTitle = "SFC-30mb Avg. RH"
      contour_rh = wrf_contour(a,wks,rh_plane,opts)
      delete(opts)

    ; Plotting options for Wind Vectors
      opts = res
      opts@FieldTitle = "Winds" ; overwrite Field Title
      opts@NumVectors = 30 ; density of wind barbs
      opts@vcWindBarbTickLengthF = 0.35
      opts@vcRefLengthF = 0.025
      vector = wrf_vector(a,wks,u10,v10,opts)
      delete(opts)

;define shapefiles
        sf1="./shapefiles/california_county_clipped_58.shp" ;ca counties
       ; sf2="./shapefiles/tl_2010_06_prisecroads_Clip.shp" ;bay area
highways

          pres_sf1=True
          pres_sf1@gsLineColor = "black"
          pres_sf1@gsLineThicknessF = 1.0
       ; pres_sf2=True
       ; pres_sf2@gsLineColor = "grey79"
       ; pres_sf2@gsLineThicknessF = 1.0

    ; MAKE PLOTS
      if (freeze) then
      plot1 =
wrf_map_overlays(a,wks,(/contour_tc,fz_line,contour_psl,vector,title/),pltres,mpres)
       else
      plot1 =
wrf_map_overlays(a,wks,(/contour_tc,contour_psl,vector,title/),pltres,mpres)
      end if
      draw(plot1)
      gsn_shapefile_polylines(wks,plot1,sf1,pres_sf1)
      frame(wks)

      plot2 =
wrf_map_overlays(a,wks,(/contour_td,vector,title/),pltres,mpres)
      draw(plot2)
      gsn_shapefile_polylines(wks,plot2,sf1,pres_sf1)
      frame(wks)

      plot3 =
wrf_map_overlays(a,wks,(/contour_rh,vector,title/),pltres,mpres)
      draw(plot3)
      gsn_shapefile_polylines(wks,plot3,sf1,pres_sf1)
      frame(wks)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  end do ; END OF TIME LOOP

  delete(wks)
  system("convert plt_Surface1.ps -rotate '-90<' Surface.png")
end

*Output:*

(0) Working on time: 2013-08-17_00:00:00
warning:ContourPlotSetValues: Data values out of range of levels set by
MANUALLEVELS mode
fatal:NhlAddOverlay: tranform is already an annotation or overlay: 151
fatal:NhlAddOverlay: tranform is already an annotation or overlay: 11
fatal:NhlAddOverlay: tranform is already an annotation or overlay: 151
fatal:NhlAddOverlay: tranform is already an annotation or overlay: 11
(0) Working on time: 2013-08-17_01:00:00
warning:ContourPlotSetValues: Data values out of range of levels set by
MANUALLEVELS mode
fatal:NhlAddOverlay: tranform is already an annotation or overlay: 378
fatal:NhlAddOverlay: tranform is already an annotation or overlay: 208
fatal:NhlAddOverlay: tranform is already an annotation or overlay: 378
fatal:NhlAddOverlay: tranform is already an annotation or overlay: 208

------------------------------------------------------------------------------------------------------

It gives me these errors after it creates the first plot.

-- 
Arthur J. Eiserloh, Jr.
San Jose State University
Graduate Student
Dept. of Meteorology and Climate Science



_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

plot1.png plot2.png
Received on Fri Sep 13 19:49:06 2013

This archive was generated by hypermail 2.1.8 : Mon Sep 16 2013 - 13:43:52 MDT