[ncl-talk] printing spi

Dennis Shea shea at ucar.edu
Wed Apr 5 07:43:01 MDT 2017


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/20170405/ef35f154/attachment.html 


More information about the ncl-talk mailing list