[ncarg-talk] NCL Contour Plotting
Neil Weston - NOAA Federal
neil.d.weston at noaa.gov
Thu Sep 21 16:36:42 MDT 2017
NCL Users,
I have a netcdf file with 'z' data that ranges from 0 to 1.76. The NCL
script below overlays contours on a map of North America. However, I have
noticed that data from 0.5 to 1.2 are not plotted even though measurements
with values in that range do exist in the netcdf dataset. I verified this
by plotting the 'z' values in the dataset using Generic Mapping Tools (GMT)
as well as using ncdump to look at the data.
I may have overlooked something but if you have any suggestions to plot
these values, I would sincerely appreciate them. The short NCL script is
below.
Kind regards,
Neil
----------
ncdump header and NCL script below
netcdf horizontal-high {
dimensions:
x = 4601 ;
y = 3001 ;
variables:
double x(x) ;
x:long_name = "x" ;
x:actual_range = -170., -55. ;
double y(y) ;
y:long_name = "y" ;
y:actual_range = 5., 80. ;
float z(y, x) ;
z:long_name = "z" ;
z:_FillValue = NaNf ;
z:actual_range = 0.000674999959301203, 1.76100623607635 ;
// global attributes:
:Conventions = "COARDS, CF-1.5" ;
:title = "" ;
:history = "grdsample horizontal.nc -Ghorizontal-high.nc
-I0.025/0.025" ;
:description = "" ;
:GMT_version = "5.3.2 (r17593) [64-bit]" ;
----------------
begin
cdf_file = addfile("horizontal-high.nc","r")
;cdf_file = addfile("vertical-high.nc","r")
shift = cdf_file->z(:,:)
lat = cdf_file->y
lon = cdf_file->x
shift at long_name = ""
lat at long_name = ""
lon at long_name = ""
wks = gsn_open_wks("x11","overlay")
; define resources
mpres = True
mpres at gsnDraw = False
mpres at gsnFrame = False
res = mpres
cnres = mpres
; contour
cnres at cnFillOn = True
cnres at cnLinesOn = False
cnres at cnInfoLabelOn = False
cnres at cnFillPalette = "MPL_jet"
;cnres at cnFillPalette = "BkBlAqGrYeOrReViWh200"
;cnres at cnFillPalette = "horizontal"
cnres at lbOrientation = "Vertical"
;cnres at lbTitleString = "Horizontal Shift"
cnres at lbTitlePosition = "Left"
cnres at lbBoxLinesOn = False
cnres at lbTitleFontHeightF = 0.015
cnres at lbLabelFontHeightF = 0.01
cnres at sfXArray = lon
cnres at sfYArray = lat
cnres at cnLevelSelectionMode = "ManualLevels"
cnres at cnMinLevelValF = 0.0
cnres at cnMaxLevelValF = 2.0
cnres at cnLevelSpacingF = 0.1
cnres at cnLineLabelsOn = False
; make sure contours are drawn in "predraw" phase
cnres at cnFillDrawOrder = "Predraw"
; map
mpres at tiMainString = "Horizontal Shift (m)"
mpres at mpFillOn = False
mpres at mpMaxLatF = 80
mpres at mpMinLatF = 5
mpres at mpMinLonF = -170
mpres at mpMaxLonF = -55
mpres at mpOutlineOn = True
mpres at mpOutlineDrawOrder = "PostDraw"
; create but don't draw contours, maps, vectors etc.
cnid = gsn_csm_contour(wks,shift,cnres)
mpid = gsn_csm_map(wks,mpres)
; overlay contour, streamline and vector plots on the map plot
overlay(mpid,cnid)
draw(mpid)
frame(wks)
end
------------------------------------------------------------
------------------------------------------------------------------------
Dr. Neil D. Weston
Technical Director
OCS, National Ocean Service, NOAA
SSMC3, Rm 7806
1315 East West Hwy, Silver Spring, MD 20910
301-713-2801 <(301)%20713-2801> 240-278-7194 <(240)%20278-7194>
301-713-4501 <(301)%20713-4501> neil.d.weston at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncarg-talk/attachments/20170921/f7a6a320/attachment.html>
More information about the ncarg-talk
mailing list