[ncl-talk] fatal:Or: operation not supported on type (string) / Plotting WRF output

Stephen Kirby thinjogger at gmail.com
Tue Jul 3 11:12:10 MDT 2018


Hi,

I am getting the error seen on the subject line as I try to plot WRF data.
I am using wrf_gsn_5.ncl straight out of the box from the NCL site page
supporting plotting WRF output.  I only changed the WRF output file to one
I generated. I'm running NCL version 6.4.0.

I'm pasting the code below for reference and please note the error comes
from this line of code:

*contour_tf = gsn_csm_contour(wks,tf2,tf_res)*

and the other errors listed are:
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 3642 in
file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl
which are these lines of code:
if(get_res_value_keep(res,"tfDoNDCOverlay",False).or.ftype.ne."map") then
    return(False)
end if

fatal:["Execute.c":8640]:Execute: Error occurred at or near line 13313 in
file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl
which are these lines of code:
if(get_lon_cyclic_point_default(data,res2,"",False)) then
        datanew = gsn_add_cyclic_point(data)
else
        datanew = data
end if

Thanks for any tips you can provide.

--Steve

;----------------------------------------------------------------------
; wrf_gsn_5.ncl
;----------------------------------------------------------------------
; Concepts illustrated:
;   - Using gsn_csm scripts to plot WRF-ARW data
;   - Overlaying line contours, filled contours, and vectors on a map
;   - Setting the correct WRF map projection using wrf_map_resources
;   - Setting lots of resources to customize a WRF plot
;----------------------------------------------------------------------
; This script is meant to show the difference between plotting WRF
; data using wrf_xxx scripts, and using gsn_csm_xxx scripts.
;
; See wrf_nogsn_5.ncl for an example of using wrf_xxxx scripts to
; plot WRF data.
;----------------------------------------------------------------------
; In NCL Versions 6.3.1 and earlier, you will get these warnings which
; you can safely ignore:
;
; warning:start_lat is not a valid resource in wrf_gsn_contour at this time
; warning:start_lon is not a valid resource in wrf_gsn_contour at this time
; warning:end_lat is not a valid resource in wrf_gsn_contour at this time
; warning:end_lon is not a valid resource in wrf_gsn_contour at this time
; warning:mpNestTime is not a valid resource in map at this time
;----------------------------------------------------------------------
; These files are loaded by default in NCL V6.2.0 and newer
; 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"

begin
;---Open WRF output file
  filename = "wrfout_d01_2005-12-14_13:00:00"
  a        = addfile(filename,"r")

;---Read several WRF variables at first time step
  it  = 0
  slp = wrf_user_getvar(a,"slp",it)   ; sea level pressure
  wrf_smooth_2d( slp, 3 )             ; smooth slp
  tc  = wrf_user_getvar(a,"tc",it)    ; 3D temperature
  u   = wrf_user_getvar(a,"ua",it)    ; 3D U at mass points
  v   = wrf_user_getvar(a,"va",it)    ; 3D V at mass points

;---Now get the lowest (bottommost) level
  nl  = 0
  tc2 = tc(nl,:,:)
  u10 = u(nl,:,:)
  v10 = v(nl,:,:)
  tf2 = 1.8*tc2+32.                    ; Convert temperature to Fahrenheit
  u10 = u10*1.94386                    ; Convert wind into knots
  v10 = v10*1.94386

;---Change the metadata
  tf2 at description = "Surface Temperature"
  tf2 at units       = "degF"
  u10 at units       = "kts"
  v10 at units       = "kts"

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

;---Set common resources for all plots
  res                = True
  res at gsnFrame       = False
  res at gsnDraw        = False
  res at gsnLeftString  = ""
  res at gsnRightString = ""

;---Necessary for contours to be overlaid correctly on WRF projection
  res at tfDoNDCOverlay        = "NDCViewport"
; res at tfDoNDCOverlay        = True      ; old method

;---Temperature filled contour plot
  tf_res                      = res
  tf_res at cnFillOn             = True
  tf_res at cnLevelSelectionMode = "ExplicitLevels"
  tf_res at cnLevels             = ispan(-20,90,5)
  tf_res at lbLabelFontHeightF   = 0.015
  tf_res at lbOrientation        = "Vertical"
  tf_res at pmLabelBarOrthogonalPosF = -0.005

  contour_tf = gsn_csm_contour(wks,tf2,tf_res)

;---SLP line contour plot
  levels      = ispan(900,1100,4)
  info_string = "Sea level pressure contours from 900 to 1100 by 4"

  slp_res                                = res
  slp_res at cnLineColor                    = "NavyBlue"
  slp_res at cnLevelSelectionMode           = "ExplicitLevels"
  slp_res at cnLevels                       = levels
  slp_res at cnLineLabelBackgroundColor     = -1    ; transparent
  slp_res at cnLineThicknessF               = 2.5
  slp_res at cnHighLabelsOn                 = True
  slp_res at cnLowLabelsOn                  = True
  slp_res at cnHighLabelBackgroundColor     = -1
  slp_res at cnLowLabelBackgroundColor      = -1
  slp_res at cnInfoLabelString              = info_string
  slp_res at cnInfoLabelFontColor           = "NavyBlue"
  slp_res at cnInfoLabelPerimOn             = False

  contour_psl = gsn_csm_contour(wks,slp,slp_res)

;---Wind vector plot
  vec_res                  = res
  vec_res at vcMinDistanceF   = 0.02
  vec_res at vcRefLengthF     = 0.02
  vec_res at vcMinFracLengthF = 0.2
  vec_res at vcGlyphStyle     = "WindBarb"
  vec_res at vcRefAnnoOn      = False

  vector = gsn_csm_vector(wks,u10,v10,vec_res)

;---Map plot
  map_res               = True
  map_res at gsnFrame      = False
  map_res at gsnDraw       = False
  map_res at tiMainString  = filename
  map_res at gsnLeftString = tf2 at description + " (" + tf2 at units + ")~C~" + \
                          slp at description + " (" + slp at units + ")~C~" + \
                          "Wind (" + u10 at units + ")"
  map_res at gsnLeftStringFontHeightF = 0.01

;---Set map resources based on projection on WRF output file
  map_res = wrf_map_resources(a,map_res)

  map = gsn_csm_map(wks,map_res)

;---Overlay plots on map and draw.
  overlay(map,contour_tf)
  overlay(map,contour_psl)
  overlay(map,vector)

  draw(map)   ; This will draw all overlaid plots and the map
  frame(wks)
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180703/0444c9d3/attachment.html>


More information about the ncl-talk mailing list