<div dir="ltr"><div class="gmail_default">The error message from write_table is telling you exactly what the problem is:</div><div class="gmail_default"><br></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif">fatal:Argument type mismatch on argument (2) of (write_table) can not coerce</span><br></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif"><br></span></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif">If you look at the write_table documentation:</span></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif"><br></span></div><div class="gmail_default" style=""><font color="#000000" face="HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/write_table.shtml">http://www.ncl.ucar.edu/Document/Functions/Built-in/write_table.shtml</a></font><br></div><div class="gmail_default" style=""><font color="#000000" face="HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br></font></div><div class="gmail_default" style=""><font color="#000000" face="HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">Argument 2 (argument count starts at 0) is the "alist" argument, which must be a list. This means you have to surround the variable with "[/" and "/]". See the examples section in the above link. </font></div><div class="gmail_default" style=""><font color="#000000" face="HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br></font></div><div class="gmail_default" style=""><font color="#000000" face="HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">--Mary</font></div><div class="gmail_default" style=""><font color="#000000" face="HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br></font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 26, 2016 at 6:30 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><span>Hi Mary. </span></div><div><span><br></span></div><div>Thanks.</div><div>The lines, outfile = "cmorph"</div><span class=""><div>; outfile = outfile+0+".txt"</div><div>; drf = "cmori"</div><div>; drf = drf+0+".txt"</div><div dir="ltr"><br></div></span><div dir="ltr">were added to write the data in each file separately. I wanted to check if the addition of the data is taking place. I got 24 files by the name of cmorph0.txt</div><div dir="ltr">cmorph10.txt</div><div dir="ltr">cmorph11.txt</div><div dir="ltr">cmorph12.txt</div><div dir="ltr">cmorph13.txt</div><div dir="ltr">cmorph14.txt</div><div dir="ltr">cmorph15.txt</div><div dir="ltr">cmorph16.txt</div><div dir="ltr">cmorph17.txt</div><div dir="ltr">cmorph18.txt</div><div dir="ltr">cmorph19.txt</div><div dir="ltr">cmorph1.txt</div><div dir="ltr">cmorph20.txt</div><div dir="ltr">cmorph21.txt</div><div dir="ltr">cmorph22.txt</div><div dir="ltr">cmorph23.txt</div><div dir="ltr"><br></div><div><br></div><div> actually I have to add the data (cmorph rainfall) corresponding to 24 files and make it as a daily data. </div><div><br></div><div>So I have converted 4 dim variable (cmorrf, the dimensions being file number, ntime, lat, lon) into one dimension (cmor1d) using ndtooned function. then each 1 dim variable I was trying to add using a do loop. </div><div>I dont know how to define a NULL array (1 dimensional). </div><div><br></div><div dir="ltr">Secondly, I could not use the write_table function. I was getting the following error...</div><div dir="ltr"><br></div><div dir="ltr">Variable: cmorrf</div><div dir="ltr">Type: float</div><div dir="ltr">Total Size: 783288192 bytes</div><div dir="ltr"> 195822048 values</div><div dir="ltr">Number of Dimensions: 4</div><div dir="ltr">Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[24] x [1] x [1649] x [4948]</div><div dir="ltr">Coordinates: </div><div dir="ltr">Number Of Attributes: 1</div><div dir="ltr"> _FillValue :<span style="white-space:pre-wrap">        </span>9.96921e+36</div><div dir="ltr">fatal:Argument type mismatch on argument (2) of (write_table) can not coerce</div><div dir="ltr">fatal:["Execute.c":8578]:Execute: Error occurred at or near line 70 in file cmorph-daily-v2.ncl</div><div dir="ltr"><br></div><div>Thanks again</div><div><div class="h5"> <div><br><br></div><div style="display:block"> <div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,Sans-Serif;font-size:16px"> <div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,Sans-Serif;font-size:16px"> <div dir="ltr"><font size="2" face="Arial"> On Tuesday, 26 January 2016 3:59 AM, Mary Haley <<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>> wrote:<br></font></div> <br><br> <div><div><div><div dir="ltr"><div style="font-size:small">There are a few issues with your script. </div><div style="font-size:small"><br clear="none"></div><div style="font-size:small">[1] </div><div>
<div style="font-size:small"><font face="monospace, monospace"> <span>do</span> n = 0, no_of_files</font></div><div style="font-size:small">Shouldn't this be:</div><div style="font-size:small">
</div><div style="font-size:small"><font face="monospace, monospace"> <span>do</span> n = 0, no_of_files-1</font></div><div style="font-size:small">[2] I don't understand this part:</div><div><font face="monospace, monospace"> outfile = "cmorph"<br clear="none"> outfile = outfile+0+".txt"<br clear="none"> drf = "cmori"<br clear="none"> drf = drf+0+".txt"</font></div><div>Are the "0" supposed to be "n"?</div><div style="font-size:small">[3]</div><div style="font-size:small">
</div><div style="font-size:small"><font face="monospace, monospace"> rf = <span>fbindirread</span>(files(0),0,<span>(/</span>ntim,nlat,nlon<span>/)</span>,<span>"ubyte"</span>)</font></div><div style="font-size:small">Shouldn't this be:</div><div style="font-size:small">
</div><div style="font-size:small"><font face="monospace, monospace"> rf = <span>fbindirread</span>(files(n),0,<span>(/</span>ntim,nlat,nlon<span>/)</span>,<span>"ubyte"</span>)<br clear="none"><br clear="none"></font><span style="font-family:monospace,monospace"> ^^^</span><font face="monospace, monospace"><br clear="none"></font></div><div 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.</div><div style="font-size:small">[5] <br clear="none"></div><div 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. </div><div 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:</div><div style="font-size:small"><span style="font-family:monospace,monospace"> rf = new((/no_of_files,ntim,nlat,nlon/),"ubyte")</span></div><div style="font-size:small"><font face="monospace, monospace"> do n = 0, no_of_files <br clear="none"> rf(n,:,:,:) = fbindirread(files(n),0,(/ntim,nlat,nlon/),"ubyte")<br clear="none"> end do<br clear="none"> cmorrf = where(rf.eq.255,255,rf*0.2)<br clear="none"> asciiwrite(outfile,cmorrf)</font></div><div 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:</div><div><a rel="nofollow" shape="rect" href="http://www.ncl.ucar.edu/Applications/o-ascii.shtml" target="_blank">http://www.ncl.ucar.edu/Applications/o-ascii.shtml</a></div><div>--Mary</div><div><br clear="none"></div></div></div><div><br clear="none"><div>On Sun, Jan 24, 2016 at 9:57 AM, Geeta Geeta <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:geetag54@yahoo.com" target="_blank">geetag54@yahoo.com</a>></span> wrote:<br clear="none"><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><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 clear="none"></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 clear="none"></div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"><br clear="none"></div><div><div>; ----Defining for Once -----</div><div><br clear="none"></div><div> wks = gsn_open_wks("ps","cmorph-v2")</div><div> gsn_define_colormap(wks,"prcp_2")</div><div><br clear="none"></div><div> plot = new(24,graphic)</div><div><br clear="none"></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 clear="none"></div><div> ntim = 1</div><div> nlat = 1649 </div><div> nlon = 4948</div><div><br clear="none"></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 clear="none"></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 clear="none"></div><div dir="ltr"> cmordaily= new(8159252,float,255)</div><div dir="ltr"> printVarSummary(cmordaily)</div><div dir="ltr"><br clear="none"></div><div dir="ltr"><br clear="none"></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 clear="none"></div><div dir="ltr"> rf = fbindirread(files(0),0,(/ntim,nlat,nlon/),"ubyte")</div><div dir="ltr"> printVarSummary(rf)</div><div dir="ltr"><br clear="none"></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 clear="none"></div><div dir="ltr"><br clear="none"></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 clear="none"></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 clear="none"></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 clear="none"></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 clear="none"></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 clear="none"></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 clear="none"></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></div><br clear="none">_______________________________________________<br clear="none">
ncl-talk mailing list<br clear="none">
<a rel="nofollow" shape="rect" href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br clear="none">
List instructions, subscriber options, unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br clear="none">
<br clear="none"></blockquote></div><br clear="none"></div></div></div><br><br></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>