[ncl-talk] explicit contour colors not working
MIRA BERDAHL
mlosic at scarletmail.rutgers.edu
Fri Mar 10 13:35:01 MST 2017
Hi All,
I'm working with NCL v. 6.0.0. I am trying to make a 3 panel plot, with
filled contours. However, when I try to set explicit colors for the third
panel (I would like to do a Red-White-Blue theme, centered on a white
zero), I cannot get the appropriate colors plotted. I am using
con_Lev_4.ncl as an example (
http://www.ncl.ucar.edu/Applications/contourLev.shtml).
I have also tried setting this to manual levels with a max, min and
interval for the contours and using a prescribed color table, such as
hotcold_18lev, but the colormap defaults to the same as the top two panels.
I've copied my script here, and the output figure is attached.
Does anyone have ideas on how to change this third panel so the colors are
Red-White-Blue themed?
Thanks,
Mira
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/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
;************************************************
begin
;************************************************
; read in netCDF files
;************************************************
a = addfile("SLP.mon.mean.nc","r") ; sea level pressure
;************************************************
; read in zonal [u] and meridional [v] moisture transport (water vapor)
;************************************************
slp = a->PRMSL_GDS0_MSL_S123(1:648,:,:)
;***************************************************************
; geneerate a new longitude list that is monotonically increasing
;***************************************************************
g0_lat_1 = a->g0_lat_1
g0_lon_2 = a->g0_lon_2
g0_lon_2 = where(g0_lon_2.gt.180, g0_lon_2-360, g0_lon_2); change it from
220to 30 to be -110 to 30
g0_lon_2&g0_lon_2 = g0_lon_2
printVarSummary(g0_lon_2)
slp&g0_lon_2 = g0_lon_2 ; replace with 'correct' ordering
slp&g0_lon_2 = g0_lon_2
printVarSummary(slp)
; Calculate the seasonal averages.
slpDJF = month_to_season(slp, "DJF")
printVarSummary(slpDJF)
; this data starts at 1958 (this is index 0), so 1963=5, 1973=15 etc.
slpDJF_lon_hi = slpDJF((/8,10,11,16,25,26,36,37,41,47/),:,:)
slpDJF_lon_lo = slpDJF((/5,6,22,27,29,33,34,38,45,48/),:,:)
slpAvgTime_hi = dim_avg_n_Wrap(slpDJF_lon_hi,0)
slpAvgTime_lo = dim_avg_n_Wrap(slpDJF_lon_lo,0)
printVarSummary(slpAvgTime_hi)
printVarSummary(slpAvgTime_lo)
; sneaky way to copy metadata over first.
diff_slp = slpAvgTime_hi;
diff_slp = slpAvgTime_lo - slpAvgTime_hi
printVarSummary(diff_slp)
;************************************************
; create plot
;************************************************
wks = gsn_open_wks("ps","Panel_lon_SLP") ; open a ps file
gsn_define_colormap(wks,"temp1")
plot = new(3,graphic) ; create a plot array
;---- set common resources for all plots
res = True
res at gsnDraw = False ; dont draw
res at gsnFrame = False ; dont advance frame
res at cnInfoLabelOn = False ; trn off cn info label
res at gsnAddCyclic = False ; has to do with wrapping the lonitude at 0/360
res at cnFillPalette = "matlab_jet"
;;************************************************
;; Choose a subregion
;;************************************************
res at mpMaxLatF = 90 ;maximum latitude
res at mpMinLatF = 25 ;minimum latitude
res at mpMaxLonF = 30 ; max lon
res at mpMinLonF = -110 ; min lon
res at mpOutlineBoundarySets = "National"
res at mpOutlineOn = True ; turn map outline on
res at mpOutlineDrawOrder = "PostDraw"
res at mpFillOn = False ; turn map fill off
res at cnFillOn = True ; turn on color fill
res at cnLinesOn = False ; turn off contour lines
res at lbOrientation = "Vertical" ; make labels vertical
res at cnFillPalette = "BlWhRe"
res at cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
res at cnMinLevelValF = 100000 ; set min contour level
res at cnMaxLevelValF = 102400 ; set max countrou level
res at cnLevelSpacingF = 400 ; set contour spacing
plot(0) = gsn_csm_contour_map(wks,slpAvgTime_hi,res)
plot(1) = gsn_csm_contour_map(wks,slpAvgTime_lo,res)
delete(res at cnLevelSpacingF) ; delete resources before reseting
res at cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels
res at cnLevels = (/ -900, -700., -500., -300., -100., 100., 300., 500., 700.,
900./) ; set levels
res at cnFillColors = (/ 23,30,36,41,45,-1,59,63,68,74/) ; set the colors to
be used
plot(2) = gsn_csm_contour_map(wks,diff_slp,res)
;************************************************
; create panel
;************************************************
resP = False ; modify the panel plot
resP at txString = "lon - SLP"
gsn_panel(wks,(/plot/),(/3,1/),resP) ; now draw as one plot;
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170310/4612bd50/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Panel_lon_SLP.pdf
Type: application/pdf
Size: 89902 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170310/4612bd50/attachment.pdf
More information about the ncl-talk
mailing list