[ncl-talk] My script does not work

Kerwyn Texeira ktish86 at gmail.com
Mon Mar 14 14:36:14 MDT 2016


Hi Alan Brammer,

I appreciate your help in this matter!

I still got a few errors:

1. When i use overlay, I get: warning:wkImageFileName is not a resource in
the given object
warning:wkImageFormat is not a resource in the given object
warning:PlotManagerSetValues: TickMark annotation cannot be added after
NhlCreate
warning:mpProjection is not a valid resource in test_contour at this time
warning:mpMinLonF is not a valid resource in test_contour at this time
warning:mpMaxLonF is not a valid resource in test_contour at this time
warning:mpMinLatF is not a valid resource in test_contour at this time
warning:mpMaxLatF is not a valid resource in test_contour at this time
warning:mpShapeMode is not a valid resource in test_contour at this time
warning:mpFillOn is not a valid resource in test_contour at this time
warning:mpOutlineOn is not a valid resource in test_contour at this time
warning:mpDataBaseVersion is not a valid resource in test_contour at this
time
warning:cnLineOn is not a valid resource in test_contour at this time
(0)     wrf_map_overlay: Warning: This procedure is obsolete. Consider
(0)                               using wrf_map_overlays instead.
warning:ContourPlotDraw: data boundary is out of range

2. I do not understand part of no.5 "you want to transfer the mp resources
to a new variable and pass that to wrf_map() instead of True"

The revised script:

;*************************************************
; overlay_1.ncl
;
; Concepts illustrated:
;   - Overlaying line contours on filled contours
;   - Explicitly setting contour levels
;   - Selecting a different color map
;
;*************************************************
;
; 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
  a = addfile("./wrfout_d03_2014-01-11_21:00:00.nc","r")

  it = 0
  hgt = wrf_user_getvar(a, "HGT", it)
  hgt at lat2d = wrf_user_getvar(a, "XLAT", it)
  hgt at lon2d = wrf_user_getvar(a, "XLONG", it)
  u         = wrf_user_getvar(a, "ua", it)
  v         = wrf_user_getvar(a, "va", it)
  p         = wrf_user_getvar(a, "pressure", it)

  u_wind    = wrf_user_intrp3d(u, p, "h", 650., 0.0, False)
  v_wind    = wrf_user_intrp3d(v, p, "h", 650., 0.0, False)


   spd = (u_wind*u_wind + v_wind*v_wind)^(0.5)  ;m/s
 ;  spd = spd*1.94384449
 ; spd at units = "Wind Speed"
 ; spd at units = "m/s"



  wks = gsn_open_wks("png","test")         ; send graphics to PNG file
  gsn_define_colormap(wks,"BlAqGrYeOrRe")


  res = True
  res at mpFillOn     = False
  res at mpMaxLatF    = 38.20                      ; specify the plot domain
  res at mpMinLatF    = 37.75                      ;
  res at mpMinLonF    = -120.00                     ;
  res at mpMaxLonF    = -119.10                     ;
  res at mpOutlineOn  = True                  ; turn the map outline on
  res at gsnDraw      =  False                   ; do not draw the plot
  res at gsnFrame     =  False                   ; do not advance the frame
;  res at csnLinesOn   =  True
;  res at tiMainString  = a

  res at mpProjection  = "CylindricalEquidistant"    ;The default
  res at pmTickMarkDisplayMode  = "Always"
  res at mpDataBaseVersion      = "MediumRes"
  res at mpOutlineOn            =True
  res at lbOrientation          = "Vertical"
  res at tiMainOffsetYF         = -0.03
  res at mpShapeMode            = "FreeAspect"
  res at vpWidthF               = 0.9
  res at vpHeightF              = 0.9

;  res at cnLevelSelectionMode = "ExplicitLevels" ; use explicit levels
;  res at cnLevels             = ispan(215,265,5) ; set the contour levels
  res at cnLineLabelsOn       = False            ; do not use line labels
  res at cnFillOn             = True             ; color fill
  res at cnLineOn            = False            ; do not draw contour lines
