<div dir="ltr"><div class="gmail_default" style="font-size:small">There are a few issues with your script. </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">[1] </div><div class="gmail_default" style="">
<p class="" style="font-size:small"><font face="monospace, monospace"> <span class="">do</span> n = 0, no_of_files</font></p><p class="" style="font-size:small">Shouldn't this be:</p><p class="" style="font-size:small">
</p><p class="" style="font-size:small"><font face="monospace, monospace"> <span class="">do</span> n = 0, no_of_files-1</font></p><p class="" style="font-size:small">[2] I don't understand this part:</p><p class="" style=""><font face="monospace, monospace"> outfile = "cmorph"<br> outfile = outfile+0+".txt"<br> drf = "cmori"<br> drf = drf+0+".txt"</font></p><p class="" style="">Are the "0" supposed to be "n"?</p><p class="" style="font-size:small">[3]</p><p class="" style="font-size:small">
</p><p class="" style="font-size:small"><font face="monospace, monospace"> rf = <span class="">fbindirread</span>(files(0),0,<span class="">(/</span>ntim,nlat,nlon<span class="">/)</span>,<span class="">"ubyte"</span>)</font></p><p class="" style="font-size:small">Shouldn't this be:</p><p class="" style="font-size:small">
</p><p class="" style="font-size:small"><font face="monospace, monospace"> rf = <span class="">fbindirread</span>(files(n),0,<span class="">(/</span>ntim,nlat,nlon<span class="">/)</span>,<span class="">"ubyte"</span>)<br><br></font><span style="font-family:monospace,monospace"> ^^^</span><font face="monospace, monospace"><br></font></p><p class="" style="font-size:small">[4] Why do you want to write the values to an ASCII files? And, if you are going to do this, why use asciiwrite? This writes one value per line which is extremely inefficient. Really, writing any kind of ASCII file is not ideal for large files. You should probably look at using "write_table" which at least allows for multiple values per line.</p><p class="" style="font-size:small">[5] <br></p><p class="" style="font-size:small">You are calling "asciiwrite" inside the do loop, with the same output filename. This is going to cause the output file to get overwritten each time, and not appended to. </p><p class="" style="font-size:small">If you have enough memory, then I would create "rf" outside the loop so that it has an extra leftmost dimension of size no_of_files, and then call "asciiwrite" outside the do loop:</p><p class="" style="font-size:small"><span style="font-family:monospace,monospace"> rf = new((/no_of_files,ntim,nlat,nlon/),"ubyte")</span></p><p class="" style="font-size:small"><font face="monospace, monospace"> do n = 0, no_of_files <br> rf(n,:,:,:) = fbindirread(files(n),0,(/ntim,nlat,nlon/),"ubyte")<br> end do<br> cmorrf = where(rf.eq.255,255,rf*0.2)<br> asciiwrite(outfile,cmorrf)</font></p><p class="" style="font-size:small">If you don't have the memory to do this, then look into using "write_table", which allows for appending to an existing file. See example "write_asc_4.ncl" at:</p><p class="" style=""><a href="http://www.ncl.ucar.edu/Applications/o-ascii.shtml">http://www.ncl.ucar.edu/Applications/o-ascii.shtml</a></p><p class="" style="">--Mary</p><p class="" style=""><br></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 24, 2016 at 9:57 AM, Geeta Geeta <span dir="ltr"><<a href="mailto:geetag54@yahoo.com" target="_blank">geetag54@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,Sans-Serif;font-size:16px"><div><div><div style="background-color:rgb(255,255,255)"><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px">I have to add the 24 binary rainfall files (cmorph) and get one rainfall variable that has 24 hours data. </div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"><br></div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px">Following the part of the script used for reading the rainfall. </div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"><br></div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"><br></div><div><div>; ----Defining for Once -----</div><div><br></div><div> wks = gsn_open_wks("ps","cmorph-v2")</div><div> gsn_define_colormap(wks,"prcp_2")</div><div><br></div><div> plot = new(24,graphic)</div><div><br></div><div> files = systemfunc("ls CMORPH_8KM-30MIN_20151130*")</div><div>; print(files)</div><div>; print(files(0))</div><div> no_of_files = dimsizes(files)</div><div> print(no_of_files)</div><div><br></div><div> ntim = 1</div><div> nlat = 1649 </div><div> nlon = 4948</div><div><br></div><div> lat = 59.963614 - ispan(0,nlat-1,1)*0.072771377</div><div> lat!0 = "latitude"</div><div> lat@units = "degrees_north"</div><div>; printVarSummary(lat)</div><div>; print(lat)</div><div><br></div><div> lon = 0.036378335 + ispan(0,nlon-1,1)*0.072756669</div><div> lon!0 = "longitude"</div><div> lon@units = "degrees_east"</div><div>; printVarSummary(lon)</div><div>; print(lon)</div><div dir="ltr"><div dir="ltr">; Reading File-----------------</div><div dir="ltr"><br></div><div dir="ltr"> cmordaily= new(8159252,float,255)</div><div dir="ltr"> printVarSummary(cmordaily)</div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"> do n = 0, no_of_files</div><div dir="ltr"> outfile = "cmorph"</div><div dir="ltr"> outfile = outfile+n+".txt"</div><div dir="ltr"> drf = "cmori"</div><div dir="ltr"> drf = drf+n+".txt"</div><div dir="ltr"><br></div><div dir="ltr"> rf = fbindirread(files(0),0,(/ntim,nlat,nlon/),"ubyte")</div><div dir="ltr"> printVarSummary(rf)</div><div dir="ltr"><br></div><div dir="ltr">; temp = str_split(files(n),"_") ; For date of the data file</div><div dir="ltr">; date_time = temp(1)+temp(2)</div><div dir="ltr">; print(date_time)</div><div dir="ltr">; date_time!0 = "time"</div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"> cmorrf = where(rf.eq.255,255,rf*0.2)</div><div dir="ltr"> printVarSummary(cmorrf)</div><div dir="ltr"> cmorrf@units = "mm"</div><div dir="ltr"> cmorrf@_FillValue = 255</div><div dir="ltr"> asciiwrite(outfile,cmorrf)</div><div dir="ltr"><br></div><div dir="ltr"> cmor1d = ndtooned(cmorrf)</div><div dir="ltr"> asciiwrite("cmor1d_after1d.txt",cmor1d)</div><div dir="ltr"> printVarSummary(cmor1d)</div><div dir="ltr"><br></div><div dir="ltr"> cmordaily = cmor1d+cmordaily</div><div dir="ltr">; cmordaily@_FillValue = 255</div><div dir="ltr"> asciiwrite(drf,cmordaily)</div><div dir="ltr"><br></div><div dir="ltr" style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"><br></div><div dir="ltr" style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"><br></div><div dir="ltr" style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px">I am not getting getting the data added in the last file. </div><div dir="ltr" style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px">I am attaching the cmordaily files. </div><div dir="ltr" style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px">Following files are created</div><div dir="ltr" style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"><div dir="ltr">-rw-rw-r-- 1 aditya aditya 3635 Jan 24 22:08 cmorph-daily.ncl</div><div dir="ltr">-rw-rw-r-- 1 aditya aditya 25048562 Jan 24 22:11 cmorph0.txt</div><div dir="ltr">-rw-rw-r-- 1 aditya aditya 25048562 Jan 24 22:11 cmor1d_after1d.txt</div><div dir="ltr">-rw-rw-r-- 1 aditya aditya 32637008 Jan 24 22:12 cmori0.txt</div><div dir="ltr"><br></div></div><div dir="ltr" style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px">cmori0.txt file has only 8199252 values each equal to 255.</div><div dir="ltr" style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px">can someone suggest...</div></div></div></div></div></div></div></div><br>_______________________________________________<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/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>