[ncl-talk] printing spi

Dennis Shea shea at ucar.edu
Thu Apr 6 12:00:59 MDT 2017


I do not understand the question.

https://www.ncl.ucar.edu/Applications/

Under Data Analysis: Click 'Standardized Precipitation Index'

See: Example 1

You need to make the same array changes as in the print.

EG:     spi(0,:,)==> spi(0,:,nl,ml)


On Thu, Apr 6, 2017 at 1:22 AM, Dawit Abebe <dawit.kan at gmail.com> wrote:

> Hello All,
>
> Thanks to Dennis, I am able to appreciate the power of NCL computing SPI.
> My next step is to produce
>  (1) a time serious XY plot for seasonal (SPI-3 ending in May and ending
> in November), annual (SPI-12) and multi annual (SPI-24 and SPI-36 months)
> and
> (2) Shape map of selected annual SPI with extremely sever drought events
> to examine the spatial characteristics of the drought.
>
> I’m not asking for help before I try by my self (thanks Dennis for the
> push to do this). However, I need a quick comment how I should proceed from
> the last step producing the SPI output, which was printing:
>
> print(yyyymm+sprintf("%8.2f", prc(:,nl,ml))   \
>
>
>                 +sprintf("%8.2f", spi(0,:,nl,ml))+sprintf("%8.2f",
> spi(1,:,nl,ml)) \
>
>                 +sprintf("%8.2f", spi(2,:,nl,ml))+sprintf("%8.2f",
> spi(3,:,nl,ml)) \
>
>                 +sprintf("%8.2f", spi(4,:,nl,ml))+sprintf("%8.2f",
> spi(5,:,nl,ml)) \
>                 +sprintf("%8.2f", spi(6,:,nl,ml)))
>
> Do I need to go through this and then start with plot parameters, or I
> can continue with plot parameters without the print command?
>
> Thank you so much
> Dawit
>
>
>
>
> On Apr 5, 2017, at 4:43 PM, Dennis Shea <shea at ucar.edu> wrote:
>
> The error mesages is telling you the exact problem:
>    fatal:Plus: Number of dimensions do not match, can't continue
>
> spi has 4-dimensions:
>    [len | 7] x [time | 1368] x [lat | 4] x [lon | 9]
>
> prc has 3-dimensions
>    [time | 1368] x [lat | 4] x [lon | 9]
>
> yyyymm has 1-dimension
>    [time | 1368]
>
> ==============
> The print statement you used was copied from:
>     https://www.ncl.ucar.edu/Document/Functions/Built-in/dim_spi_n.shtml
>     Example 2
> That was working upon a single time series prc[*]
>
>
>
> You have a 4-D array. *You* must make the appropriate changed to handle
> your situation.
> The eamples are not generic to all dimensions.
>
>    nlat=4
>    mlon=9
>
>    do nl=0,nlat-1
>       do ml=0,mlon-1
>        print("------------------------------------------------")
>
> print(yyyymm+sprintf("%8.2f", prc(:,nl,ml))   \
>
>                 +sprintf("%8.2f", spi(0,:,nl,ml))+sprintf("%8.2f",
> spi(1,:,nl,ml)) \
>                 +sprintf("%8.2f", spi(2,:,nl,ml))+sprintf("%8.2f",
> spi(3,:,nl,ml)) \
>                 +sprintf("%8.2f", spi(4,:,nl,ml))+sprintf("%8.2f",
> spi(5,:,nl,ml)) \
>                 +sprintf("%8.2f", spi(6,:,nl,ml)))
>
>     end do
>   en do
>
> On Wed, Apr 5, 2017 at 2:20 AM, Dawit Abebe <dawit.kan at gmail.com> wrote:
>
>> Hello all,
>>
>> Kindly help me to fix my problem with printing SPI. I pasted below first
>> the return of printVarSummary(spi), which seems okay. However, my attempt
>> to print  the output (text in blue) did not work.  What was wrong?
>>
>> Greatly appreciate your help.
>>
>> Dawit
>>
>> …………………………………….
>>
>> copy_VarCoords(prc,spi(0,:,:,:))
>> spi at long_name = "SPI"
>> spi!0         = "len"
>> spi&len       =  len
>>
>> printVarSummary(spi)
>>
>>
>> Variable: spi
>> Type: double
>> Total Size: 2757888 bytes
>>             344736 values
>> Number of Dimensions: 4
>> Dimensions and sizes: [len | 7] x [time | 1368] x [lat | 4] x [lon | 9]
>> Coordinates:
>>             len: [1..36]
>>             time: [ 380..41987]
>>             lat: [3.75..5.25]
>>             lon: [36.75..40.75]
>> Number Of Attributes: 2
>>   long_name : SPI
>>   _FillValue : -999
>>
>>
>> yyyymm = cd_calendar(f->time, -1)
>>
>> print(yyyymm+sprintf("%8.2f", prc)   \
>>                 +sprintf("%8.2f", spi(0,:))+sprintf("%8.2f", spi(1,:)) \
>>                 +sprintf("%8.2f", spi(2,:))+sprintf("%8.2f", spi(3,:)) \
>>                 +sprintf("%8.2f", spi(4,:))+sprintf("%8.2f", spi(5,:)) \
>>                 +sprintf("%8.2f", spi(6,:)))
>> fatal:Plus: Number of dimensions do not match, can't continue
>> fatal:["Execute.c":8638]:Execute: Error occurred at or near line 37
>>
>>
>>
>> _______________________________________________
>> 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/20170406/aaea9039/attachment.html 


More information about the ncl-talk mailing list