[ncl-talk] space in annual cycle plot

Sri Nandini snandini at marum.de
Fri Jun 9 00:41:11 MDT 2017


Hello

Thank you.

The res at trXMaxF = 12 doesnt work because i cannot convert the float to string, my xlabels are in months, so i try to use "Dec" but:
fatal:NhlCvtStringToFloat:Unable to Convert "Dec"
warning:Error retrieving resource trXMaxF from args - Ignoring Arg

Attached is my script.
 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
; ==============================================================
; NAO region + Caspian region
; ==============================================================
 yrStrt = 1900
  yrLast = 1999

; ==============================================================
; Open the file: Read only the user specified period first observations then model
; ==============================================================
f = addfile("air.mon.mean.nc", "r") ;
TIME   = f->time
YYYY   = cd_calendar(TIME,-1)/100                 ; entire file
iYYYY  = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)
air  = f->air(iYYYY,:,:)
air = air(:,::-1,:)                          ; make latitudes monotonically increasing (NCL syntax)
printVarSummary(air)                                ; (time, lat,lon)
;===================================================
; compute desired global annual or monthly climatology (12,nlat,mlon)(100,nlat,nlon)               
; ==============================================================
  temp=clmMonTLL(air)  
   printVarSummary(temp) 
;==========================================================weighting
  rad    = 4.*atan(1.)/180.
 lat = f->lat
   if (typeof(lat).eq."double") then
       clat = sqrt( cos(rad*tofloat(lat)) )
   else
       clat = sqrt( cos(rad*lat) )
   end if
   copy_VarCoords(lat, clat) ; contributed
   printVarSummary(clat) 
;==========================================================compute for weighted area average over spatial lat lon
    aAve = wgt_areaave(temp(:,{36:51},{46:55}), clat({36:51}), 1.0, 0)   ; aAve(time over caspian/volga area)
   printVarSummary(aAve) 
print(aAve)
;===================================================================
f1= addfile("T2M_cam5.nc", "r") ;
TIME3   = f1->time
YYYY3   = cd_calendar(TIME3,-1)/100                 ; entire file
iYYYY3  = ind(YYYY3.ge.yrStrt .and. YYYY3.le.yrLast)
T4    = f1->TREFHT(iYYYY3,:,:)
T4=T4-273.15
printVarSummary(T4)                                ; (time, lat,lon)
T4 at _FillValue = -9.96921e+36  
  ;airf    = lonFlip( air )
  T2M=clmMonTLL(T4)  
   printVarSummary(T2M) 
;==========================================================weighting
  rad    = 4.*atan(1.)/180.
lat2=f1->lat
   if (typeof(lat2).eq."double") then
       clat2 = sqrt( cos(rad*tofloat(lat2)) )
   else
       clat2 = sqrt( cos(rad*lat2) )
   end if
   copy_VarCoords(lat2, clat2) ; contributed
   printVarSummary(clat2) 

  ; xAnom      = calcMonAnomTLL (airw, AIR)     
   ; printVarSummary(xAnom)
  t4Ave = wgt_areaave(T2M(:,{36:51},{46:55}), clat2({36:51}), 1.0, 0)   ; aAve(time over caspian/volga area)
    printVarSummary(t4Ave)
;=====================================================================
 datarray1 = new((/2,12/),double) ;
datarray1(0,:) = aAve
datarray1(1,:) = t4Ave

 time = ispan(0,11,1)              ;is integer change to scalar
time1=int2flt(time)
printVarSummary(time1)                                
;===================================================plotting
;plot that shit
;=======================================================================open a workstation
     wks_type = "png"
   wks_type at wkWidth   =  1024
   wks_type at wkHeight  =  1024
wks =  gsn_open_wks(wks_type, "annual cycle")
;-- set resources
  res = True
 res at xyExplicitLegendLabels = (/ "T2M(Wilmott)","T2M CAM5"/)
 res at xyLineThicknesses = (/  3,3/)          ; make second line thicker
 res at xyLineColors = (/ "red","blue"/)         
  res at gsnMaximize      = True
  res at gsnDraw          = False
  res at gsnFrame         = False
