Hi All
I am having trouble with plotting my second part of my eof bar charts, I am able to plot the spatial eof graph, but then an error comes up saying
 gsn_csm_xy: Fatal: The x array is not monotonically increasing.
 Cannot draw a bar chart.
fatal:Illegal right-hand side type for assignment
fatal:Execute: Error occurred at or near line 223 in file eofprecip1.ncl
I am not sure what I am doing wrong or if there is something not agreeing in the code, but any help in this matter will be greatly appreciated :)
My code is attached below.
Kind Regards
Melissa
; ==============================================================
; eof_1.ncl
; ==============================================================
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"
begin
; ==============================================================
; User defined parameters that specify region of globe and
; ==============================================================
  latS   =  -40.
  latN   =  0.
  lonL   =  10.
  lonR   =  60.
  yrStrt = 1979
  yrLast = 2009
  season = "DJF"    ; choose Dec-Jan-Feb seasonal mean
  neof   = 3        ; number of EOFs
  optEOF = True
  optEOF@jopt<mailto:optEOF@jopt> = 0   ; This is the default; most commonly used; no need to specify.
;;optEOF@jopt = 1   ; **only** if the correlation EOF is desired
  optETS = False
; ==============================================================
; Open the file: Read only the user specified period
; ==============================================================
  f      = addfile ("/mnt/nfs2/geog/ml382/melphd/eof_sicz/cmap_eof.nc", "r")
  lat    = f->lat
  TIME   = f->time
  YYYY   = cd_calendar(TIME,-1)/100                 ; entire file
  iYYYY  = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)
  PR    = f->precip(iYYYY,:,:)
  printVarSummary(PR)                              ; variable overview
; ==============================================================
; compute desired global seasonal mean: month_to_season (contributed.ncl)
; ==============================================================
  ;PR    = month_to_season (precip, season)
  nyrs   = dimsizes(PR&time)
  ;printVarSummary(PR)
; =================================================================
; normalize data at each gridpoint by local standard deviation at each grid pt
; =================================================================
  PR = dim_standardize_n(PR,1,0)
; =================================================================
; create weights:  sqrt(cos(lat))   [or sqrt(gw) ]
; =================================================================
  ;rad    = 4.*atan(1.)/180.
  ;clat   = f->lat
  ;clat   = sqrt( cos(rad*clat) )                 ; gw for gaussian grid
; =================================================================
; weight all observations
; =================================================================
  ;wPR   = PR                                   ; copy meta data
  ;wPR   = PR*conform(PR, clat, 1)
  ;wPR@long_name = "Wgt: "+wPR@long_name<mailto:+wPR@long_name>
; =================================================================
; Reorder (lat,lon,time) the *weighted* input data
; Access the area of interest via coordinate subscripting
; =================================================================
  x      = PR({lat|latS:latN},{lon|lonL:lonR},time|:)
  eof    = eofunc_Wrap(x, neof, optEOF)
  eof_ts = eofunc_ts_Wrap (x, eof, optETS)
  printVarSummary( eof )                         ; examine EOF variables
  printVarSummary( eof_ts )
; =================================================================
; Normalize time series: Sum spatial weights over the area of used
; =================================================================
  ;dimx   = dimsizes( x )
  ;mln    = dimx(1)
  ;sumWgt = mln*sum( lat({lat|latS:latN}) )
  ;eof_ts = eof_ts/sumWgt
; =================================================================
; Extract the YYYYMM from the time coordinate
; associated with eof_ts [same as SLP&time]
; =================================================================
  yyyymm = cd_calendar(eof_ts&time,-2)/100
;;yrfrac = yyyymm_to_yyyyfrac(yyyymm, 0.0); not used here
;============================================================
; PLOTS
;============================================================
  wks = gsn_open_wks("X11","eofstd")
  gsn_define_colormap(wks,"gsltod")       ; choose colormap
  plot = new(neof,graphic)                ; create graphic array
                                          ; only needed if paneling
; EOF patterns
  res                      = True
  res@gsnDraw<mailto:res@gsnDraw>              = False        ; don't draw yet
  res@gsnFrame<mailto:res@gsnFrame>             = False        ; don't advance frame yet
;---This resource not needed in V6.1.0
  res@gsnSpreadColors<mailto:res@gsnSpreadColors>      = True         ; spread out color table
  res@gsnAddCyclic<mailto:res@gsnAddCyclic>         = False        ; plotted dataa are not cyclic
  res@mpFillOn<mailto:res@mpFillOn>             = False        ; turn off map fill
  res@mpMinLatF<mailto:res@mpMinLatF>            = latS         ; zoom in on map
  res@mpMaxLatF<mailto:res@mpMaxLatF>            = latN
  res@mpMinLonF<mailto:res@mpMinLonF>            = lonL
  res@mpMaxLonF<mailto:res@mpMaxLonF>            = lonR
  res@cnFillOn<mailto:res@cnFillOn>             = True         ; turn on color fill
  res@cnLinesOn<mailto:res@cnLinesOn>            = False        ; True is default
 ;res@cnLineLabelsOn       = False        ; True is default
  res@lbLabelBarOn<mailto:res@lbLabelBarOn>         = False        ; turn off individual lb's
 res@tmXBMode<mailto:res@tmXBMode>      = "Explicit"     ; Define own tick mark labels.
 res@tmXBValues<mailto:res@tmXBValues>    = (/ 10.,20.,30.,40.,50.,59 /)
 res@tmXBLabels<mailto:res@tmXBLabels>    = (/ "10E","20E","30E","40E","50E","60E" /)
 res@tmYLMode<mailto:res@tmYLMode>      = "Explicit"     ; Define own tick mark labels.
 res@tmYLValues<mailto:res@tmYLValues>    = (/  -39.,-30.,-20.,-10.,-1 /)
 res@tmYLLabels<mailto:res@tmYLLabels>    = (/"40S","30S","20S","10S","0" /)
  res@tmXBLabelFontHeightF<mailto:res@tmXBLabelFontHeightF> = 0.03                ; resize tick labels
  res@tmYLLabelFontHeightF<mailto:res@tmYLLabelFontHeightF> = 0.03
  ;res@pmLabelBarOrthogonalPosF = .10           ; move whole thing down
                                          ; set symmetric plot min/max
  symMinMaxPlt(eof, 16, False, res)       ; contributed.ncl
