Re: Plotting Colors for Missing Values

From: Melissa A Richards <Melissa.Richards_at_nyahnyahspammersnyahnyah>
Date: Wed, 6 May 2009 10:42:44 -0600

Adam,

Thank you for the suggestions. I have tried them without success. I
have streamlined my code to the most relevant parts and attached it
below. I ran this streamlined code on NCL 5.0.0 and NCL 5.1.0. The
respective plots are below (the NCL version is in the title of the
plot). You will see the difference in the colors for the missing
values (the left side of the plot). I have tried using color tables
that contain white and color tables that do not contain white.
Ironically, I have problems when the color white IS included in the
color table. If I use the color table "rainbow", I have no problems.
Let me know if any other information would be helpful.

Thank you!
Melissa

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Load necessary libraries ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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/wrf/WRF_contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

;;;;;;;;;;;;;;;;;
; Start program ;
;;;;;;;;;;;;;;;;;

begin

;;;;;
; Settings for what type of plot this is going to be
;;;;;

input_var1 = "Z_p" ; Input variable for main plot
level = "1" ; Input variable for pressure level used
model = "wrf" ; Input variable for the model used
resolution = "6.6km" ; Input variable for the model resolutioned
fff = "012"

;;;;;
; Open the file that has the plotting data
;;;;;

 wrf=addfile("2006030612-f012-cf.nc","r") ; Loading the input file in read-only

