[ncl-talk] explicit contour colors not working

MIRA BERDAHL mlosic at scarletmail.rutgers.edu
Fri Mar 10 14:28:04 MST 2017


Hi Mary,
Thanks very much for doing this test with your data and the newest version
of NCL.
I will try to download the 6.4.0 and hopefully this is more straightforward
then.
Best,
Mira

On Fri, Mar 10, 2017 at 2:16 PM, Mary Haley <haley at ucar.edu> wrote:

> Hi Mira,
>
> First, if you are truly using NCL V6.0.0, then I recommend upgrading
> because this is pretty old. Also, the cnFillPalette resource was added in
> NCL V6.1.0, so it doesn't surprise me if it's not working with NCL V6.0.0.
>
> If you actually do have NCL V6.2.0 or later, then something is wrong,
> because your script works for me with a few minor changes:
>
>
>    - I don't have a SLP.mon.mean.nc file, but I have a similar one.
>
>    - My pressure values are in mb, so I had to scale the contour levels
>    accordingly.
>
>    - I removed this line:
>
> res at cnFillColors = (/ 23,30,36,41,45,-1,59,63,68,74/)  ; set the colors
> to be used
>
> Because you shouldn't need to do this since you are setting:
>
> res at cnFillPalette = "BlWhRe"
>
> NCL will automatically span the full color map, and you should get white
> in the middle since you chose the contour levels correctly. See the
> attached image.
>
> If you want to upgrade your version of NCL, then I recommend downloading
> NCL V6.4.0.  See our release notes and download page:
>
> http://www.ncl.ucar.edu/current_release.shtml
> http://www.ncl.ucar.edu/Download/
>
> --Mary
>
>
>
> On Fri, Mar 10, 2017 at 1:35 PM, MIRA BERDAHL <mlosic at scarletmail.rutgers.
> edu> wrote:
>
>> 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/Appli
>> cations/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
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> 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/20170310/fd8b0ea6/attachment.html 


More information about the ncl-talk mailing list