[ncl-talk] SPI calculation

Dennis Shea shea at ucar.edu
Thu Nov 29 07:42:12 MST 2018


I do not understand: *"197207 with 3 month running avg"*


If you used:



*runlen = (/ 12, 24 /)  *

and your source array is dimensioned:
*(time,lat,lon) ==> (492,129,135)*then your SPI variable should be



*[len | 2] x [time | 492] x [lat | 129] x [lon | 135]*and your source
array is dimensioned:
* (time,lon,lat) ==> (492,135,129)*then your SPI variable should be






*[len | 2] x [time | 492] x [lon | 135] x [lat | 129]  ---     0
     1             2             3---*

 *IF* you want to perform a 3-month running average of the 12 and 24 run-lengths

nrun = 3
opt  = ?   ; read documentation
tdim = 1   ; time dimension
spi3= *runave_n_Wrap*
<http://www.ncl.ucar.edu/Document/Functions/Contributed/runave_n_Wrap.shtml>
(spi, nrun, tdim, opt)

*printVarSummary*(spi3)

========





On Thu, Nov 29, 2018 at 1:15 AM Soma Roy <somaroy892 at gmail.com> wrote:

> Hello Mary,
>
> I save the data of 'spi' as netcdf file.
>
> Where dimension of the data is like below;
> spi(135x129x492) ; (lon, lat, spi values)
>
> Now my question is if I want to select 197207 with 3 month running avg.
> Then how to select those indices from 3rd dimension of the matrix "spi"?
>
> Start yr is 1970.
>
> Please kindly inform me.
>
> Thanking you,
> Soma
>
> On Thu, Nov 29, 2018, 12:39 Oluwaseun Ilori <wilseun at gmail.com wrote:
>
>> Good day, please could you assist with the correct script of the spi
>> calculation, I'm having problem listing the result of the one I'm doing to
>> text file for further analysis on ArcGis.
>>
>> Thanks
>>
>> On Thu, Nov 29, 2018, 7:47 AM Soma Roy <somaroy892 at gmail.com wrote:
>>
>>> I fixed the issue. Please ignore my last mail.
>>>
>>> Soma
>>>
>>> On Thu, Nov 29, 2018, 11:07 Soma Roy <somaroy892 at gmail.com wrote:
>>>
>>>> Hello Mary,
>>>>
>>>> I am using the attached script. Modified it as per your hints. But
>>>> getting some errors at run time.
>>>>
>>>> printVarSummary of the data is as follows;
>>>> Variable: prc
>>>> Type: double
>>>> Total Size: 73560960 bytes
>>>>             9195120 values
>>>> Number of Dimensions: 3
>>>> Dimensions and sizes:   [time | 528] x [lat | 129] x [lon | 135]
>>>> Coordinates:
>>>>             time: [ 360..1068]
>>>>             lat: [ 6.5..38.5]
>>>>             lon: [66.5.. 100]
>>>> Number Of Attributes: 3
>>>>   _FillValue :  -999
>>>>   long_name :   GRIDDED RAINFALL
>>>>   missing_value :       -999
>>>>  : min=0   max=222.9121398925781
>>>>
>>>> I am getting the following errors;
>>>> fatal:Dimension sizes of left hand side and right hand side of
>>>> assignment do not match
>>>> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 47 in
>>>> file spi_2.ncl
>>>>
>>>> fatal:NclOneDValGetClosestIndex: Non-monotonic coordinate value being
>>>> used, can't complete coordinate subscript
>>>> fatal:Could not obtain coordinate indexes, unable to perform subscript
>>>> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 82 in
>>>> file spi_2.ncl
>>>>
>>>> Please kindly inform me how to correct it.
>>>>
>>>> Thanking you,
>>>> Soma
>>>>
>>>>
>>>> On Thu, Nov 29, 2018 at 9:51 AM Soma Roy <somaroy892 at gmail.com> wrote:
>>>>
>>>>> Thank you very much.
>>>>>
>>>>> Soma
>>>>>
>>>>> On Thu, Nov 29, 2018, 02:28 Mary Haley <haley at ucar.edu wrote:
>>>>>
>>>>>> Soma,
>>>>>>
>>>>>> The spi_2.ncl script shows you how to calculate the yyyymm variable:
>>>>>>
>>>>>>   year    = yyyymm/100
>>>>>>   yrStrt  = year(0)
>>>>>>   yrLast  = year(ntim-1)
>>>>>>   nyear   = yrLast-yrStrt+1
>>>>>>   yyyymm  = yyyymm_time(yrStrt, yrLast, "integer")
>>>>>>
>>>>>> You don't need the "date" or "yyyymm" arrays, because you already
>>>>>> have the year information. Use ispan to generate the "year" array and now
>>>>>> you can get your yyyymm and yrfac values as needed:
>>>>>>
>>>>>>   year    = ispan(1970,2010,1)
>>>>>>   ntim    = dimsizes(year)
>>>>>>   yrStrt  = year(0)
>>>>>>   yrLast  = year(ntim-1)
>>>>>>   nyear   = yrLast-yrStrt+1
>>>>>>   yyyymm  = yyyymm_time(yrStrt, yrLast, "integer")
>>>>>>   yrfrac  = (/ yyyymm_to_yyyyfrac(yyyymm, 0.0) /)
>>>>>>
>>>>>> --Mary
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Nov 28, 2018 at 1:05 PM Soma Roy <somaroy892 at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Thank you very much for the hint.
>>>>>>> I will check it.
>>>>>>>
>>>>>>> But mannualy we can't set the "date" range in the script without
>>>>>>> using CDO?
>>>>>>>
>>>>>>> Please kindly inform me.
>>>>>>>
>>>>>>> Thanking you,
>>>>>>> Soma
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Nov 29, 2018, 01:28 Guilherme Martins <jgmsantos at gmail.com
>>>>>>> wrote:
>>>>>>>
>>>>>>>> I don't know if you use climate data operators or cdo software.
>>>>>>>>
>>>>>>>> You can set the data in your file.
>>>>>>>>
>>>>>>>> Exemple
>>>>>>>>
>>>>>>>> cdo settaxis,1970-01-01,00:00:00,1mon input.nc output.nc
>>>>>>>>
>>>>>>>> Guilherme.
>>>>>>>>
>>>>>>>>
>>>>>>>> Em qua, 28 de nov de 2018 16:35, Soma Roy <somaroy892 at gmail.com
>>>>>>>> escreveu:
>>>>>>>>
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>> I am trying to calculate standadize precipitation index using
>>>>>>>>> monthly gridded dataset.
>>>>>>>>>
>>>>>>>>> Dimension of data is like below;
>>>>>>>>> Rainfall(12x41) (months x years).
>>>>>>>>>
>>>>>>>>> I am using the script from the below link;
>>>>>>>>> https://www.ncl.ucar.edu/Applications/Scripts/spi_2.ncl
>>>>>>>>>
>>>>>>>>> But in my dataset there is no variable as "date".
>>>>>>>>>
>>>>>>>>> Can we manually set the date range inside the script?
>>>>>>>>>
>>>>>>>>> I am using rainfall dataset for 1970-2010.
>>>>>>>>>
>>>>>>>>> Please kindly inform me how we can modify it over the same script.
>>>>>>>>>
>>>>>>>>> Thanking you,
>>>>>>>>> Soma
>>>>>>>>> _______________________________________________
>>>>>>>>> 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
>>>>>>>
>>>>>> _______________________________________________
>>> 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/20181129/a6a14cd0/attachment.html>


More information about the ncl-talk mailing list