;;;;;
; Let resources be set
;;;;;

 res = True
 txres = True
 tpolyres = True
 ppolyres = True

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; For a single contouring plot ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; Get the dimensions of input_var1

  dim1 = dimsizes(dimsizes(wrf->Z_p))

 ;; Pull the corresponding data from the input file for input_var1

  if (dim1 .eq. 3) then
   dat1 = wrf->Z_p(0,:,:)
  end if
  if (dim1 .eq. 4) then
   dat1 = wrf->Z_p(0,1,:,:)
  end if
 
 ;; Grab lat and lon data

  dat1_at_lat2d=wrf->lat
  dat1_at_lon2d=wrf->lon

 ;; Get output file name and date for plotting

  date=wrf->DateTime
  sdate=""+date
  svar1="Z_p"
  smodel="wrf"
  sres="6.6km"

  yr=wrf->year
  syr=""+yr
  mo=wrf->month
  smo=""+mo
  dy=wrf->day
  sdy=""+dy
  hr=wrf->hour
  shr=""+hr

  if (dim1 .eq. 3) then
   myfilename=svar1+"-"+sdate+"-f"+fff+"-"+smodel+"-"+sres
   mydate="my_model my_res "+smo+"-"+sdy+"-"+syr+" "+shr+"UTC"
  end if
  if (dim1 .eq. 4) then
   if (level .eq. 0) then
    slevel = "1000"
   end if
   if (level .eq. 1) then
    slevel = "850"
   end if
   if (level .eq. 2) then
    slevel = "700"
   end if
   if (level .eq. 3) then
    slevel = "500"
   end if
   if (level .eq. 4) then
    slevel = "300"
   end if
   myfilename=svar1+"-"+slevel+"-"+sdate+"-f"+fff+"-"+smodel+"-"+sres
   mydate="wrf 6.6km "+slevel+"hPa "+smo+"-"+sdy+"-"+syr+" "+shr+"UTC"
  end if

  wks=gsn_open_wks("ps",myfilename)

  gsn_define_colormap(wks,"testcmap")
  ;gsn_define_colormap(wks,"rainbow")

  resmymin = 750
  resmymax = 1250
  resmaxLev = 41
     
  resmnmxint = nice_mnmxintvl(resmymin,resmymax,resmaxLev,True)
  res_at_cnLevelSelectionMode = "ManualLevels"
  res_at_cnMinLevelValF = resmnmxint(0)
  res_at_cnMaxLevelValF = resmnmxint(1)
  res_at_cnLevelSpacingF = resmnmxint(2)
  res_at_lbLabelStride = 2
  res_at_cnLineLabelInterval = 1

  res_at_gsnMaximize = True ; Maximize plot in frame
  res_at_gsnAddCyclic = False ; This is not global data
  res_at_gsnFrame = False ; Do not advance frame

  res_at_mpProjection = "Stereographic" ; Polar stereographic map projection
  res_at_mpLimitMode = "Points" ; How to zoom in on the map
  res_at_mpDataBaseVersion = "HighRes" ; Use high resolution map information

  res_at_mpCenterLonF = -180. ; Set dimensions of map to zoom in on our area
  res_at_mpCenterLatF = -77.5 ; Set dimensions of map to zoom in on our area
  res_at_mpLeftPointLatF = -75.971265 ; Set dimensions of map to zoom in on our area
  res_at_mpLeftPointLonF = 153.5854 ; Set dimentions of map to zoom in on our area
  res_at_mpRightPointLatF = -77.53824 ; Set dimentions of map to zoom in on our area
  res_at_mpRightPointLonF = -175.86005 ; Set dimentions of map to zoom in on our area
  res_at_mpTopPointLatF = -73.1 ; Set dimentions of map to zoom in on our area
  res_at_mpTopPointLonF = 171.31385 ; Set dimentions of map to zoom in on our area
  res_at_mpBottomPointLatF = -81.55926 ; Set dimentions of map to zoom in on our area
  res_at_mpBottomPointLonF = 164.4115 ; Set dimentions of map to zoom in on our area
 
  res_at_mpGridAndLimbOn = True ; Turn on lat/lon grid
  res_at_mpGridLineThicknessF = 0.5 ; Grid thickness
  res_at_mpGridLineDashPattern = 2 ; Dash pattern
  res_at_mpGridAndLimbDrawOrder = "PostDraw" ; Overlay grid on what is drawn
  res_at_mpGridLonSpacingF = 1. ; Spacing of latitude and longitude lines on grid
  res_at_mpGridLatSpacingF = 0.5 ; Spacing of latitude and longitude lines on grid
  res_at_mpGeophysicalLineThicknessF = 2.0 ; Make continent lines a bit thicker
  res_at_mpGridLineColor = "black"

  res_at_tiMainString = mydate ; Date of the plot
  res_at_tiMainSide = "Bottom" ; Put date on the bottom of the plot
  res_at_tiMainFont = 21 ; Title font (helvetica)
  res_at_tiMainFontHeightF = 0.015 ; Make title font a bit smaller

  res_at_cnLinesOn = True ; Draw contour lines also
  res_at_cnFillOn = True ; Turn on contour fill
  res_at_cnLineLabelsOn = True
  res_at_cnLineLabelFont = 21
  res_at_cnLineLabelFontHeightF = 0.01
; res_at_cnMissingValFillColor = "white"
  res_at_cnLineLabelFontColor = "black"
  res_at_cnLineColor = "black"

  res_at_gsnSpreadColors = True ; Span full color map
  res_at_gsnStringFont = "helvetica"
  res_at_gsnPaperOrientation = "Portrait"

  res_at_lbLabelAutoStride = True ; Control labelbar spacing
  res_at_lbOrientation = "Vertical" ; Vertical label bar
  res_at_lbLabelFont = 21 ; Label bar font (helvetica)
  res_at_lbLabelFontHeightF = 0.015 ; Make label bar font a bit bigger

         

  plot=gsn_csm_contour_map(wks,dat1,res)

;; Polymarker resources

; Terra Nova Bay (74.7S, 164.09E)
 tpolyres_at_gsMarkerIndex = 7 ; Triangle
 tpolyres_at_gsMarkerSizeF = 15.0 ; Set the size of the marker
 tpolyres_at_gsMarkerThicknessF = 8.0 ; Make marker thicker
 tpolyres_at_gsMarkerColor = "black"

; Pegasus (77.95S, 166.5E)
 ppolyres_at_gsMarkerIndex = 3 ; Star
 ppolyres_at_gsMarkerSizeF = 15.0 ; Set the size of the marker
 ppolyres_at_gsMarkerThicknessF = 8.0 ; Make marker thicker
 ppolyres_at_gsMarkerColor = "black"

