<div dir="ltr"><div dir="ltr"><div><font size="4">Dear Adam,</font></div><div><font size="4">Thank you for your kind help<br></font></div><div><font size="4">The script proposed by you is very clear and optimized. <br></font></div><div><font size="4">But there is an error appearing at this line <br></font></div><div><span style="color:rgb(255,0,0)"><font size="4">mod_data({data(0)*100+1:data(</font></span><span style="color:rgb(255,0,0)"><font size="4">0)*100+12},{lat_coord},{lon_</font></span><span style="color:rgb(255,0,0)"><font size="4">coord}) = (/ data(1:) /)</font></span></div><div><span style="color:rgb(255,0,0)"><font size="4"><br></font></span></div><div><span style="color:rgb(255,0,0)"><font size="4"><span style="color:rgb(0,0,0)">Telling</span>  <br></font></span></div><div><span style="color:rgb(255,0,0)"><font size="4"><br></font></span></div><div><span style="color:rgb(255,0,0)"><font size="4">fatal:NclOneDValGetClosestIndex: finish coordinate index out of range, can't continue<br>fatal:Could not obtain coordinate indexes, unable to perform subscript<br>fatal:["Execute.c":8637]:Execute: Error occurred at or near line 48 in file read_NCwrite_NC131_Adam.ncl<br></font></span></div><div><span style="color:rgb(255,0,0)"><font size="4"><br></font></span></div><div><span style="color:rgb(255,0,0)"><font size="4"><font color="#000000">Since a hour I am looking how to correct it without success</font></font></span></div><div><span style="color:rgb(255,0,0)"><font size="4"><font color="#000000"><br></font></font></span></div><div><span style="color:rgb(255,0,0)"><font size="4"><font color="#000000">Thanks again</font></font></span></div><div><span style="color:rgb(255,0,0)"><font size="4"><font color="#000000"><br></font></font></span></div><div><span style="color:rgb(255,0,0)"><font size="4"><font color="#000000">Appo<br></font></font></span></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mar. 19 févr. 2019 à 21:54, Adam Phillips <<a href="mailto:asphilli@ucar.edu">asphilli@ucar.edu</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Appo,<div>The nice aspect of your ascii file is that it is regular: Each grid point's data is given over 100 rows, and each is monthly running from 1920-2014. I would strongly recommend developing a new script that operates on each 100 row chunk of data, and that uses coordinate subscripting to put the data in the proper place in your final data array. One negative to this method is the possibility exists that multiple nearby data points get assigned to the same grid point, but this can be countered by setting your master array grid appropriately. An example:</div><div><br></div><div>; Untested! Review the code below.</div><div><div> yrStrt = 1920</div><div> yrLast = 2014</div></div><div><div> file_name   = "Rain_estimate_2.5DegGrid.txt"</div><div> rain    = asciiread(file_name, -1, "string")</div></div><div><br></div><div>lat = fspan(6.25,43.75,16)</div><div>lat@units = "degrees_north"</div><div>lat!0 = "lat"</div><div>lat&lat = lat</div><div><div>lon = fspan(-23.75, 11.25,15)</div><div>lon@units = "degrees_east"</div><div>lon!0 = "lon"</div><div>lon&lon = lon</div></div><div>time = yyyymm_time(yrStrt,yrLast,"integer")</div><div>mod_data = new((/(yrLast-yrStrt+1)*12,dimsizes(lat),dimsizes(lon)/),float,-999.)    ;Set up master array that will be filled in. </div><div>mod_data!0  = "time"</div><div>mod_data&time = time</div><div>mod_data!1 = "lat"</div><div>mod_data&lat = lat</div><div>mod_data!2 = "lon"</div><div>mod_data&lon = lon</div><div><br></div><div>nrow = numAsciiRow("file_name")</div><div><br></div><div>do gg = 0,nrow-1,100   ; Run a do loop over each 100 row segment</div><div>     temp = rain(gg:gg+99)</div><div>     coords = str_split(temp(1)," ")</div><div>     print(coords)     ; examine results of text split</div><div>     lat_coord = tofloat(coords(2))</div><div>     lon_coord = tofloat(coords(5))   </div><div>     do hh = 5,99   ; operate on rows 5-99 of temp </div><div>          data = tofloat(str_split(temp(hh)," "))</div><div>          mod_data({data(0)*100+1:data(0)*100+12},{lat_coord},{lon_coord}) = (/ data(1:) /)</div><div>          delete(data)</div><div>    end do</div><div>     delete(temp)</div><div>    print("Now done with lat="+lat_coord+", lon="+lon_coord) </div><div>end do</div><div><br></div><div>The above should at least get you going. If further changes need to be made to the above you will need to make them. If you have any further questions let ncl-talk know. </div><div>Adam</div><div><br></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 19, 2019 at 8:27 AM Appo derbetini <<a href="mailto:appopson4@gmail.com" target="_blank">appopson4@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Dear NCL users,</div><div><br></div><div>Here a script that i am using to read rainfall data. <br></div><div>Data are given for each grid point. <br></div><div>But points are not regularly distributed. <br></div><div>for some grid point there is no data</div><div><br></div><div>I want to construct  regular matrix (lat, lon) where point without data will be created and filled by missing value (-999.0 in the script). <br></div><div><br></div><div>My script is giving wrong result !!!<br></div><div><br></div><div>Any help will be appreciated<br></div><div><br></div><div><br></div><div>Regards<br></div></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><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_5712938886382667916gmail-m_-7481751364549875121gmail-m_-2755428772392260587gmail-m_6588817634466662453gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist,  </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a>   </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></div>