Re: error in SPI Calculation

From: marziyeh dadizadeh <marzi_d65_at_nyahnyahspammersnyahnyah>
Date: Mon Jul 29 2013 - 08:46:56 MDT

Dear Anna, Thanks for your guidance! but my script has still same error and I can't eliminate it. Can you please guide me more? my script: ------------------------------------------ load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" begin    f      = addfile("precip.mon.1981-2010.ltm.v6(1).nc", "r")    prc    = f->precip     nprc   = dimsizes(prc)         len    = (/3, 6, 12, 24, 36, 48 /)    klen   =  dimsizes(len)    spi    =  new( (/klen, nprc/) , typeof(prc), prc@_FillValue)      do k=0,klen-1       spi(k,:) = dim_spi_n(prc, len(k), False, 0)   ; spi(nlen,nprc)    end do       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,:)) ) end ----------------------------------------------------------------------------- and these are script's errors: -----------------------------------------------------------------------------fatal:_NclBuildArray: each element of a literal array must have the same dimension sizes, at least one item doesn't fatal:Execute: Error occurred at or near line 13 in file spi-1.ncl ----------------------------------------------------------------------------- ________________________________ From: "Harper, Anna" <A.Harper_at_exeter.ac.uk> To: marziyeh dadizadeh <marzi_d65_at_yahoo.com> Cc: NCL <ncl-talk_at_ucar.edu> Sent: Monday, July 29, 2013 2:36 PM Subject: Re: [ncl-talk] error in SPI Calculation Dear Marzieh, I think your data prc has dimensions (time,lat,lon), not (time) as you indicate at the top of your script (this is confirmed with the printVarSummary function). So the first problem is the number of dimensions of spi: It should be 4 not 2 (klen, time, lat, lon). See example 3 on the Function page for dim_spi_n http://ncl.ucar.edu/Document/Functions/Built-in/dim_spi_n.shtml Hope that helps! Anna Anna Harper, PhD College of Engineering, Mathematics, and Physical Sciences University of Exeter Harrison Building, North Park Road Exeter, EX4 4QF Phone: +44 1392 725910 http://emps.exeter.ac.uk/mathematics/staff/ah431 On 29 Jul 2013, at 10:40, marziyeh dadizadeh <marzi_d65_at_yahoo.com>  wrote: Dear NCL users, >  >I want to calculate SPI globally. I run the codes which are provided by the ncl website, but I got some errors. Here are the codes I have run, the erroes and a header of nc file I work with( The nc file I use is a ttal monthly precipitation). >  >I coulden't understand where is the problem. Please advise me how sort it out. >Thanks in advance, >Marzieh >here is my script: >___________________________________________________________________ >load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" >load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" >load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" > > >   f      = addfile("precip.mon.1981-2010.ltm.v6.nc","r") >   prc    = f->precip                                     ; PRECIP(time)   >   printVarSummary(prc) > >   nprc   = dimsizes(prc)              ; # monthly precipitation values > >   len    = (/3, 6, 12, 24, 36, 48 /) >   klen   =  dimsizes(len) >   spi    =  new((/6,3/) ,float,prc@_FillValue) >  >   do k=0,klen-1 >      spi(k,:) = dim_spi_n(prc, len(k), False, 0)    >   end do > >   yyyymm = f->time >   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,:)) ) >  >  >  > > >file's header: >----------------------------------------------------------------------------------------- >netcdf precip.mon.1981-2010.ltm.v6 { >dimensions: >    lon = 720 ; >    lat = 360 ; >    time = 12 ; >    nbnds = 2 ; >variables: >    float lat(lat) ; >        lat:long_name = "Latitude" ; >        lat:units = "degrees_north" ; >        lat:standard_name = "latitude" ; >        lat:axis = "Y" ; >        lat:coordinate_defines = "point" ; >        lat:actual_range = 89.75f, -89.75f ; >    float lon(lon) ; >        lon:long_name = "Longitude" ; >        lon:units = "degrees_east" ; >        lon:standard_name = "longitude" ; >        lon:actual_range = 0.25f, 359.75f ; >        lon:axis = "X" ; >        lon:coordinate_defines = "point" ; >    double time(time) ; >        time:long_name = "Time" ; >        time:units = "days since 1800-1-1 00:00:00" ; >        time:actual_range = -657073., -656739. ; >        time:delta_t = "0000-01-00 00:00:00" ; >        time:standard_name = "time" ; >        time:axis = "T" ; >        time:coordinate_defines = "start" ; >        time:totalling_period = "0000-01-00 00:00:00" ; >        time:avg_period = "0030-00-00 00:00:00" ; >        time:prev_avg_period = "0000-01-00 00:00:00" ; >        time:climatology = "climatology_bounds" ; >        time:climo_period = "1981/01/01 - 2010/12/31" ; >        time:ltm_range = 66109., 77035. ; >        time:interpreted_actual_range = "0001/01/01 00:00:00 - 0001/12/01 00:00:00" ; >    double climatology_bounds(time, nbnds) ; >        climatology_bounds:long_name = "Climate Time Boundaries" ; >        climatology_bounds:units = "days since 1800-1-1 00:00:00" ; >    float precip(time, lat, lon) ; >        precip:add_offset = 0.f ; >        precip:scale_factor = 1.f ; >        precip:missing_value = -9.96921e+36f ; >        precip:units = "mm" ; >        precip:dataset = "GPCC Precipitation Full V6 (0.5x0.5)" ; >        precip:var_desc = "Precipitation" ; >        precip:level_desc = "Surface" ; >        precip:statistic = "Long Term Mean" ; >        precip:parent_stat = "Mean" ; >        precip:long_name = "GPCC Long Term Monthly total of precipitation" ; >        precip:valid_range = 0.f, 8000.f ; >        precip:actual_range = 0.f, 1924.842f ; >    short valid_yr_count(time, lat, lon) ; >        valid_yr_count:long_name = "count of non-missing values used in mean" ; >        valid_yr_count:missing_value = 32767s ; >        valid_yr_count:add_offset = 0.f ; >        valid_yr_count:scale_factor = 1.f ; > >// global attributes: >        :history = "Created 2013/03/07 by doMonthLTM" ; >        :title = "GPCC Full Data Reanalysis Version 6 0.5x0.5 Monthly Means" ; >        :convention = "CF 1.0" ; >        :Documentation = "http://www.esrl.noaa.gov/psd/data/gridded/data.gpcc.html" ; >        :Original_Source = "http://www.dwd.de/en/FundE/Klima/KLIS/int/GPCC/GPCC.htm%5Cn", >            " is the webpage and the data is at ftp://ftp.dwd.de/pub/data/gpcc/download.html" ; >        :Reference = "Users of the data sets are kindly requested to give feed back and to refer to GPCC publications on this webpage: http://www.dwd.de/bvbw/appmanager/bvbw/dwdwwwDesktop/?_nfpb=true&_pageLabel=_dwdwww_klima_umwelt_datenzentren_wzn&T12404518261141645246564gsbDocumentPath=Content%2FOeffentlichkeit%2FKU%2FKU4%2FKU42%2Fteaser__product__access.html&_state=maximized&_windowLabel=T12404518261141645246564&lastPageLabel=_dwdwww_klima_umwelt_datenzentren_wzn" ; >        :original_source = "ftp://ftp-anon.dwd.de/pub/data/gpcc/html/fulldata_download.html" ; >        :not_missing_threshold_percent = "minimum 3% values input to have non-missing output value" ; >} >  >Summary of variable: >___________________________________________________________________ > >Variable: prc >Type: float >Total Size: 12441600 bytes >3110400 values >Number of Dimensions: 3 >Dimensions and sizes: [time | 12] x [lat | 360] x [lon | 720] >Coordinates: >time: [-657073..-656739] >lat: [89.75..-89.75] >lon: [0.25..359.75] >Number Of Attributes: 13 >add_offset : 0 >scale_factor : 1 >missing_value : -9.96921e+36 >units : mm >dataset : GPCC Precipitation Full V6 (0.5x0.5) >var_desc : Precipitation >level_desc : Surface >statistic : Long Term Mean >parent_stat : Mean >long_name : GPCC Long Term Monthly total of precipitation >valid_range : ( 0, 8000 ) >actual_range : ( 0, 1924.842 ) >_FillValue : -9.96921e+36 > >  >  > >and errors: >------------------------------------------------------------------------------------------------------------------------------------ >  >fatal:Dimension size mismatch on subscript #1, left-hand and right-hand side dimensions do not match >fatal:["Execute.c":8128]:Execute: Error occurred at or near line 17 in file new-spi.ncl > >fatal:Plus: Number of dimensions do not match, can't continue >fatal:["Execute.c":8128]:Execute: Error occurred at or near line 22 in file new-spi.ncl >  >  _______________________________________________ >ncl-talk mailing list >List instructions, subscriber options, unsubscribe: >http://mailman.ucar.edu/mailman/listinfo/ncl-talk >

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jul 29 08:47:10 2013

This archive was generated by hypermail 2.1.8 : Thu Aug 01 2013 - 15:55:04 MDT