;; Add markers for Terra Nova Bay and Pegasus
 
 gsn_polymarker(wks,plot,164.09,-74.7,tpolyres)
 gsn_polymarker(wks,plot,166.5,-77.95,ppolyres)
 
;; Label latitude and longitude grid lines

LatLabels = (/"81S","80S","79S","78S","77S","76S","75S","74S","73S"/)
LatlatLoc = (/-81,-80,-79,-78,-77,-76,-75,-74,-73/)
LatlonLoc = (/-178,-178,-178,-178,-178,-178,-178,-178,-178/)

;; Set resources for latitude and longitude text

txres_at_txFontHeightF = 14.0
txres_at_txFont = 22
txres_at_txFontColor = "black"

gsn_text(wks,plot,LatLabels,LatlonLoc,LatlatLoc,txres)

LonLabels = (/"145E","150E","155E","160E","165E","170E","175E","180E","160E","165E","170E","175E","180E"/)
LonlatLoc = (/-79.75,-79.75,-79.75,-79.75,-79.75,-79.75,-79.75,-79.75,-73.35,-73.35,-73.35,-73.35,-73.35/)
LonlonLoc = (/145,150,155,160,165,170,175,180,160,165,170,175,180/)

gsn_text(wks,plot,LonLabels,LonlonLoc,LonlatLoc,txres)

frame(wks)

end

On May 6, 2009, at 8:55 AM, Adam Phillips wrote:

> Hi Melissa,
> As far as I know, nothing has changed with regards to filling of
> missing value areas, or of filling of land areas between 5.0.0 and
> 5.1.0.
>
> Note that when you are specifying a color in any resource that
> accepts it, that NCL will use the color you specify, or if that
> exact color isn't available, it will try to pick the color that it
> thinks is closest to the color your asked for.
>
> For instance, let's say that while setting cnFillOn = True (needed
> to use cnMissingValFillColor), I set cnMissingValFillColor =
> "white". If my colormap does not have white in it, NCL will choose a
> color it thinks is closest to white, say perhaps light green.
>
> If what I said above doesn't help, respond to the group with your
> resource list along with a .jpg,.gif, etc. of your plot.
> Adam
>
>
> Melissa A Richards wrote:
>> Hello,
>> I am using "gsn_csm_contour_map" to plot various variables at
>> different pressure height levels. When I plot data for the 850hPa
>> level, I have a large area of missing values (due to mountainous
>> terrain). When I ran my script on NCL 5.0.0 the plot showed the
>> missing values correctly, by plotting the background white with
>> the continent outlines and lat/lon gridlines plotted in black.
>> When I run the same exact script on NCL 5.1.0, the missing values
>> are filled with a blue/gray color. Was there something changed
>> between NCL 5.0.0 and NCL 5.1.0 that would effect this? I checked
>> the release notes and did not see anything.
>> A few other notes...
>> It seems that in 5.1.0 it chooses a color from the color table to
>> fill in the missing values with (the blue/gray color is part of my
>> color table). I attempted to use res_at_cnMissingValFillColor set to
>> "white" and the missing values were still plotted with the blue/
>> gray color. I attempted to run the same plot using a standard NCL
>> color table. The missing values were plotted correctly when I
>> used the "rainbow" color table. When I used the "testcmap" color
>> table, it plotted the missing values with a light green color. It
>> seems that I am having trouble with the missing values if a color
>> table contains "white" within the color table. Am I missing
>> something?
>> Thanks!
>> Melissa
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> --
> --------------------------------------------------------------
> Adam Phillips asphilli_at_ucar.edu
> National Center for Atmospheric Research tel: (303) 497-1726
> ESSL/CGD/CAS fax: (303) 497-1333
> P.O. Box 3000
> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

plot_5.0.0.jpg plot_5.1.0.jpg
Received on Wed May 06 2009 - 10:42:44 MDT

This archive was generated by hypermail 2.2.0 : Wed May 06 2009 - 16:48:59 MDT