[ncl-talk] unexpected white contours in color filled plot

Mark Branson mark at atmos.colostate.edu
Fri Aug 19 15:34:28 MDT 2016


Thanks, Dennis.  I modified my code to use the lat_select lines that you sent.  It’s a good reminder to use the coordinate variables in that way instead of just a simple array index.  Unfortunately, I'm still getting the white areas in the contours.  :(

I actually did have a symmetric color bar set up using those four manual settings that you sent in a previous version of the script.  I just removed them and a number of other things trying to simplify things to see if the problem would go away, and to make for something shorter to post to the mailing list.

Thanks again!
Mark

> On Aug 19, 2016, at 2:36 PM, Dennis Shea <shea at ucar.edu> wrote:
> 
> Some general commens:
> 
> [1] 
> 
> Maybe use coordinate variable (CV) for the latitude. CV are the natural coordinate of the specific dimension. You used an index (47) which corresponds to   -0.9473684210526364.
> 
> A coordinate variable uses the {...} syntax. It would look like look like:
> 
> lat_select = 0       
> wind2      = uclm(:,:,{lat_select},:)   ; this would select 0.9473684210526364 
> 
> or
> lat_select = -0.001  
> wind2      = uclm(:,:,{lat_select},:)   ; this would select -0.9473684210526364
> 
> One  advantage of using CVs is that you can use a different resolution without having to change a specific index.
> 
> [2]
> Since the sign of the zonal average conveys direction (East or West), it would be best to have a symmetric label bar. Suggest  (eg: -9 to 9). You can do this manually:
> 
>   res at cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
>   res at cnMinLevelValF       = -9.0.          ; set min contour level
>   res at cnMaxLevelValF       =  9.0           ; set max contour level
>   res at cnLevelSpacingF      =   1.           ; set contour spacing
> or, better (?)
>   symMinMaxPlt(uwind, 21, False, res)       ; contributed.ncl
> 
> http://www.ncl.ucar.edu/Document/Functions/Contributed/symMinMaxPlt.shtml <http://www.ncl.ucar.edu/Document/Functions/Contributed/symMinMaxPlt.shtml>
> 
> On Fri, Aug 19, 2016 at 10:07 AM, Mark Branson <mark at atmos.colostate.edu <mailto:mark at atmos.colostate.edu>> wrote:
> Hello.
> 
> I'm running ncl v6.2.1 and here is what I'm doing in the attached script:
> 
> 1) read in a long time series of zonal wind and surface pressure data from CAM output.
> 2) interpolate them to constant pressure levels using vinth2p.
> 3) compute long-term monthly means with clmMonTLLL.
> 4) compute the annual mean of the monthly means.
> 5) subtract off the annual mean from the monthly means.
> 6) select one latitude (the equator), and then take the mean of all longitudes.
> 6) make a color-filled height versus time cross section plot.
> 
> I get the plot (see attached), but some of the contours near the top are white.  I thought maybe it was because there were some missing or bogus values, so I inserted a check for those with the ismissing and isnan_ieee functions and it seems the data is fine.
> 
> Any ideas?
> 
> Thanks,
> Mark Branson
> 
> 
> begin
>  a = addfile("/pool/mark/spcam_nlev51/spcam_nlev51.cam.h0.0003-01.nc <http://spcam_nlev51.cam.h0.0003-01.nc/>","r")
>  hyam = a->hyam
>  hybm = a->hybm
> 
>  b = addfile("/pool/mark/spcam_nlev51/uandps.nc <http://uandps.nc/>","r")
>  u = b->U         ;u = [time | 338] x [lev | 53] x [lat | 96] x [lon | 144]
>  ps = b->PS       ;ps = [time | 338] x [lat | 96] x [lon | 144]
>  u at _FillValue = default_fillvalue("float")
> 
>  if (any(ismissing(u))) then
>    print("### original u array contains some missing data ###")
>  end if
> 
> ; interpolation variables
>  plvlM = (/ 30.,50.,70.,100.,150.,200.,250.,300.,350.,400.,450.,500.,550., \
>            600.,650.,700.,750.,800.,850./)
>  plvlM at units = "mb"
>  nplvlM = dimsizes(plvlM)
> 
>  p0     = 1000.     ; mb required by vinth2p
>  interp = 2         ; log interpolation
>  extrap = False     ; no extrapolation past psfc.
> 
>  tmp = vinth2p(u,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
>  if (typeof(tmp).eq."double") then
>    uwind1 = dble2flt(tmp)
>  else
>    uwind1 = tmp
>  end if
> 
> ; compute long-term monthly means
>  uclm = clmMonTLLL(uwind1)       ;uclm = [month | 12] x [lev_p | 33] x [lat | 96] x [lon | 144]
> 
> ; annual mean of monthly means
>  uann = dim_avg_n_Wrap(uclm,0)   ;uann = [lev_p | 33] x [lat | 96] x [lon | 144]
> 
> ; subtract off annual mean from monthly means
>  do i = 0,11
>    uclm(i,:,:,:) = (/ uclm(i,:,:,:) - uann(:,:,:) /)
>  end do
> 
>  uwind2 = uclm(:,:,47,:)              ; select the equator for the latitude
>  uwind3 = dim_avg_Wrap(uwind2)        ; mean of all longitudes
>  uwind = uwind3(lev_p|:,month|:)      ; swap the array dimensions:  month,level --> level,month
> 
>  printMinMax(uwind,False)
> 
>  if (any(ismissing(uwind))) then
>    print("### uwind array contains some missing data ###")
>  end if
>  if (any(isnan_ieee(uwind))) then
>    print("### uwind array contains some NaNs ###")
>  end if
> 
>  uwind at long_name = "SP-CAM, 51 levels, Monthly Means"
> 
>  wks   = gsn_open_wks ("eps", "test1")           ; send graphics to EPS file
>  gsn_define_colormap(wks,"BlRe")
> 
>  res                      = True                  
>  res at cnFillOn             = True                 
>  res at cnLinesOn            = True                
>  res at lbLabelBarOn         = True              
>  res at cnInfoLabelOn        = False
> 
> ; change labels for monthly mean plot
>  res at tmXBMode = "Explicit"
>  res at tmXBLabelFontHeightF = 0.015
>  res at tmXBLabels=(/"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep", \
>                   "Oct","Nov","Dec","Jan"/)
>  res at tmXBValues = ispan(0,12,1)
> 
>  plot = gsn_csm_pres_hgt (wks,uwind,res) 
> end
> 
> ** OUTPUT FROM THE SCRIPT **
> 
> /Users/mark/mmf/SPCAM5/stratosphere_gwdrag/spcam_nlev51> ncl hvstime.ncl
> Copyright (C) 1995-2014 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.2.1
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ <http://www.ncl.ucar.edu/> for more details.
> (0)	min=-9.835   max=6.77056
> 
> 
> 
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160819/9cecddce/attachment.html 


More information about the ncl-talk mailing list