<div dir="ltr"><div><div><div><div><div><div><div><div><div>The text file looks like it contains grid points from 'some' pre-existing <br>(time,lat,lon) array.<br><br></div>ntim = ?? ; number of unique time steps<br></div>nlat = ??<br></div>mlon = ??<br><br></div>RAIN = new( (/ntim,nlat,mlon/), "float", -999.9)<br></div>lat = .... ; lat(lat) ; coordinate variables for the grid<br></div>lon = ... ; lon(lon)<br><br></div><div>=== As suggested by Forrest ...<br><br></div><div> diri = "./" ; input diectory<br> fili = "RAIN.txt" ; whatever the text file name is<br> pthi = diri+fili<br> data = asciiread(pthi, -1, "string")<br><br> delim= " ,-_:"<br><br> rain = tofloat( str_get_field(data(1:), 1, delim) )<br> yyyy = toint( str_get_field(data(1:), 2, delim) )<br> mm = toint( str_get_field(data(1:), 3, delim) )<br> dd = toint( str_get_field(data(1:), 4, delim) )<br> hh = toint( str_get_field(data(1:), 5, delim) )<br> mn = toint( str_get_field(data(1:), 6, delim) )<br> sc = todouble( str_get_field(data(1:),7, delim) )<br><br> LAT = todouble( str_get_field(data(1:),8, delim) )<br> LON = todouble( str_get_field(data(1:),9, delim) )<br><br></div> npts = dimsizes(lat)<br><br></div><div>; Fill array<br><br></div><div> eps = 0.001 ; arbitrary 'distance'<br></div> do np=0,npts-1<br></div><div> nt = ???<br></div><div> nl = ind(LAT(np).gt.(lat-eps) .and. LAT(np).lt.(lat+eps)) ; lat index<br> ml = ind(LON(np).gt.(lon-eps) .and. LON(np).lt.(lon+eps)) ; lon index<br></div><div> RAIN(nt,nl,ml) = RAIN(np)<br></div> end do<br><div><div><div><br></div><div> RAIN!0 = "time"<br></div><div> RAIN!1 = "lat"<br></div><div> RAIN!2 = "lon"<br></div><div> RAIN&lat = lat<br></div><div> RAIN&lon = lon<br></div><div> RAIN@long_name = "Rain Density"<br></div><div> RAIN@units = "..."<br></div><div> printVarSummary(RAIN)<br></div><div> printMinMax(RAIN,0)<br><br><br></div><div><br></div><div>plot RAIN variable<br></div><div><br></div><div>Good luck<br></div><div><br><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 20, 2016 at 7:29 AM, Black, Forrest (LARC-D318)[UNIVERSITIES SPACE RESEARCH ASSOCIATION] <span dir="ltr"><<a href="mailto:forrest.black@nasa.gov" target="_blank">forrest.black@nasa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-US">
<div class="m_4669642721288996316WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hi Tao,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">The attached script reads in asci data and creates a new table by column, but gives you an idea how the NCL asciiread function works.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Once the date column is read you can use the str_split function to split up your date in NCL (<a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/str_split.shtml" target="_blank">https://www.ncl.ucar.edu/<wbr>Document/Functions/Built-in/<wbr>str_split.shtml</a>).<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">I hope this helps,<b><u></u><u></u></b></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="m_4669642721288996316MsoListParagraph"><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><span>-<span style="font:7.0pt "Times New Roman"">
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Forrest<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a> [mailto:<a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.<wbr>edu</a>]
<b>On Behalf Of </b>Tao Lu<br>
<b>Sent:</b> Thursday, October 20, 2016 3:35 AM<br>
<b>To:</b> <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
<b>Subject:</b> [ncl-talk] How to read ascii data and subscript a three dimension arry<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hello ncl-talk<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I am Tao.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I have a time series data. I want to use this data to plot a contour graph.<br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><img id="m_4669642721288996316_x0000_i1025" src="cid:image002.png@01D22AB3.60A8BF30" alt="Inline image 1" height="389" border="0" width="554"><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">As you see, I get the data in this format. This data is rain data of 100x100 grid with different time.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">How can I make an array rain(ntime, nlat, nlon) from this data?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Please help me, thanks in advance.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:9.5pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">******************************<wbr>************************</span><span style="font-size:9.5pt"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Tao Lu (M. Eng)</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:"Arial",sans-serif">Laboratory of River Engineering and Hydrology,</span><span style="font-family:"Arial",sans-serif"><br>
Dept. of Civil and Environmental Engineering,<br>
</span><span style="font-size:9.5pt;font-family:"Arial",sans-serif">Graduate School of Science and Engineering,</span><span style="font-family:"Arial",sans-serif"><br>
Chuo University<br>
<br>
</span>1-13-27<span style="font-family:"Arial",sans-serif">,Kasuga,Bunkyo-ku,Tokyo<br>
112-8551, Japan<br>
TEL: </span>03-3817-1805<span style="font-size:10.0pt;font-family:"Arial",sans-serif">; </span><span style="font-family:"Arial",sans-serif">Phone: 070-2188-7509<br>
</span><span style="font-size:9.5pt">Email1: </span><a href="mailto:mail%3Amet.yamos@gmail.com" target="_blank"><span style="font-size:9.5pt;color:#1155cc">hakufu.asano@gmail.com</span></a><span style="font-size:9.5pt"><br>
Email2: </span><a href="mailto:mail%3Ayamoto@civil.chuo-u.ac.jp" target="_blank"><span style="font-size:9.5pt;color:#1155cc">lutao@civil.chuo-u.ac.<wbr>jp</span></a><span style="font-family:"Arial",sans-serif"><br>
******************************<wbr>***********************</span><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div></div></div>
</div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>