subscripts do not match number of dimensions]

From: <siswanto_at_nyahnyahspammersnyahnyah>
Date: Fri Nov 27 2009 - 07:45:23 MST

 Hi everyone,..

Iam very new in using NCL. I tried to apply EOF analysis using both
controlrun1990 and freshwater hosing experiment flux004 (CCSM3 output). My
final goal is to see the changes in PDO pattern during the hosing exp.
Here I projecting EOF pattern of control run into SST flux, but I have
some bugs in the script and the error massage such as :

fatal:Number of subscripts do not match number of dimensions of
variable,(2) Subscripts used, (3) Subscripts expected
fatal:Execute: Error occurred at or near line 78 in file ProjectedEOF.ncl

Could you please give me some clues to solve this problem

Many thanks in advance
Best wishes,

Siswanto

----------------------------------------------------
My run look like this :

 University Corporation for Atmospheric Research
 NCAR Command Language Version 5.0.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.

Variable: ssta
Type: float
Total Size: 259459200 bytes
            64864800 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1001] x [lat | 180] x [lon | 360]
Coordinates:
            lat: [-89.5..89.5]
            lon: [ 0..359]
Number Of Attributes: 3
  _FillValue : -999
  missing_value : -999
  spatial_op : Bilinear remapping: 1st order: destarea: NCL:
/home/siswanto/script/map_gx3v5_to_1x1d_bilin_da_040122.nc

Variable: sstb
Type: float
Total Size: 51321600 bytes
            12830400 values
Number of Dimensions: 3
Dimensions and sizes: [time | 198] x [lat | 180] x [lon | 360]
Coordinates:
            lat: [-89.5..89.5]
            lon: [ 0..359]
Number Of Attributes: 3
  _FillValue : -999
  missing_value : -999
  spatial_op : Bilinear remapping: 1st order: destarea: NCL:
/home/siswanto/script/map_gx3v5_to_1x1d_bilin_da_040122.nc

Variable: vara
Type: float
Total Size: 21029008 bytes
            5257252 values
Number of Dimensions: 3
Dimensions and sizes: [lat | 52] x [lon | 101] x [time | 1001]
Coordinates:
            lat: [19.5..70.5]
            lon: [140..240]
Number Of Attributes: 3
  _FillValue : 1e+35
  missing_value : -999
  spatial_op : Bilinear remapping: 1st order: destarea: NCL:
/home/siswanto/script/map_gx3v5_to_1x1d_bilin_da_040122.nc

Variable: varb
Type: float
Total Size: 4159584 bytes
            1039896 values
Number of Dimensions: 3
Dimensions and sizes: [lat | 52] x [lon | 101] x [time | 198]
Coordinates:
            lat: [19.5..70.5]
            lon: [140..240]
Number Of Attributes: 3
  _FillValue : 1e+35
  missing_value : -999
  spatial_op : Bilinear remapping: 1st order: destarea: NCL:
/home/siswanto/script/map_gx3v5_to_1x1d_bilin_da_040122.nc
warning:dim_rmvmean: 1565 rightmost sections of the input array contained
all missing values
warning:dim_rmvmean: 1565 rightmost sections of the input array contained
all missing values

Variable: eofb
Type: float
Total Size: 105040 bytes
            26260 values
Number of Dimensions: 3
Dimensions and sizes: [evn | 5] x [lat | 52] x [lon | 101]
Coordinates:
            evn: [1..5]
            lat: [19.5..70.5]
            lon: [140..240]
Number Of Attributes: 7
  eval : ( 384.5412, 105.1702, 100.4963, 68.89677, 53.60186 )
  pcvar : ( 38.52052, 10.53518, 10.06699, 6.901573, 5.369441 )
  trace : 998.2763
  pcrit : 95
  eof_function : 2
  _FillValue : 1e+35
  matrix : covariance
fatal:Number of subscripts do not match number of dimensions of
variable,(2) Subscripts used, (3) Subscripts expected
fatal:Execute: Error occurred at or near line 78 in file ProjectedEOF.ncl
-----------------------------------------------------------
My script is as following :
;******************************************************************
; EOF analysis for North Pacific Region (Control projection to Flux)
; Siswanto
;******************************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" ; High Level
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" ; plot interfaces
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

begin

a =
addfile("/data03/siswanto/dataocn/regridded/annual_means/flux004_TEMP_1x1d_y_439-1439.nc","r")
  ; data file flux004
b =
addfile("/data03/siswanto/ctrl_1990/ocn/annual_means/regrided/ctrl_1990_TEMP_1x1d_y_933-1130.nc","r")
  ; data file control run
