<div dir="ltr"><div dir="ltr"><b>Please</b> read the File IO on netCDF. As noted in the documentation, the following is the most commonly used approach.</div><div dir="ltr"><br></div><div dir="ltr"> <a href="http://www.ncl.ucar.edu/Applications/method_1.shtml">http://www.ncl.ucar.edu/Applications/method_1.shtml</a></div><div dir="ltr"><br></div><div dir="ltr">===</div><div dir="ltr"><pre> <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/system.shtml"><strong>system</strong></a>("/bin/rm -f SPI.nc") ; remove any pre-existing file
ncdf = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml"><strong>addfile</strong></a>("SPI.nc" ,"c") ; open output netCDF file
;===================================================================
; create global attributes of the file (optional)
;===================================================================
fAtt = True ; assign file attributes
fAtt@title = "Standardized Precipitation Index"
fAtt@Conventions = "None"
fAtt@creation_date = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml"><strong>systemfunc</strong></a> ("date")
<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/fileattdef.shtml"><strong>fileattdef</strong></a>( ncdf, fAtt ) ; copy file attributes
;===================================================================
; output variables directly; NCL will call appropriate functions
; to write the meta data associated with each variable
;===================================================================
ncdf->SPI = spi ; (len,time,lat,lon)</pre></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018 at 10:29 PM Soma Roy <<a href="mailto:somaroy892@gmail.com">somaroy892@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Hello Mary,<div dir="auto"><br></div><div dir="auto">I just want to know that what is the more efficient way to save the variable "spi" as a netcdf for multiple runlen?</div><div dir="auto"><br></div><div dir="auto">Say 3,6,9 and 12 or 12 and 24 as mentioned in the spi_2.ncl script.</div><div dir="auto"><br></div><div dir="auto">I want to save all runlen in a single netcdf file in single run time.</div><div dir="auto"><br></div><div dir="auto">Please kindly inform me.</div><div dir="auto"><br></div><div dir="auto">Thanking you,</div><div dir="auto">Soma</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018, 20:12 Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><pre>I do not understand: <b>"197207 with 3 month running avg"</b></pre><pre><br>If you used:<br><br><b>runlen = (/ 12, 24 /) <br><br></b></pre><pre>and your source array is dimensioned: <b>(time,lat,lon) ==> (492,129,135)<br></b>then your SPI variable should be<b><br><br><span style="color:rgb(255,0,0)">[len | 2]</span> x <span style="color:rgb(0,0,255)">[time | 492]</span> x [lat | 129] x [lon | 135]<br><br></b>and your source array is dimensioned:<b> <b>(time,lon,lat) ==> (492,135,129)<br></b></b>then your SPI variable should be<b><b><br><br><span style="color:rgb(255,0,0)">[len | 2]</span> x <span style="color:rgb(0,0,255)">[time | 492]</span> x <b><b>[lon | 135] x </b></b>[lat | 129] <br><br>---<br> <span style="color:rgb(255,0,0)">0</span> <span style="color:rgb(0,0,255)">1</span> 2 3<br>---<br></b></b></pre><pre><b><b> </b></b>*IF* you want to perform a 3-month running average of the 12 and 24 run-lengths<br><br></pre><pre>nrun = 3<br>opt = ? ; read documentation <br>tdim = 1 ; time dimension<br>spi3= <a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/runave_n_Wrap.shtml" rel="noreferrer" target="_blank"><strong>runave_n_Wrap</strong></a> (spi, nrun, tdim, opt)<br></pre><pre><b>printVarSummary</b>(spi3)<br><br>========<br></pre><pre><br></pre><pre><b><b><br><br></b></b></pre></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018 at 1:15 AM Soma Roy <<a href="mailto:somaroy892@gmail.com" rel="noreferrer" target="_blank">somaroy892@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto">Hello Mary,</div><div dir="auto"><br></div>I save the data of 'spi' as netcdf file.<div dir="auto"><br></div><div dir="auto">Where dimension of the data is like below;</div><div dir="auto">spi(135x129x492) ; (lon, lat, spi values)</div><div dir="auto"><br></div><div dir="auto">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"?</div><div dir="auto"><br></div><div dir="auto">Start yr is 1970.</div><div dir="auto"><br></div><div dir="auto">Please kindly inform me.</div><div dir="auto"><br></div><div dir="auto">Thanking you,</div><div dir="auto">Soma</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018, 12:39 Oluwaseun Ilori <<a href="mailto:wilseun@gmail.com" rel="noreferrer" target="_blank">wilseun@gmail.com</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">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.<div dir="auto"><br></div><div dir="auto">Thanks</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018, 7:47 AM Soma Roy <<a href="mailto:somaroy892@gmail.com" rel="noreferrer noreferrer" target="_blank">somaroy892@gmail.com</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">I fixed the issue. Please ignore my last mail.<div dir="auto"><br></div><div dir="auto">Soma</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018, 11:07 Soma Roy <<a href="mailto:somaroy892@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">somaroy892@gmail.com</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello Mary,<div><br></div><div>I am using the attached script. Modified it as per your hints. But getting some errors at run time. </div><div><br></div><div>printVarSummary of the data is as follows;</div><div><div>Variable: prc</div><div>Type: double</div><div>Total Size: 73560960 bytes</div><div> 9195120 values</div><div>Number of Dimensions: 3</div><div>Dimensions and sizes: [time | 528] x [lat | 129] x [lon | 135]</div><div>Coordinates:</div><div> time: [ 360..1068]</div><div> lat: [ 6.5..38.5]</div><div> lon: [66.5.. 100]</div><div>Number Of Attributes: 3</div><div> _FillValue : -999</div><div> long_name : GRIDDED RAINFALL</div><div> missing_value : -999</div><div> : min=0 max=222.9121398925781</div></div><div><br></div><div>I am getting the following errors;</div><div><div>fatal:Dimension sizes of left hand side and right hand side of assignment do not match</div><div>fatal:["Execute.c":8640]:Execute: Error occurred at or near line 47 in file spi_2.ncl</div><div><br></div><div>fatal:NclOneDValGetClosestIndex: Non-monotonic coordinate value being used, can't complete coordinate subscript</div><div>fatal:Could not obtain coordinate indexes, unable to perform subscript</div><div>fatal:["Execute.c":8640]:Execute: Error occurred at or near line 82 in file spi_2.ncl</div></div><div><br></div><div>Please kindly inform me how to correct it.</div><div><br></div><div>Thanking you,</div><div>Soma</div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018 at 9:51 AM Soma Roy <<a href="mailto:somaroy892@gmail.com" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">somaroy892@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Thank you very much. <div dir="auto"><br></div><div dir="auto">Soma</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018, 02:28 Mary Haley <<a href="mailto:haley@ucar.edu" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">haley@ucar.edu</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Soma,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The spi_2.ncl script shows you how to calculate the yyyymm variable:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"> year = yyyymm/100</font></div><div class="gmail_default"><font face="monospace, monospace"> yrStrt = year(0)</font></div><div class="gmail_default"><font face="monospace, monospace"> yrLast = year(ntim-1)</font></div><div class="gmail_default"><font face="monospace, monospace"> nyear = yrLast-yrStrt+1</font></div><div class="gmail_default"><font face="monospace, monospace"> yyyymm = yyyymm_time(yrStrt, yrLast, "integer") </font></div><div class="gmail_default"><br></div><div class="gmail_default">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:</div><div class="gmail_default"><br></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"> year = ispan(1970,2010,1)</font></div><div class="gmail_default"><font face="monospace, monospace"> ntim = dimsizes(year)</font></div><div class="gmail_default"><font face="monospace, monospace"> yrStrt = year(0)</font></div><div class="gmail_default"><font face="monospace, monospace"> yrLast = year(ntim-1)</font></div><div class="gmail_default"><font face="monospace, monospace"> nyear = yrLast-yrStrt+1</font></div><div class="gmail_default"><font face="monospace, monospace"> yyyymm = yyyymm_time(yrStrt, yrLast, "integer") </font></div></div><div class="gmail_default"><font face="monospace, monospace"> yrfrac = (/ yyyymm_to_yyyyfrac(yyyymm, 0.0) /)</font></div><div class="gmail_default"><br></div><div class="gmail_default">--Mary</div><div class="gmail_default"><br></div><div class="gmail_default"><br></div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Nov 28, 2018 at 1:05 PM Soma Roy <<a href="mailto:somaroy892@gmail.com" rel="noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">somaroy892@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto">Thank you very much for the hint.</div><div dir="auto">I will check it.</div><div dir="auto"><br></div><div dir="auto">But mannualy we can't set the "date" range in the script without using CDO?</div><div dir="auto"><br></div><div dir="auto">Please kindly inform me.</div><div dir="auto"><br></div><div dir="auto">Thanking you,</div><div dir="auto">Soma</div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018, 01:28 Guilherme Martins <<a href="mailto:jgmsantos@gmail.com" rel="noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">jgmsantos@gmail.com</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">I don't know if you use climate data operators or cdo software.<div dir="auto"><br></div><div dir="auto">You can set the data in your file.</div><div dir="auto"><br></div><div dir="auto">Exemple</div><div dir="auto"><br></div><div dir="auto">cdo settaxis,1970-01-01,00:00:00,1mon <a href="http://input.nc" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">input.nc</a> <a href="http://output.nc" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">output.nc</a></div><div dir="auto"><br></div><div dir="auto">Guilherme.</div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr">Em qua, 28 de nov de 2018 16:35, Soma Roy <<a href="mailto:somaroy892@gmail.com" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">somaroy892@gmail.com</a> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto">Hello,</div><div dir="auto"><br></div><div dir="auto">I am trying to calculate standadize precipitation index using monthly gridded dataset.</div><div dir="auto"><br></div><div dir="auto">Dimension of data is like below;</div><div dir="auto">Rainfall(12x41) (months x years).</div><div dir="auto"><br></div><div dir="auto">I am using the script from the below link;</div><a href="https://www.ncl.ucar.edu/Applications/Scripts/spi_2.ncl" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">https://www.ncl.ucar.edu/Applications/Scripts/spi_2.ncl</a><div dir="auto"><br></div><div dir="auto">But in my dataset there is no variable as "date".</div><div dir="auto"><br></div><div dir="auto">Can we manually set the date range inside the script?</div><div dir="auto"><br></div><div dir="auto">I am using rainfall dataset for 1970-2010.</div><div dir="auto"><br></div><div dir="auto">Please kindly inform me how we can modify it over the same script.</div><div dir="auto"><br></div><div dir="auto">Thanking you,</div><div dir="auto">Soma </div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>
</blockquote></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" rel="noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" rel="noreferrer noreferrer noreferrer" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>
</blockquote></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" rel="noreferrer" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>
</blockquote></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>