[ncl-talk] problems with EOF_AAO

Dennis Shea shea at ucar.edu
Thu Jul 24 08:23:52 MDT 2014


Since

xAnom is [TIME | 360] x [Y2DEG | 91] x [X2DEG | 181]


I think

eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:),
xAnom(X2DEG|:,Y2DEG|:,TIME|:)) /)

should be

eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:),
xAnom(Y2DEG|:,X2DEG|:,TIME|:)) /)


On Wed, Jul 23, 2014 at 10:24 PM, Mary Haley <haley at ucar.edu> wrote:

> The error is telling you that you are trying to assign an array to another
> array, but they are not the same size.
>
> Here's an example code that produces the same type of error:
>
> x = random_uniform(-10,10,(/10,5/))   ; x is 10 x 5
>
> y = random_uniform(-10,10,(/5,10,20/)) ; y ix 5 x 10 x 20
>
> do i=0,4
>     y(i,:,:) = x
> end do
>
> The above script will give you an error:
>
> fatal:Dimension size mismatch on subscript #2, left-hand and right-hand
> side dimensions do not match
> fatal:["Execute.c":8578]:Execute: Error occurred at or near line 5 in file
> dim.ncl
>
> because you are trying to put a 10 x 5 array into a 10 x 20 array.
>
> Note that it mentioned "subscript #2".  This is a bit obscure, but this
> refers to the rightmost dimension of y (dimension numbering starts at 0 and
> goes left to right, so the #2 subscript is the 3rd one from the left).
>
> Your error message is complaining about subscript #1, so this is the
> second subscript in "eof_regres":
>   do ne=0,neof-1
>      eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:),
> xAnom(X2DEG|:,Y2DEG|:,TIME|:)) /)
>   end do
>
> You may want to assign the "regCoef" results to a temporary variable and
> do a printVarSummary on that variable to make sure the assignment is what
> you expect.
>
> --Mary
>
>
> On Fri, Jul 18, 2014 at 4:05 PM, Vanúcia Schumacher <
> vanucia-schumacher at hotmail.com> wrote:
>
>> Hi users,
>>
>> I'm trying to plot the EOF_AAO the example of the NCL page and returns
>> this error, if someone can help.
>>
>> fatal:Dimension size mismatch on subscript #1, left-hand and right-hand
>> side dimensions do not match
>> fatal:["Execute.c":8567]:Execute: Error occurred at or near line 90 in
>> file eof_aao.ncl
>>
>> Variable: x
>> Type: double
>> Total Size: 47436480 bytes
>>             5929560 values
>> Number of Dimensions: 3
>> Dimensions and sizes: [TIME | 360] x [Y2DEG | 91] x [X2DEG | 181]
>> Coordinates:
>>             TIME: [15.5..10934.5]
>>             Y2DEG: [ -90..  90]
>>             X2DEG: [   0.. 360]
>> Number Of Attributes: 5
>>   PLEV14_14 : 70000
>>   missing_value : -9.999999999999999e+33
>>   _FillValue : -9.999999999999999e+33
>>   long_name : ZG[GX=X2DEG,GY=Y2DEG]
>>   history : From zg.IPSL
>>
>> Variable: xClm
>> Type: double
>> Total Size: 1581216 bytes
>>             197652 values
>> Number of Dimensions: 3
>> Dimensions and sizes: [month | 12] x [Y2DEG | 91] x [X2DEG | 181]
>> Coordinates:
>>             month: [0..11]
>>             Y2DEG: [ -90..  90]
>>             X2DEG: [   0.. 360]
>> Number Of Attributes: 7
>>   _FillValue : -9.999999999999999e+33
>>   PLEV14_14 : 70000
>>   long_name : ZG[GX=X2DEG,GY=Y2DEG]
>>   history : From zg.IPSL
>>   missing_value : -9.999999999999999e+33
>>   time_op_ncl : Climatology: 30 years
>>   info : function clmMonLLT: contributed.ncl
>>
>> Variable: xAnom
>> Type: double
>> Total Size: 47436480 bytes
>>             5929560 values
>> Number of Dimensions: 3
>> Dimensions and sizes: [TIME | 360] x [Y2DEG | 91] x [X2DEG | 181]
>> Coordinates:
>>             TIME: [15.5..10934.5]
>>             Y2DEG: [ -90..  90]
>>             X2DEG: [   0.. 360]
>> Number Of Attributes: 6
>>   PLEV14_14 : 70000
>>   missing_value : -9.999999999999999e+33
>>   _FillValue : -9.999999999999999e+33
>>   long_name : ZG[GX=X2DEG,GY=Y2DEG]
>>   history : From zg.IPSL
>>   anomaly_op_ncl : Anomalies from Annual Cycle: calcMonAnomTLL:
>> contributed.ncl
>> (0)
>> (0) ZG[GX=X2DEG,GY=Y2DEG]: min=-230.4509485966109   max=295.5109758631793
>>
>> Variable: clat
>> Type: double
>> Total Size: 728 bytes
>>             91 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [Y2DEG | 91]
>> Coordinates:
>> Number Of Attributes: 4
>>   standard_name : latitude
>>   axis : Y
>>   point_spacing : even
>>   units : degrees_north
>>
>> Variable: eof
>> Type: double
>> Total Size: 131768 bytes
>>             16471 values
>> Number of Dimensions: 3
>> Dimensions and sizes: [evn | 1] x [Y2DEG | 91] x [X2DEG | 181]
>> Coordinates:
>>             evn: [1..1]
>>             Y2DEG: [ -90..  90]
>>             X2DEG: [   0.. 360]
>> Number Of Attributes: 7
>>   eval_transpose : 47025.64585057087
>>   eval : 2022102.771574547
>>   pcvar : 21.81134
>>   matrix : covariance
>>   method : transpose
>>   _FillValue : -9.999999999999999e+33
>>   long_name : EOF: Wgt: ZG[GX=X2DEG,GY=Y2DEG]
>>
>> Variable: eof_ts
>> Type: double
>> Total Size: 2880 bytes
>>             360 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [evn | 1] x [TIME | 360]
>> Coordinates:
>>             evn: [1..1]
>>             TIME: [15.5..10934.5]
>> Number Of Attributes: 4
>>   ts_mean : -5.431704468921655e-13
>>   matrix : covariance
>>   _FillValue : -9.999999999999999e+33
>>   long_name : EOF: Amplitude: Wgt: ZG[GX=X2DEG,GY=Y2DEG]
>>
>>
>> ;==============================================================
>> ; Match the AAO pattern at:
>> ;
>> http://www.cpc.ncep.noaa.gov/products/precip/CWlink/daily_ao_index/aao/aao.loading.shtml
>> ;
>> ; Use method:
>> ;
>> http://www.cpc.ncep.noaa.gov/products/precip/CWlink/daily_ao_index/aao/aao.shtml
>> ;==============================================================
>> ; Data source was Reanalysis-2 geopotential height.
>> ;
>> http://www.esrl.noaa.gov/psd/data/gridded/;data.ncep.reanalysis2.pressure.html
>>
>> ;==============================================================
>>
>> 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"
>>
>> ; ==============================================================
>> ; User defined parameters that specify region of globe and
>> ; ==============================================================
>>   latS   = -90.
>>   latN   = -20.
>>   plev   = 700
>>
>>   yrStrt = 1981
>>   yrLast = 2010
>>
>>   var    = "ZG_NEW"
>>   title  = str_upper(var)+": "+plev+"hPa "
>>
>>   ymStrt = yrStrt*100 +  1
>>   ymLast = yrLast*100 + 12
>>
>>   neof   = 1                                  ; Leading EOF only
>>   optEOF = True
>>   optETS = False
>>
>> ; ==============================================================
>> ; Open the file:
>> ; ==============================================================
>>   f      = addfile ("zg.IPSL.2g.nc", "r")
>>   x=f->ZG_NEW(:,0,:,:)
>> printVarSummary(x)
>> ; ==============================================================
>> ; compute climatology and Anomalies
>> ; ==============================================================
>>   xClm   = clmMonTLL(x)                             ; (12,lat,lon)
>>   printVarSummary(xClm)
>>
>>   xAnom  = calcMonAnomTLL ( x, xClm)                ; (time, lat,lon)
>>   printVarSummary(xAnom)
>>   printMinMax(xAnom, True)
>>
>> ; =================================================================
>> ; create weights:  sqrt(cos(lat))   [or sqrt(gw) ]
>> ; =================================================================
>>   rad    = 4.*atan(1.)/180.
>>   clat   = xAnom&Y2DEG
>>   clat   = sqrt( cos(rad*clat) )                 ; gw for gaussian grid
>>   printVarSummary(clat)
>>
>> ; =================================================================
>> ; weight all observations
>> ; =================================================================
>>   xw     = xAnom*conform(xAnom, clat, 1)
>>   copy_VarMeta(x, xw)
>>   xw at long_name = "Wgt: "+x at long_name
>>
>> ; =================================================================
>> ; Reorder (lat,lon,time) the *weighted* input data
>> ; Compute EOFs & Standardize time series
>> ; =================================================================
>>   wx     = xw(Y2DEG|:,X2DEG|:,TIME|:)                ; convenience,
>> cleaner code
>>   delete(xw)
>>
>>   eof    = eofunc_Wrap(wx, neof, optEOF)
>>   eof    = -1*eof                                ; *special* match sign
>> of CPC
>>
>>   eof_ts = eofunc_ts_Wrap (wx, eof, optETS)
>>
>>   printVarSummary( eof )                         ; examine EOF variables
>>   printVarSummary( eof_ts )
>>
>>   eof_ts = dim_standardize_n( eof_ts, 0, 1)      ; normalize
>>
>> ; =================================================================
>> ; Regress
>> ; =================================================================
>>
>>   eof_regres = eof                               ; create an array w meta
>> data
>>   do ne=0,neof-1
>>      eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:),
>> xAnom(X2DEG|:,Y2DEG|:,TIME|:)) /)   ->>>>>>>>> error this line
>>   end do
>>
>> ; =================================================================
>> ; Extract the YYYYMM from the time coordinate
>> ; associated with eof_ts [same as x&time]
>> ; =================================================================
>>
>>   yyyymm = cd_calendar(eof_ts&TIME,-1)
>>   yrfrac = yyyymm_to_yyyyfrac(yyyymm, 0.0); not used here
>>
>> ;============================================================
>> ; PLOTS
>> ;============================================================
>>   wks = gsn_open_wks("ps","eof")
>>   gsn_define_colormap(wks,"BlueWhiteOrangeRed")
>>   plot = new(neof,graphic)                ; create graphic array
>>                                           ; only needed if paneling
>> ; EOF patterns
>>
>>   res                      = True
>>   res at gsnAddCyclic         = False
>>   res at gsnDraw              = False        ; don't draw yet
>>   res at gsnFrame             = False        ; don't advance frame yet
>>   res at gsnPolar             = "SH"
>>   res at gsnSpreadColors      = True         ; spread out color table
>>
>>   res at mpFillOn             = False        ; turn off map fill
>>   res at mpMaxLatF            = latN
>>   res at mpCenterLonF         = 180
>>
>>   res at cnFillOn             = True         ; turn on color fill
>>   res at cnLinesOn            = False        ; True is default
>>   res at cnLineLabelsOn       = False        ; True is default
>>   res at lbLabelBarOn         = False        ; turn off individual lb's
>>
>>                                           ; set symmetric plot min/max
>>   symMinMaxPlt(eof_regres, 16, False, res)       ; contributed.ncl
>>   res at cnLevelSpacingF      = 5.0          ; *special* match CPC
>>
>> ; 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 gsnPaperOrientation = "portrait"   ; force portraitorbar
>>   resP at lbLabelAutoStride   = True         ; auto stride on labels
>>
>>   resP at txString            = title+": "+yrStrt+"-"+yrLast
>>
>> ;*******************************************
>> ; 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_polar(wks,eof_regres(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 = "Standardized"          ; 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            = title+": "+yrStrt+"-"+yrLast
>>
>> ; create individual plots
>>   do n=0,neof-1
>>      rts at gsnLeftString  = "EOF "+(n+1)
>>      rts at gsnRightString = sprintf("%5.1f", eof_regres at pcvar(n)) +"%"
>>      plot(n) = gsn_csm_xy (wks,yrfrac,eof_ts(n,:),rts)
>>   end do
>>   gsn_panel(wks,plot,(/neof,1/),rtsP)     ; now draw as one plot
>>
>>
>>
>> ---
>> Vanúcia Schumacher
>> Mestranda em Meteorologia - UFV
>> Meteorologista -UFPel
>> Departamento de Meteorologia Agrícola - DEA
>> Cel: (31) 9978 2522
>> DEA: (31) 3899 1890
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> 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/20140724/1b242147/attachment.html 


More information about the ncl-talk mailing list