neval = 5 ; # eigenvectors to compute
ssta = a->TEMP(:,:,:) ;change variable name
sstb = b->TEMP(:,:,:) ;variable in control run
dataa = ssta(:,109:160,140:240) ;and specify the area of file a;
datab = sstb(:,109:160,140:240) ;and specify the area of file b;
printVarSummary(ssta)
printVarSummary(sstb)
;;;;;;;;;;;;;;;;;;;;;do not change for most of
cases;;;;;;;;;;;;;;;;;;;;;;;;;;
  dataa@_FillValue = 1e+35 ; missing value
  datab@_FillValue = 1e+35 ; missing value

  vara = dataa(lat|:,lon|:,time|:) ; reorder so time is last dim
  varb = datab(lat|:,lon|:,time|:) ; reorder so time is last dim
  vara@_FillValue = 1e+35 ; missing value
  varb@_FillValue = 1e+35 ; missing value
  printVarSummary(vara)
  printVarSummary(varb)

  vara=dim_rmvmean(vara) ; remove mean flux
  varb=dim_rmvmean(varb) ; remove mean control run
  dims=dimsizes(vara) ; get dim sizes for variable a
  dims=dimsizes(varb)
  lat=vara&lat ; assign latitudes to variable
  lon=vara&lon
  ;time=vara&time
  lat=varb&lat
  lon=varb&lon
  ;time=varb&time
  do nl=0,dims(0)-1 ; wgt by sqrt(cos(latitude))
    vara(nl,:,:) = vara(nl,:,:)*doubletofloat(sqrt(cos(lat(nl)*0.0174532)))
  end do
  do nl=0,dims(0)-1 ; wgt by sqrt(cos(latitude))
    varb(nl,:,:) = varb(nl,:,:)*doubletofloat(sqrt(cos(lat(nl)*0.0174532)))
  end do
  ;printVarSummary(dims)

timesa=ispan(0,1001,1)
 yrsa=ispan(0,1000,1)
timesb=ispan(0,199,1)
 yrsb=ispan(0,198,1)

;;;;;;;;;;;;;

eofa=eofcov_pcmsg_Wrap(vara,neval,95.) ; calculate eof
eofb=eofcov_pcmsg_Wrap(varb,neval,95.) ; calculate eof
eofa@_FillValue=1e+35 ; missing value
eofb@_FillValue=1e+35 ; missing value
eof_tsa = eofcov_ts_Wrap(vara,eofa) ; calculate time series of eof file a
eof_tsb = eofcov_ts_Wrap(varb,eofb) ; calculate time series of eof file b
eof_tsa@_FillValue=1e+35 ; missing value
eof_tsb@_FillValue=1e+35 ; missing value
eof_tsc = eofcov_ts_Wrap(vara,eofb) ; calculate time series of eof control
run projected into flux004 sst
eof_tsc@_FillValue=1e+35 ; missing value
;;;;;;;;;;;;;;;;;

printVarSummary(eofb)

;reconstruction data using eof

do n=0,neval-1
  eof_tsa(n,:)= eof_tsa(n,:)+eof_tsa@ts_mean(n) ; add time series mean
of eof file a
end do

xeof= eof2data(eofa, eof_tsa) ; reconstruct orriginal array
xa3 = eof2data(eofa(0:2,:),eof_tsa(0:2,:)) ; constract array using
first 3 EOF using EOF file b
xb3 = eof2data(eofb(0:2,:),eof_tsb(0:2,:))
xc3 = eof2data(eofb(0:2,:),eof_tsa(0:2,:))

; Projected control PDO mode into Flux SST

 do n=0,neval-1
  do time=0,1000
   do lat=19.5,70.5
    do lon=140,240
     PC(n,:) = eofb(n,lat,lon)*vara(lat,lon,time)
    end do
   end do
  end do
 end do
;printVarSummary(PC)

wks = gsn_open_wks("ps" ,"NorthPacific_projection_sst1") ; open ps
file

plot = new(4, "graphic")
  pres = True ; mod panel plot
  pres@gsnDraw=True
  pres@gsnFrame=True
  pres@gsnMaximize = True ; blow up plot
  pres@gsnPaperWidth=8.5
  pres@gsnPaperHeight=11.0
  pres@txString = "North Pacific 20N-70N 140E-150W EOF SSTA Projected
with Control Run"
  pres@txFontHeightF = .005
  pres@gsnPaperOrientation="portrait"
  pres@gsnPaperMargin=0.02
  pres@gsnPanelLeft = 0.02
  pres@gsnPanelRight = 0.98
  pres@gsnPanelBottom = .02
  pres@gsnPanelTop = .98
  pres@gsnPanelYWhiteSpacePercent = 2
  pres@gsnPanelXWhiteSpacePercent = 5
  gsn_panel(wks,plot3,(/4,3/),pres) ; create panel plot

  resxy = True ; xy plot mods desired
  resxy@gsnDraw = False ; don't draw yet
  resxy@gsnFrame = False ; don't advance frame
yet
  resxy@vpWidthF = 0.80 ; plot width
  resxy@vpHeightF= 0.50 ; plot height
  resxy@tiYAxisString=""
  do ne=0,3
  pres@txString = "North Pacific 20N-70N 140E-150W EOF SSTA 0-1000 Yrs
(Int 1000 Yrs) projected with control run"
    resxy@gsnLeftString = "Covariance" ; titles
    resxy@gsnCenterString = "EOF "+(ne+1)
    resxy@gsnRightString = "%Var=" + sprintf("%4.1f", eofb@pcvar(ne))
    plot(ne) = gsn_csm_xy(wks,yrsa,proj_tsc(ne,:), resxy)
  end do
  gsn_panel(wks,plot3(0:3),(/4,1/),False) ; draw: 1-across, 3-down

end

Siswanto
Climate and Environmental Physics siswanto@climate.unibe.ch
Physics Institute, University of Bern ph: +41 (0)31 631 48 71
Sidlerstrasse 5, 3012 Bern, Switzerland

Siswanto
Climate and Environmental Physics siswanto@climate.unibe.ch
Physics Institute, University of Bern ph: +41 (0)31 631 48 71
Sidlerstrasse 5, 3012 Bern, Switzerland

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Nov 27 07:45:39 2009

This archive was generated by hypermail 2.1.8 : Sun Nov 29 2009 - 20:52:58 MST