;  res at cnFillPalette        = "BlueDarkRed18"

  res at gsnAddCyclic         = False

  map = wrf_map(wks, a, True)

u_wind = u_wind*1.94384449
v_wind = v_wind*1.94384449

 contour = gsn_csm_contour(wks,hgt,res)

 ;------wind vectors
 res2 = True
 res2 at gsnDraw = True
 res2 at gsnFrame = True
 res2 at FieldTitle = "Winds"
 res2 at NumVectors = 47
 res2 at vcWindBarbLineThicknessF= 2.5

vector = wrf_vector(a,wks,u_wind,v_wind,res2)
 wrf_map_overlay(wrf,map,(/contour,vector/),True)
;overlay(contour,vector)



end





On Mon, Mar 14, 2016 at 9:04 AM, Alan Brammer <abrammer at albany.edu> wrote:

>
> Not sure where you’re getting those error messages from but there are many
> problems in the script.  Here are the errors I got on running your code on
> my own file and the step by step to fix them.  Make the below edits. If
> there are still problems send the whole new script to the list so we can
> see your edits.
>
>
> warning:attsetvalues: the value associated with (tiMainString) does not
> have an HLU representation
> warning:csnLinesOn is not a valid resource in gsnapp_contour at this time
> (0) gsn_csm_map_ce: Fatal: The resources mpMinLatF/mpLeftCornerLatF must
> be less than the resources mpMaxLatF/mpRightCornerF.
> (0) Execution halted.
>
>
> ;====
> 1.
> so the top error:
>
> "warning:attsetvalues: the value associated with (tiMainString) does not
> have an HLU representation"
>
>
> Some thing is wrong with tiMainString.  "  res1 at tiMainString  = a “  a is
> a pointer to a file. NCL has no idea how to turn that into a string.
> If you upgrade to 6.3.0 you could do the following.
> res1 at tiMainString  = getfilepath(a)  ;; needs 6.3.0!!!
> or
> res1 at tiMainString = “Some string value for a title"
>
>
> ;====
> 2.
>
> warning:csnLinesOn is not a valid resource in gsnapp_contour at this time
>
> Self explanatory, csnLineOn isn’t a resource. This is a typo. Find that
> resource and fix it.
>
>
> ;====
> 3.
>
> (0) gsn_csm_map_ce: Fatal: The resources mpMinLatF/mpLeftCornerLatF must
> be less than the resources mpMaxLatF/mpRightCornerF.
> (0) Execution halted.
>
> Again, does what it says on the tin. minLat must be less than maxLat.
> Yours are not. Switch your min/max lat resources and you’ll be set.
>
>
> ;====
> 4.
> Once those are fixed, you’ll get the following error.
>
> (0) wrf_map_overlay: Warning: This procedure is obsolete. Consider
> (0)                          using wrf_map_overlays instead.
> fatal:NhlAddOverlay: plot class mapPlotClass cannot be overlay plot member
> warning:NhlRemoveOverlay: plot not found in overlay sequence
>
>
> You can’t overlay 2 maps on top of each other.  wrf_map() and
> gsn_csm_contour_map()  so just remove the _map part and make a plain
> contour plot.
>
>
> ;====
> 5.
> Lastly, you want to transfer the mp resources to a new variable and pass
> that to wrf_map() instead of True.
> and change the order in the overlay function … map, (/contour, vector/)...
>
>
>
>
>
> On 13 Mar 2016, at 18:12, Kerwyn Texeira <ktish86 at gmail.com> wrote:
>
> Hi All,
>
> For a month now I have been having trouble overlay windbards on zoomed
> terrain with specified lat and lon in ncl. I do not want the entire
> domain plotted with winds.  If so, I would have used the multiOverlay.ncl
> script which works perfectly for many overlay for the entire domain.  No
> images are being plotted with the script below. I'm not getting any fatal
> errors. I'm using NCL version 6.2.1.   All I'm getting is the following;
> warning:wkImageFileName is not a resource in the given object
> warning:wkImageFormat is not a resource in the given object.
>
>  I would like some help with this script please.  I looked online for a
> script to help with this (overlay on zoomed in terrain with specified lat
> and lon) but I’m having trouble finding it.  Any advice will be greatly
> appreciated. Thanks, Kerwyn
>
> Script:
>
> ;*************************************************
> ; overlay_1.ncl
> ;
> ; Concepts illustrated:
> ;   - Overlaying line contours on filled contours
> ;   - Explicitly setting contour levels
> ;   - Selecting a different color map
> ;
> ;*************************************************
> ;
> ; 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
>   a = addfile("./wrfout_d03_2014-01-11_21:00:00.nc","r")
>
>   it = 0
>   hgt = wrf_user_getvar(a, "HGT", it)
>   hgt at lat2d = wrf_user_getvar(a, "XLAT", it)
>   hgt at lon2d = wrf_user_getvar(a, "XLONG", it)
>   u         = wrf_user_getvar(a, "ua", it)
>   v         = wrf_user_getvar(a, "va", it)
>   p         = wrf_user_getvar(a, "pressure", it)
>
>   u_wind    = wrf_user_intrp3d(u, p, "h", 650., 0.0, False)
>   v_wind    = wrf_user_intrp3d(v, p, "h", 650., 0.0, False)
>
>
> ;  spd       = (u_wind*u_wind + v_wind*v_wind)^(0.5)  ;m/s
> ;  spd at units = "Wind Speed"
> ;  spd at units = "m/s"
>
>
>   wks = gsn_open_wks("png","test")         ; send graphics to PNG file
>   gsn_define_colormap(wks,"BlAqGrYeOrRe")
>
>
>   res1 = True
>   res1 at mpFillOn     = False
>   res1 at mpMaxLatF    = 37.75                      ; specify the plot domain
>   res1 at mpMinLatF    = 38.20
> ;
>   res1 at mpMinLonF    = -120.00                     ;
>   res1 at mpMaxLonF    = -119.10                     ;
>   res1 at mpOutlineOn  = True                  ; turn the map outline on
>   res1 at gsnDraw      =  False                   ; do not draw the plot
>   res1 at gsnFrame     =  False                   ; do not advance the frame
>   res1 at csnLinesOn   =  True
>   res1 at tiMainString  = a
>
>   res1 at mpProjection  = "CylindricalEquidistant"    ;The default
>   res1 at pmTickMarkDisplayMode  = "Always"
>   res1 at mpDataBaseVersion      = "MediumRes"
>   res1 at mpOutlineOn            =True
>   res1 at lbOrientation          = "Vertical"
>   res1 at tiMainOffsetYF         = -0.03
>   res1 at mpShapeMode            = "FreeAspect"
>   res1 at vpWidthF               = 0.9
>   res1 at vpHeightF              = 0.9
>
> ;  res at cnLevelSelectionMode = "ExplicitLevels" ; use explicit levels
> ;  res at cnLevels             = ispan(215,265,5) ; set the contour levels
>   res1 at cnLineLabelsOn       = False            ; do not use line labels
>   res1 at cnFillOn             = True             ; color fill
>   res1 at cnLinesOn            = False            ; do not draw contour lines
> ;  res at cnFillPalette        = "BlueDarkRed18"
>
>   res1 at gsnAddCyclic         = False
>
>   map = wrf_map(wks, a, True)
>
>   contour = gsn_csm_contour_map(wks,hgt,res1)
>
>  ;------wind vectors
>  res2 = True
>  res2 at FieldTitle = "Winds"
>  res2 at NumVectors = 47
>  res2 at vcWindBarbLineThicknessF= 2.5
>  vector = wrf_vector(a, wks, u_wind, v_wind, res2)
>
>  wrf_map_overlay(wks,map,(/vector, contour/),True)
>
> end
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160314/9d661ecb/attachment.html 


More information about the ncl-talk mailing list