<div dir="ltr"><div>Since <span style="white-space:pre-wrap"></span><br><br><span style="white-space:pre-wrap"></span>xAnom is [TIME | 360] x [Y2DEG | 91] x [X2DEG | 181]<br><br></div><div><br>I think<br><br><font color="#ac193d">eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:), xAnom(X2DEG|:,Y2DEG|:,TIME|:)) /) <br>
<br></font></div><font color="#ac193d">should be<br></font><br><font color="#ac193d">eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:), xAnom(Y2DEG|:,X2DEG|:,TIME|:)) /) <br></font></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Jul 23, 2014 at 10:24 PM, Mary Haley <span dir="ltr"><<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_default" style="font-size:small">The error is telling you that you are trying to assign an array to another array, but they are not the same size.</div><div class="gmail_default" style="font-size:small">
<br></div><div class="gmail_default" style="font-size:small">Here's an example code that produces the same type of error:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">
<p><font face="courier new, monospace"><span>x = </span><span>random_uniform</span><span>(-10,10,</span><span>(/</span><span>10,5</span><span>/)</span><span>) <span>        </span></span>; x is 10 x 5 <br>
<span>y = </span><span>random_uniform</span><span>(-10,10,</span><span>(/</span><span>5,10,20</span><span>/)</span><span>)<span>        </span></span>; y ix 5 x 10 x 20 <br>
<span>do</span> i=0,4<br> y(i,:,:) = x<br>end<span> </span>do</font></p><p><font face="arial, helvetica, sans-serif">The above script will give you an error:</font></p><p><font face="courier new, monospace">fatal:Dimension size mismatch on subscript #2, left-hand and right-hand side dimensions do not match<br>
fatal:["Execute.c":8578]:Execute: Error occurred at or near line 5 in file dim.ncl</font></p><p>because you are trying to put a 10 x 5 array into a 10 x 20 array. </p><p>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).</p>
<p>Your error message is complaining about subscript #1, so this is the second subscript in "eof_regres":</p><div class=""><div style="font-size:13px"><font color="#000000" face="courier new, monospace"> do ne=0,neof-1<br>
</font></div><div style="font-size:13px"><font color="#000000" face="courier new, monospace"> eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:), xAnom(X2DEG|:,Y2DEG|:,TIME|:)) /)</font></div></div><div style="font-size:13px">
<font color="#000000" face="courier new, monospace"> end do</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font color="#000000"><br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font color="#000000">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.</font></div>
<div style="font-family:arial,sans-serif;font-size:13px"><font color="#000000"><br></font></div><div style="font-family:arial,sans-serif;font-size:13px"><font color="#000000">--Mary</font></div></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote"><div><div class="h5">On Fri, Jul 18, 2014 at 4:05 PM, Vanúcia Schumacher <span dir="ltr"><<a href="mailto:vanucia-schumacher@hotmail.com" target="_blank">vanucia-schumacher@hotmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<div><div dir="ltr"><font color="#000000" face="Calibri" size="3">Hi users,</font><div><font color="#000000" face="Calibri" size="3"><br></font></div><div><font color="#000000" face="Calibri" size="3">I'm trying to plot the EOF_AAO the example of the NCL page and returns this error, if someone can help.</font></div>
<div><br></div><div><div>fatal:Dimension size mismatch on subscript #1, left-hand and right-hand side dimensions do not match</div><div>fatal:["Execute.c":8567]:Execute: Error occurred at or near line 90 in file eof_aao.ncl</div>
<div><br></div><div><div>Variable: x</div><div>Type: double</div><div>Total Size: 47436480 bytes</div><div> 5929560 values</div><div>Number of Dimensions: 3</div><div>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[TIME | 360] x [Y2DEG | 91] x [X2DEG | 181]</div>
<div>Coordinates: </div><div> TIME: [15.5..10934.5]</div><div> Y2DEG: [ -90.. 90]</div><div> X2DEG: [ 0.. 360]</div><div>Number Of Attributes: 5</div><div> PLEV14_14 :<span style="white-space:pre-wrap">        </span>70000</div>
<div> missing_value :<span style="white-space:pre-wrap">        </span>-9.999999999999999e+33</div><div> _FillValue :<span style="white-space:pre-wrap">        </span>-9.999999999999999e+33</div><div> long_name :<span style="white-space:pre-wrap">        </span>ZG[GX=X2DEG,GY=Y2DEG]</div>
<div> history :<span style="white-space:pre-wrap">        </span>From zg.IPSL</div><div><br></div><div>Variable: xClm</div><div>Type: double</div><div>Total Size: 1581216 bytes</div><div> 197652 values</div><div>Number of Dimensions: 3</div>
<div>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[month | 12] x [Y2DEG | 91] x [X2DEG | 181]</div><div>Coordinates: </div><div> month: [0..11]</div><div> Y2DEG: [ -90.. 90]</div>
<div> X2DEG: [ 0.. 360]</div><div>Number Of Attributes: 7</div><div> _FillValue :<span style="white-space:pre-wrap">        </span>-9.999999999999999e+33</div><div> PLEV14_14 :<span style="white-space:pre-wrap">        </span>70000</div>
<div> long_name :<span style="white-space:pre-wrap">        </span>ZG[GX=X2DEG,GY=Y2DEG]</div><div> history :<span style="white-space:pre-wrap">        </span>From zg.IPSL</div><div> missing_value :<span style="white-space:pre-wrap">        </span>-9.999999999999999e+33</div>
<div> time_op_ncl :<span style="white-space:pre-wrap">        </span>Climatology: 30 years</div><div> info :<span style="white-space:pre-wrap">        </span>function clmMonLLT: contributed.ncl</div><div><br></div><div>Variable: xAnom</div>
<div>Type: double</div><div>Total Size: 47436480 bytes</div><div> 5929560 values</div><div>Number of Dimensions: 3</div><div>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[TIME | 360] x [Y2DEG | 91] x [X2DEG | 181]</div>
<div>Coordinates: </div><div> TIME: [15.5..10934.5]</div><div> Y2DEG: [ -90.. 90]</div><div> X2DEG: [ 0.. 360]</div><div>Number Of Attributes: 6</div><div> PLEV14_14 :<span style="white-space:pre-wrap">        </span>70000</div>
<div> missing_value :<span style="white-space:pre-wrap">        </span>-9.999999999999999e+33</div><div> _FillValue :<span style="white-space:pre-wrap">        </span>-9.999999999999999e+33</div><div> long_name :<span style="white-space:pre-wrap">        </span>ZG[GX=X2DEG,GY=Y2DEG]</div>
<div> history :<span style="white-space:pre-wrap">        </span>From zg.IPSL</div><div> anomaly_op_ncl :<span style="white-space:pre-wrap">        </span>Anomalies from Annual Cycle: calcMonAnomTLL: contributed.ncl</div><div>(0)<span style="white-space:pre-wrap">        </span> </div>
<div>(0)<span style="white-space:pre-wrap">        </span>ZG[GX=X2DEG,GY=Y2DEG]: min=-230.4509485966109 max=295.5109758631793</div><div><br></div><div>Variable: clat</div><div>Type: double</div><div>Total Size: 728 bytes</div>
<div> 91 values</div><div>Number of Dimensions: 1</div><div>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[Y2DEG | 91]</div><div>Coordinates: </div><div>Number Of Attributes: 4</div><div> standard_name :<span style="white-space:pre-wrap">        </span>latitude</div>
<div> axis :<span style="white-space:pre-wrap">        </span>Y</div><div> point_spacing :<span style="white-space:pre-wrap">        </span>even</div><div> units :<span style="white-space:pre-wrap">        </span>degrees_north</div><div><br>
</div><div>Variable: eof</div><div>Type: double</div><div>Total Size: 131768 bytes</div><div> 16471 values</div><div>Number of Dimensions: 3</div><div>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[evn | 1] x [Y2DEG | 91] x [X2DEG | 181]</div>
<div>Coordinates: </div><div> evn: [1..1]</div><div> Y2DEG: [ -90.. 90]</div><div> X2DEG: [ 0.. 360]</div><div>Number Of Attributes: 7</div><div> eval_transpose :<span style="white-space:pre-wrap">        </span>47025.64585057087</div>
<div> eval :<span style="white-space:pre-wrap">        </span>2022102.771574547</div><div> pcvar :<span style="white-space:pre-wrap">        </span>21.81134</div><div> matrix :<span style="white-space:pre-wrap">        </span>covariance</div>
<div> method :<span style="white-space:pre-wrap">        </span>transpose</div><div> _FillValue :<span style="white-space:pre-wrap">        </span>-9.999999999999999e+33</div><div> long_name :<span style="white-space:pre-wrap">        </span>EOF: Wgt: ZG[GX=X2DEG,GY=Y2DEG]</div>
<div><br></div><div>Variable: eof_ts</div><div>Type: double</div><div>Total Size: 2880 bytes</div><div> 360 values</div><div>Number of Dimensions: 2</div><div>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[evn | 1] x [TIME | 360]</div>
<div>Coordinates: </div><div> evn: [1..1]</div><div> TIME: [15.5..10934.5]</div><div>Number Of Attributes: 4</div><div> ts_mean :<span style="white-space:pre-wrap">        </span>-5.431704468921655e-13</div>
<div> matrix :<span style="white-space:pre-wrap">        </span>covariance</div><div> _FillValue :<span style="white-space:pre-wrap">        </span>-9.999999999999999e+33</div><div> long_name :<span style="white-space:pre-wrap">        </span>EOF: Amplitude: Wgt: ZG[GX=X2DEG,GY=Y2DEG]</div>
</div><div><br></div><div><br></div><div><div>;==============================================================</div><div>; Match the AAO pattern at: </div><div>; <a href="http://www.cpc.ncep.noaa.gov/products/precip/CWlink/daily_ao_index/aao/aao.loading.shtml" target="_blank">http://www.cpc.ncep.noaa.gov/products/precip/CWlink/daily_ao_index/aao/aao.loading.shtml</a></div>
<div>;</div><div>; Use method: </div><div>; <a href="http://www.cpc.ncep.noaa.gov/products/precip/CWlink/daily_ao_index/aao/aao.shtml" target="_blank">http://www.cpc.ncep.noaa.gov/products/precip/CWlink/daily_ao_index/aao/aao.shtml</a></div>
<div>;==============================================================</div><div>; Data source was Reanalysis-2 geopotential height.</div><div>; <a href="http://www.esrl.noaa.gov/psd/data/gridded/;data.ncep.reanalysis2.pressure.html" target="_blank">http://www.esrl.noaa.gov/psd/data/gridded/;data.ncep.reanalysis2.pressure.html</a> </div>
<div>;==============================================================</div><div><br></div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</div><div><br></div><div>; ==============================================================</div><div>; User defined parameters that specify region of globe and</div>
<div>; ==============================================================</div><div> latS = -90.</div><div> latN = -20. </div><div> plev = 700</div><div><br></div><div> yrStrt = 1981</div><div> yrLast = 2010</div>
<div>
<br></div><div> var = "ZG_NEW"</div><div> title = str_upper(var)+": "+plev+"hPa "</div><div><br></div><div> ymStrt = yrStrt*100 + 1</div><div> ymLast = yrLast*100 + 12</div><div><br>
</div><div> neof = 1 ; Leading EOF only</div><div> optEOF = True </div><div> optETS = False</div><div><br></div><div>; ==============================================================</div>
<div>; Open the file: </div><div>; ==============================================================</div><div> f = addfile ("<a href="http://zg.IPSL.2g.nc" target="_blank">zg.IPSL.2g.nc</a>", "r")</div>
<div> x=f->ZG_NEW(:,0,:,:) </div><div>printVarSummary(x) </div><div>; ==============================================================</div><div>; compute climatology and Anomalies</div><div>; ==============================================================</div>
<div> xClm = clmMonTLL(x) ; (12,lat,lon)</div><div> printVarSummary(xClm)</div><div><br></div><div> xAnom = calcMonAnomTLL ( x, xClm) ; (time, lat,lon)</div><div> printVarSummary(xAnom) </div>
<div> printMinMax(xAnom, True)</div><div><br></div><div>; =================================================================</div><div>; create weights: sqrt(cos(lat)) [or sqrt(gw) ]</div><div>; =================================================================</div>
<div> rad = 4.*atan(1.)/180.</div><div> clat = xAnom&Y2DEG </div><div> clat = sqrt( cos(rad*clat) ) ; gw for gaussian grid</div><div> printVarSummary(clat)</div><div><br></div><div>
; =================================================================</div><div>; weight all observations </div><div>; =================================================================</div><div> xw = xAnom*conform(xAnom, clat, 1)</div>
<div> copy_VarMeta(x, xw)</div><div> xw@long_name = "Wgt: "+x@long_name</div><div><br></div><div>; =================================================================</div><div>; Reorder (lat,lon,time) the *weighted* input data</div>
<div>; Compute EOFs & Standardize time series</div><div>; =================================================================</div><div> wx = xw(Y2DEG|:,X2DEG|:,TIME|:) ; convenience, cleaner code</div>
<div> delete(xw)</div><div><br></div><div> eof = eofunc_Wrap(wx, neof, optEOF) </div><div> eof = -1*eof ; *special* match sign of CPC</div><div><br></div><div> eof_ts = eofunc_ts_Wrap (wx, eof, optETS)</div>
<div><br></div><div> printVarSummary( eof ) ; examine EOF variables</div><div> printVarSummary( eof_ts )</div><div><br></div><div> eof_ts = dim_standardize_n( eof_ts, 0, 1) ; normalize</div>
<div><br></div><div>; =================================================================</div><div>; Regress</div><div>; =================================================================</div><div><br></div><div> eof_regres = eof ; create an array w meta data</div>
<div> do ne=0,neof-1</div><div> <font color="#ac193d"> eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:), xAnom(X2DEG|:,Y2DEG|:,TIME|:)) /) ->>>>>>>>> error this line</font></div><div><font color="#ac193d"> end do</font></div>
<div><br></div><div>; =================================================================</div><div>; Extract the YYYYMM from the time coordinate </div><div>; associated with eof_ts [same as x&time] </div><div>; =================================================================</div>
<div><br></div><div> yyyymm = cd_calendar(eof_ts&TIME,-1) </div><div> yrfrac = yyyymm_to_yyyyfrac(yyyymm, 0.0); not used here</div><div><br></div><div>;============================================================</div>
<div>; PLOTS</div><div>;============================================================</div><div> wks = gsn_open_wks("ps","eof")</div><div> gsn_define_colormap(wks,"BlueWhiteOrangeRed") </div>
<div> plot = new(neof,graphic) ; create graphic array</div><div> ; only needed if paneling</div><div>; EOF patterns</div><div><br></div><div> res = True </div>
<div> res@gsnAddCyclic = False </div><div> res@gsnDraw = False ; don't draw yet</div><div> res@gsnFrame = False ; don't advance frame yet</div><div> res@gsnPolar = "SH"</div>
<div> res@gsnSpreadColors = True ; spread out color table</div><div> </div><div> res@mpFillOn = False ; turn off map fill</div><div> res@mpMaxLatF = latN</div><div> res@mpCenterLonF = 180</div>
<div><br></div><div> res@cnFillOn = True ; turn on color fill</div><div> res@cnLinesOn = False ; True is default</div><div> res@cnLineLabelsOn = False ; True is default</div>
<div> res@lbLabelBarOn = False ; turn off individual lb's</div><div><br></div><div> ; set symmetric plot min/max</div><div> symMinMaxPlt(eof_regres, 16, False, res) ; contributed.ncl</div>
<div> res@cnLevelSpacingF = 5.0 ; *special* match CPC</div><div><br></div><div>; panel plot only resources</div><div><br></div><div> resP = True ; modify the panel plot</div><div>
resP@gsnMaximize = True ; large format</div><div> resP@gsnPanelLabelBar = True ; add common colorbar</div><div> resP@gsnPaperOrientation = "portrait" ; force portraitorbar</div>
<div>
resP@lbLabelAutoStride = True ; auto stride on labels</div><div><br></div><div> resP@txString = title+": "+yrStrt+"-"+yrLast</div><div><br></div><div>;*******************************************</div>
<div>; first plot</div><div>;*******************************************</div><div> do n=0,neof-1</div><div> res@gsnLeftString = "EOF "+(n+1)</div><div> res@gsnRightString = sprintf("%5.1f", eof@pcvar(n)) +"%"</div>
<div> plot(n)=gsn_csm_contour_map_polar(wks,eof_regres(n,:,:),res)</div><div> end do</div><div> gsn_panel(wks,plot,(/neof,1/),resP) ; now draw as one plot</div><div><br></div><div>;*******************************************</div>
<div>; second plot</div><div>;*******************************************</div><div>; EOF time series [bar form]</div><div><br></div><div> rts = True</div><div> rts@gsnDraw = False ; don't draw yet</div>
<div> rts@gsnFrame = False ; don't advance frame yet</div><div> rts@gsnScale = True ; force text scaling </div><div><br></div><div>; these four rtsources allow the user to stretch the plot size, and</div>
<div>; decide exactly where on the page to draw it.</div><div><br></div><div> rts@vpHeightF = 0.40 ; Changes the aspect ratio</div><div> rts@vpWidthF = 0.85</div><div> rts@vpXF = 0.10 ; change start locations</div>
<div> rts@vpYF = 0.75 ; the plot</div><div><br></div><div><br></div><div> rts@tiYAxisString = "Standardized" ; y-axis label </div><div><br></div><div> rts@gsnYRefLine = 0. ; reference line </div>
<div> rts@gsnXYBarChart = True ; create bar chart </div><div> rts@gsnAboveYRefLineColor = "red" ; above ref line fill red</div><div> rts@gsnBelowYRefLineColor = "blue" ; below ref line fill blue</div>
<div><br></div><div>; panel plot only resources</div><div> rtsP = True ; modify the panel plot</div><div> rtsP@gsnMaximize = True ; large format</div><div> rtsP@txString = title+": "+yrStrt+"-"+yrLast</div>
<div><br></div><div>; create individual plots</div><div> do n=0,neof-1</div><div> rts@gsnLeftString = "EOF "+(n+1)</div><div> rts@gsnRightString = sprintf("%5.1f", eof_regres@pcvar(n)) +"%"</div>
<div> plot(n) = gsn_csm_xy (wks,yrfrac,eof_ts(n,:),rts)</div><div> end do</div><div> gsn_panel(wks,plot,(/neof,1/),rtsP) ; now draw as one plot</div></div><div><br></div><div><br></div><br><div><font face="Comic Sans MS"><span style="line-height:17px">---</span></font></div>
<span style="line-height:17px;background-color:rgb(255,255,255)"><font style="font-size:12pt" face="Comic Sans MS" size="3"><font>Vanúcia Schumacher</font></font></span><div><span style="line-height:17px;background-color:rgb(255,255,255)"><font face="Comic Sans MS">Mestranda em Meteorologia - UFV<font style="font-size:12pt" size="3"><font><br style="line-height:17px">
Meteorologista -UFPel</font><br></font></font></span></div><div><span style="line-height:17px;background-color:rgb(255,255,255)"><font face="Comic Sans MS"><font style="font-size:12pt" size="3"><font>Departamento de Meteorologia Agrícola - DEA</font></font></font></span></div>
<div><span style="line-height:17px;background-color:rgb(255,255,255)"><font style="font-size:12pt" face="Comic Sans MS" size="3"><font>Cel: <a href="tel:%2831%29%209978%202522" value="+13199782522" target="_blank">(31) 9978 2522</a> </font></font></span></div>
<div><span style="line-height:17px;background-color:rgb(255,255,255)"><font style="font-size:12pt" face="Comic Sans MS" size="3"><font>DEA: <a href="tel:%2831%29%203899%201890" value="+13138991890" target="_blank">(31) 3899 1890</a></font></font></span></div>
</div>                                            </div></div>
<br></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>