<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Hi Benita, </div><div class=""><br class=""></div><div class="">Multiple things.</div><div class=""> <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/spei.shtml" class="">https://www.ncl.ucar.edu/Document/Functions/Built-in/spei.shtml</a></div><div class="">At the top of the page. "<span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class=""> </span><i style="margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13px;" class="">Available in <a href="https://www.ncl.ucar.edu/prev_releases.shtml#6.3.1" style="margin: 0px; padding: 0px; text-decoration: none; color: rgb(133, 45, 133);" class="">version 6.3.1</a> and later. "</i></div><div class=""> So you can’t use the function yet, latest released version is 6.3.0. Which you’re using. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Secondly, </div><div class="">You can’t have variables and functions named the same thing. When the function spei() is included, trying to define an array named spei is going to create problems. </div><div class=""><br class=""></div><div class="">Line 16 won’t work in any language I know of. Rename your variable so it doesn’t clash with the function name. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Third. </div><div class="">Again from the top link, spei() will expect 6 arguments and you only passed 4. </div><div class=""><br class=""></div><div class="">Fourth.</div><div class="">The specific error you’re getting is because NCL is trying to subscript the spei variable using False as you passed on line 16. False isn’t a valid subscript. </div><div class=""><br class=""></div><div class="">Fifth.</div><div class="">Included edited lines below which should work once 6.3.1 is released. Though you will need to read in some temperature data as well. Read the functions documentation. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">;;;; Will need 6.3.1 </div><div class=""><br class=""></div><div class=""><div class=""> f= addfile("pr_Amon_ensemble_historical_190001-200512.nc", "r")</div><div class=""> prc = f->pr ; pr(time,lat,lon)</div><div class=""> printVarSummary(prc)</div><div class=""><br class=""></div><div class=""> prc_dimnames = getvardims(prc)</div><div class=""> time = lat= prc&$prc_dimnames(0)$<span class="Apple-tab-span" style="white-space:pre">                </span>;; get dimension coordinates without knowing dimension names</div><div class=""> lat= prc&$prc_dimnames(1)$</div><div class=""> lon= prc&$prc_dimnames(2)$</div><div class=""> </div><div class=""> dimp = dimsizes(prc) ; # monthly precipitation values</div><div class=""> ntim = dimp(0)</div><div class=""> nlat = dimp(1)</div><div class=""> mlon = dimp(2)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""> len = (/ 6, 12, 24 /)</div><div class=""> klen = dimsizes(len)</div><div class=""> spei_data = new((/klen,ntim,nlat,mlon/) ,float,prc@_FillValue)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""> t = …. ; spei needs a temperature variable same size as prc</div><div class=""><br class=""></div><div class=""> do k=0,klen-1</div><div class=""> spei_data(k,:,:,:) = spei(prc, t, len(k),lat, False, 0)</div><div class=""> end do</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Good luck, </div><div class="">Alan</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 22 Feb 2016, at 11:11, Tam, Benita (EC/EC) <<a href="mailto:benita.tam@canada.ca" class="">benita.tam@canada.ca</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Hi,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">I am trying to calculate SPEI using the SPEI function in NCL with gridded data, but when I run the script, I get an error message saying that the subscripts must be one dimensional. This is expected for data for one location, but not for gridded data. My sample script is attached (it’s basically the same as the example provided with the function).<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">NCL version: 6.3.0<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Script (see attached)<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Error message: fatal:Illegal subscript. Subscripts must be scalar or one dimensional vectors<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Url for netcdf data:<span class="Apple-converted-space"> </span></span><a href="http://ccds-dscc.ec.gc.ca/files/cmip5/pr/pr_Amon_ensemble_historical_190001-200512.nc" style="color: purple; text-decoration: underline;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">http://ccds-dscc.ec.gc.ca/files/cmip5/pr/pr_Amon_ensemble_historical_190001-200512.nc</span></a><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Thanks,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class="">Benita<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-CA" style="font-size: 10pt; font-family: Verdana, sans-serif;" class=""><o:p class=""> </o:p></span></div></div><span id="cid:7C2B85FD-11EC-4284-A606-2A722C188503@eas.albany.edu"><test_prc.ncl></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">ncl-talk mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:ncl-talk@ucar.edu" style="color: purple; text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">ncl-talk@ucar.edu</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">List instructions, subscriber options, unsubscribe:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" style="color: purple; text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></div></blockquote></div><br class=""></body></html>