doing eof

From: rajesh j <chithrasala_at_nyahnyahspammersnyahnyah>
Date: Mon, 5 Nov 2007 14:19:23 +0530

Hello NCL users,
When i tried to execute one script to do eof analysis with monthly sst data
NCL shows the following error.
>ncl eof.ncl
Copyright (C) 1995-2006 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 4.2.0.a033
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
(0) contributed.ncl: month_to_season12: dimension must be a multiple of
12

In my file it has 310 time points. so i rewrote the file with 300 time
points (thinking that for seasonal avaraging it need time dimension a
multiple of 12) and put into the script.

>ncl eof.ncl
Copyright (C) 1995-2006 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 4.2.0.a033
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
fatal:Assignment type mismatch, right hand side can't be coerced to type of
left hand side
fatal:Execute: Error occurred at or near line 4903 in file
$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl

fatal:Execute: Error occurred at or near line 40 in file eof.ncl

The script is as follows.

; ==============================================================
; Calculate EOFs of the Sea Level Pressure over the North Atlantic.
; ==============================================================
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 = 25.
  latN = 80.
  lonL = -70.
  lonR = 40.

  season = "JFM" ; choose Dec-Jan-Feb seasonal mean

  neof = 2 ; number of EOFs
  optEOF = False
  optETS = False

; ==============================================================
; Open the file: slp data span Jan 1979 to Dec 2003
; ==============================================================
  f = addfile ("sst.nc", "r")
  sst = f->sst
; ==============================================================
; dataset longitudes span 0=>357.5
; Because EOFs of the North Atlantic Oscillation are desired
; use the "lonFlip" (contributed.ncl) to reorder
; longitudes to span -180 to 177.5: facilitate coordinate subscripting
; ==============================================================
  sst = lonFlip( sst )
  time = f->time
; ==============================================================
; compute desired global seasonal mean: month_to_season (contributed.ncl)
; ==============================================================
  SST = month_to_season (sst,season)
  nyrs = dimsizes(SST&time)
; -----------------------------------------------------------------
; 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
; -----------------------------------------------------------------
  wSST = SST ; copy meta data
  wSST = SST*conform(SST, clat, 1)
  wSST_at_long_name = "Wgt: "+wSST_at_long_name
; -----------------------------------------------------------------
; reorder (lat,lon,time) the weighted input data
; Access the area of interest via coordinate subscripting
; -----------------------------------------------------------------
  x = wSST({lat|latS:latN},{lon|lonL:lonR},time|:)

  eof = eofunc_Wrap(x, neof, optEOF)
  eof_ts = eofunc_ts_Wrap (x, eof, optETS)
; -----------------------------------------------------------------
; Normalize time series: Sum spatial weights over the area of used
; -----------------------------------------------------------------
  dimx = dimsizes( x )
  mln = dimx(1)
  sumWgt = mln*sum( clat({lat|latS:latN}) )

  eof_ts = eof_ts/sumWgt
;------------------------------------------------------------
; PLOTS
;------------------------------------------------------------
  wks = gsn_open_wks("ps","eof")
  gsn_define_colormap(wks,"BlWhRe") ; choose colormap
  plot = new(neof,graphic) ; create graphic array
                                          ; only needed if paneling
; EOF patterns

  res = True
  res_at_gsnDraw = False ; don't draw yet
  res_at_gsnFrame = False ; don't advance frame yet
  res_at_gsnSpreadColors = True ; spread out color table
  res_at_gsnAddCyclic = False ; plotted dataa are not cyclic
 ;res_at_gsnMaximize = True ; make image as large as possible

  res_at_mpFillOn = False ; turn off map fill
  res_at_mpMinLatF = latS ; zoom in on map
  res_at_mpMaxLatF = latN
  res_at_mpMinLonF = lonL
  res_at_mpMaxLonF = lonR

  res_at_cnFillOn = True ; turn on color fill
  res_at_cnLinesOn = False ; True is default
  res_at_lbLabelBarOn = False ; turn off individual lb's

                                          ; set symmetric plot min/max
  symMinMaxPlt(eof, 16, False, res) ; contributed.ncl

; panel plot only resources
  resP = True ; modify the panel plot
  resP_at_gsnMaximize = True ; large format
  resP_at_gsnPanelLabelBar = True ; add common colorbar
  resP_at_lbLabelAutoStride = True ; auto stride on labels

  yStrt = SST&time(0)/100
  yLast = SST&time(nyrs-1)/100
  resP_at_txString = "SST: "+season+": "+yStrt+"-"+yLast

;*******************************************
; first plot
;*******************************************
  do n=0,neof-1
     res_at_gsnLeftString = "EOF "+(n+1)
     res_at_gsnRightString = sprintf("%5.1f", eof_at_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_at_gsnDraw = False ; don't draw yet
  rts_at_gsnFrame = False ; don't advance frame yet
  rts_at_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_at_vpHeightF = 0.40 ; Changes the aspect ratio
  rts_at_vpWidthF = 0.85
  rts_at_vpXF = 0.10 ; change start locations
  rts_at_vpYF = 0.75 ; the plot

  rts_at_tiYAxisString = "Pa" ; y-axis label

  rts_at_gsnYRefLine = 0. ; reference line
  rts_at_gsnXYBarChart = True ; create bar chart
  rts_at_gsnAboveYRefLineColor = "red" ; above ref line fill red
  rts_at_gsnBelowYRefLineColor = "blue" ; below ref line fill blue

; panel plot only resources
  rtsP = True ; modify the panel plot
  rtsP_at_gsnMaximize = True ; large format
  rtsP_at_txString = "SST: "+season+": "+yStrt+"-"+yLast

  year = SST&time/100

; create individual plots
  do n=0,neof-1
     rts_at_gsnLeftString = "EOF "+(n+1)
     rts_at_gsnRightString = sprintf("%5.1f", eof_at_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

I am a beginner. Can anybody give me a suggestion as to what could go wrong
in this?

Thanking you,

Rajesh

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Nov 05 2007 - 01:49:23 MST

This archive was generated by hypermail 2.2.0 : Mon Nov 05 2007 - 12:07:46 MST