[ncl-talk] Possible bug with SPEI function? -website typos
Dennis Shea
shea at ucar.edu
Mon Feb 22 10:11:37 MST 2016
The 'someone' is me.
The error is with the example(s). The hazards of duplication! I was in the
process of updating (ie: correcting) the documentation.
I will post back when all (hopefully) have been fixed.
D
On Mon, Feb 22, 2016 at 9:43 AM, Alan Brammer <abrammer at albany.edu> wrote:
> Benita,
>
> I see now that basically all these points apply to whoever wrote the
> examples and not to you.
>
> All examples on that page need to be edited. I’m guessing someone did a
> find/replace on an older version of this function and didn’t check
> thoroughly.
>
> Also mistake on my part mixed up the order of these.
> spei(prc, t, lat,len(k), False, 0)
>
>
>
> Alan.
>
>
>
>
> On 22 Feb 2016, at 11:31, Alan Brammer <abrammer at albany.edu> wrote:
>
>
> Hi Benita,
>
> Multiple things.
> https://www.ncl.ucar.edu/Document/Functions/Built-in/spei.shtml
> At the top of the page. " *Available in version 6.3.1
> <https://www.ncl.ucar.edu/prev_releases.shtml#6.3.1> and later. "*
> So you can’t use the function yet, latest released version is 6.3.0.
> Which you’re using.
>
>
> Secondly,
> 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.
>
> Line 16 won’t work in any language I know of. Rename your variable so it
> doesn’t clash with the function name.
>
>
> Third.
> Again from the top link, spei() will expect 6 arguments and you only
> passed 4.
>
> Fourth.
> 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.
>
> Fifth.
> 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.
>
>
> ;;;; Will need 6.3.1
>
> f= addfile("pr_Amon_ensemble_historical_190001-200512.nc", "r")
> prc = f->pr ; pr(time,lat,lon)
> printVarSummary(prc)
>
> prc_dimnames = getvardims(prc)
> time = lat= prc&$prc_dimnames(0)$ ;; get dimension coordinates without
> knowing dimension names
> lat= prc&$prc_dimnames(1)$
> lon= prc&$prc_dimnames(2)$
>
> dimp = dimsizes(prc) ; # monthly precipitation values
> ntim = dimp(0)
> nlat = dimp(1)
> mlon = dimp(2)
>
>
> len = (/ 6, 12, 24 /)
> klen = dimsizes(len)
> spei_data = new((/klen,ntim,nlat,mlon/) ,float,prc at _FillValue)
>
>
> t = …. ; spei needs a temperature variable same size as prc
>
> do k=0,klen-1
> spei_data(k,:,:,:) = spei(prc, t, len(k),lat, False, 0)
> end do
>
>
>
> Good luck,
> Alan
>
>
>
> On 22 Feb 2016, at 11:11, Tam, Benita (EC/EC) <benita.tam at canada.ca>
> wrote:
>
> Hi,
>
> 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).
>
> NCL version: 6.3.0
> Script (see attached)
> Error message: fatal:Illegal subscript. Subscripts must be scalar or one
> dimensional vectors
> Url for netcdf data:
> http://ccds-dscc.ec.gc.ca/files/cmip5/pr/pr_Amon_ensemble_historical_190001-200512.nc
>
> Thanks,
> Benita
>
>
> <test_prc.ncl>_______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> 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/20160222/6efe022d/attachment.html
More information about the ncl-talk
mailing list