; panel plot only resources
  resP                     = True         ; modify the panel plot
  resP@gsnMaximize<mailto:resP@gsnMaximize>         = True         ; large format
  resP@gsnPanelLabelBar<mailto:resP@gsnPanelLabelBar>    = True         ; add common colorbar
  resP@lbLabelAutoStride<mailto:resP@lbLabelAutoStride>   = True         ; auto stride on labels
  resP@lbLabelFontHeightF<mailto:resP@lbLabelFontHeightF>   = 0.02
  resP@tmXBLabelFontHeightF<mailto:resP@tmXBLabelFontHeightF> = 0.03                ; resize tick labels
  resP@tmYLLabelFontHeightF<mailto:resP@tmYLLabelFontHeightF> = 0.03
  ;resP@pmLabelBarOrthogonalPosF = .10           ; move whole thing down
  yStrt                    = yyyymm(0)/100
  yLast                    = yyyymm(nyrs-1)/100
  ;resP@txString            = "Precip: "+season+": "+yStrt+"-"+yLast
; reverse the first two colors
  setvalues wks
    "wkColorMap"        : "gsltod"
    "wkForegroundColor" : (/0.,0.,0./)
    "wkBackgroundColor" : (/1.,1.,1./)
  end setvalues
res@lbLabelFontHeightF<mailto:res@lbLabelFontHeightF>   = 0.01
;*******************************************
; first plot
;*******************************************
  do n=0,neof-1
     res@gsnLeftString<mailto:res@gsnLeftString>  = "EOF "+(n+1)
     res@gsnRightString<mailto:res@gsnRightString> = sprintf("%5.1f", eof@pcvar(n<mailto:eof@pcvar(n>)) +"%"
     plot(n)=gsn_csm_contour_map_ce(wks,eof(n,:,:),res)
  end do
  gsn_panel(wks,plot,(/neof,1/),resP)     ; now draw as one plot
;*******************************************
; second plot
;*******************************************
; EOF time series  [bar form]
  rts           = True
  rts@gsnDraw<mailto:rts@gsnDraw>   = False       ; don't draw yet
  rts@gsnFrame<mailto:rts@gsnFrame>  = False       ; don't advance frame yet
  rts@gsnScale<mailto:rts@gsnScale>  = True        ; force text scaling
; these four rtsources allow the user to stretch the plot size, and
; decide exactly where on the page to draw it.
  rts@vpHeightF<mailto:rts@vpHeightF> = 0.40        ; Changes the aspect ratio
  rts@vpWidthF<mailto:rts@vpWidthF>  = 0.85
  rts@vpXF<mailto:rts@vpXF>      = 0.10        ; change start locations
  rts@vpYF<mailto:rts@vpYF>      = 0.75        ; the plot
  rts@tiYAxisString<mailto:rts@tiYAxisString> = "mm/month"                    ; y-axis label
  rts@gsnYRefLine<mailto:rts@gsnYRefLine>           = 0.              ; reference line
  rts@gsnXYBarChart<mailto:rts@gsnXYBarChart>         = True            ; create bar chart
  rts@gsnAboveYRefLineColor<mailto:rts@gsnAboveYRefLineColor> = "red"           ; above ref line fill red
  rts@gsnBelowYRefLineColor<mailto:rts@gsnBelowYRefLineColor> = "blue"          ; below ref line fill blue
; panel plot only resources
  rtsP                      = True            ; modify the panel plot
  rtsP@gsnMaximize<mailto:rtsP@gsnMaximize>          = True            ; large format
  ;rtsP@txString             = "Precip: "+season+": "+yStrt+"-"+yLast
  year = yyyymm/100
; create individual plots
  do n=0,neof-1
     rts@gsnLeftString<mailto:rts@gsnLeftString>  = "EOF "+(n+1)
     rts@gsnRightString<mailto:rts@gsnRightString> = sprintf("%5.1f", eof@pcvar(n<mailto:eof@pcvar(n>)) +"%"
     plot(n) = gsn_csm_xy (wks,year,eof_ts(n,:),rts)
  end do
  gsn_panel(wks,plot,(/neof,1/),rtsP)     ; now draw as one plot
end
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Nov  4 05:26:28 2013
This archive was generated by hypermail 2.1.8 : Mon Nov 11 2013 - 09:45:33 MST