res at xyDashPattern  = (/0,1/)                         ; Make curves all solid
 res at xyMarkLineMode = "MarkLines"               ; Markers *and* lines
 res at xyMarkers      = (/16,16/)               ; 3 different markers
 res at xyMarkerColors := (/"black","black"/) ; 3 different colors


;res at tiMainFont      = "Helvetica"                     ; Font for title
;res at tiXAxisFont     = "Helvetica"                     ; Font for X axis label
;res at tiYAxisFont     = "Helvetica"                     ; Font for Y axis label

  res at tiYAxisFont            =  21
  res at tiYAxisFontAspectF     =  1.3
  res at tiYAxisFontHeightF     =  0.012
  res at tiXAxisFont            =  21
  res at tiXAxisFontAspectF     =  1.3
  res at tiXAxisFontHeightF     =  0.012
  res at tiXAxisOffsetYF        =  0.0
  res at tiMainOffsetYF         =  0.11
  res at tiMainString           = "T2M Annual cycle over Caspian basin"
  res at tmXBLabelFontAspectF   =  1
  res at tmXBLabelFontHeightF   =  0.012
  ;res at trYMinF                =  9.0
  res at trXMaxF                =  "Dec"
  res at gsnMaximize            =  True
  res at gsnDraw                =  False
  res at gsnFrame               =  False
  res at vpXF                   =  0.25            ;-- set viewport resourcesm
  res at vpYF                   =  0.6
  res at vpWidthF               =  0.7
  res at vpHeightF              =  0.4

  res at pmLegendDisplayMode    = "Always"
  res at lgLabelFontHeightF     =  0.01
  res at pmLegendWidthF         =  0.04            ;-- set legend width 0.3
  res at pmLegendHeightF        =  0.07            ;-- set legend height0.37 
  res at pmLegendOrthogonalPosF = -1.15            ;-- move legend up
  res at pmLegendParallelPosF   =  0.14            ;-- move legend right
  res at tiXAxisString = "Months"
  res at tiYAxisString = "~S~o~N~C"

   res at tmXBMode="Explicit"
x= ispan(0,11,1) ;setup x axis
   res at tmXBValues            =  x    ;-- bottom x-axis tickmark values
   res at tmXBLabelFontHeightF  =  0.015            ;-- x-axis font size
res at tmXBLabels            = (/ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" /) ;-- x-axis labels
  res at tmLabelAutoStride=True

;=========================================start plotting
plot = gsn_csm_xy(wks,time,datarray1,res)


  draw(plot)
  frame(wks)

end







On Jun 8, 2017 7:29:21 PM, Alan Brammer wrote:

> sorry, not trYMaxF  should be  trXMaxF  



> > On 8 Jun 2017, at 11:55, Alan Brammer <> > abrammer at albany.edu> > > wrote:
> > 
> > There’s no data after Dec so there’s nothing to plot there.  If you want Dec to be at the very edge of the plot, set res at trYMaxF = 12 ; or whatever the coordinate Dec is equal to. 
> > if you wanted the line to join back to the Jan value, you could extend the data to 13 points with the last point equal to the first point and now set trYMaxF = 13 or equivalent. 
> > 
> > e.g. (untested pseudo-code):
> > > > plot_var = array_append_record( var, var(0), 0)  
> > 

> > Seeing the resources / code you’re using would enable more precise feedback. 
> > 

> > Good luck, 
> > 
> > Alan
> > 

> > > On 8 Jun 2017, at 11:47, Sri Nandini <> > > snandini at marum.de> > > > wrote:
> > > 
> > > Hello
> > > 
> > > I have successfully plotted annual cycle. I have it attached.
> > > Could someone please tell me why there is a gap between Dec and the end of the plot? I specify my data correctly into 12months but i still cannot remove this gap.
> > > Deeply appreciated
> > > <annual cycle.png>> > > _______________________________________________
> > > 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/20170609/1aed6b77/attachment.html 


More information about the ncl-talk mailing list