<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:16px"><div id="yui_3_16_0_1_1453798588692_5194"><span id="yui_3_16_0_1_1453798588692_5200">Hi Mary. </span></div><div id="yui_3_16_0_1_1453798588692_5194"><span><br></span></div><div id="yui_3_16_0_1_1453798588692_5194">Thanks.</div><div id="yui_3_16_0_1_1453798588692_5194">The lines, outfile = "cmorph"</div><div id="yui_3_16_0_1_1453798588692_5194" class="">; outfile = outfile+0+".txt"</div><div id="yui_3_16_0_1_1453798588692_5194" class="">; drf = "cmori"</div><div id="yui_3_16_0_1_1453798588692_5194" class="">; drf = drf+0+".txt"</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class=""><br id="yui_3_16_0_1_1453798588692_6591" class=""></div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">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 id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph10.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph11.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph12.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph13.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph14.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph15.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph16.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph17.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph18.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph19.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph1.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph20.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph21.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph22.txt</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">cmorph23.txt</div><div dir="ltr" id="yui_3_16_0_1_1453798588692_6730" class=""><br id="yui_3_16_0_1_1453798588692_6732" class=""></div><div id="yui_3_16_0_1_1453798588692_5194"><br></div><div id="yui_3_16_0_1_1453798588692_5194"> actually I have to add the data (cmorph rainfall) corresponding to 24 files and make it as a daily data. </div><div id="yui_3_16_0_1_1453798588692_5194"><br></div><div id="yui_3_16_0_1_1453798588692_5194">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 id="yui_3_16_0_1_1453798588692_5194">I dont know how to define a NULL array (1 dimensional). </div><div id="yui_3_16_0_1_1453798588692_5194"><br></div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr">Secondly, I could not use the write_table function. I was getting the following error...</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class=""><br></div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">Variable: cmorrf</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">Type: float</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">Total Size: 783288192 bytes</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class=""> 195822048 values</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">Number of Dimensions: 4</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">Dimensions and sizes:<span class="" style="white-space:pre-wrap;" id="yui_3_16_0_1_1453798588692_6128">        </span>[24] x [1] x [1649] x [4948]</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">Coordinates: </div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">Number Of Attributes: 1</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class=""> _FillValue :<span class="" style="white-space:pre-wrap;" id="yui_3_16_0_1_1453798588692_6133">        </span>9.96921e+36</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">fatal:Argument type mismatch on argument (2) of (write_table) can not coerce</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class="">fatal:["Execute.c":8578]:Execute: Error occurred at or near line 70 in file cmorph-daily-v2.ncl</div><div id="yui_3_16_0_1_1453798588692_5194" dir="ltr" class=""><br id="yui_3_16_0_1_1453798588692_6138" class=""></div><div id="yui_3_16_0_1_1453798588692_5194">Thanks again</div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" 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 <haley@ucar.edu> wrote:<br></font></div> <br><br> <div class="y_msg_container"><div id="yiv4269648858"><div><div dir="ltr"><div class="yiv4269648858gmail_default" style="font-size:small;">There are a few issues with your script. </div><div class="yiv4269648858gmail_default" style="font-size:small;"><br clear="none"></div><div class="yiv4269648858gmail_default" style="font-size:small;">[1] </div><div class="yiv4269648858gmail_default" style="">
<div class="yiv4269648858" style="font-size:small;"><font face="monospace, monospace"> <span class="yiv4269648858">do</span> n = 0, no_of_files</font></div><div class="yiv4269648858" style="font-size:small;">Shouldn't this be:</div><div class="yiv4269648858" style="font-size:small;">
</div><div class="yiv4269648858" style="font-size:small;"><font face="monospace, monospace"> <span class="yiv4269648858">do</span> n = 0, no_of_files-1</font></div><div class="yiv4269648858" style="font-size:small;">[2] I don't understand this part:</div><div class="yiv4269648858" style=""><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 class="yiv4269648858" style="">Are the "0" supposed to be "n"?</div><div class="yiv4269648858" style="font-size:small;">[3]</div><div class="yiv4269648858" style="font-size:small;">
</div><div class="yiv4269648858" style="font-size:small;"><font face="monospace, monospace"> rf = <span class="yiv4269648858">fbindirread</span>(files(0),0,<span class="yiv4269648858">(/</span>ntim,nlat,nlon<span class="yiv4269648858">/)</span>,<span class="yiv4269648858">"ubyte"</span>)</font></div><div class="yiv4269648858" style="font-size:small;">Shouldn't this be:</div><div class="yiv4269648858" style="font-size:small;">
</div><div class="yiv4269648858" style="font-size:small;"><font face="monospace, monospace"> rf = <span class="yiv4269648858">fbindirread</span>(files(n),0,<span class="yiv4269648858">(/</span>ntim,nlat,nlon<span class="yiv4269648858">/)</span>,<span class="yiv4269648858">"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 class="yiv4269648858" 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 class="yiv4269648858" style="font-size:small;">[5] <br clear="none"></div><div class="yiv4269648858" 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 class="yiv4269648858" 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 class="yiv4269648858" style="font-size:small;"><span style="font-family:monospace, monospace;"> rf = new((/no_of_files,ntim,nlat,nlon/),"ubyte")</span></div><div class="yiv4269648858" 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 class="yiv4269648858" 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 class="yiv4269648858" style=""><a rel="nofollow" shape="rect" target="_blank" href="http://www.ncl.ucar.edu/Applications/o-ascii.shtml">http://www.ncl.ucar.edu/Applications/o-ascii.shtml</a></div><div class="yiv4269648858" style="">--Mary</div><div class="yiv4269648858" style=""><br clear="none"></div></div></div><div class="yiv4269648858gmail_extra"><br clear="none"><div class="yiv4269648858gmail_quote">On Sun, Jan 24, 2016 at 9:57 AM, Geeta Geeta <span dir="ltr"><<a rel="nofollow" shape="rect" ymailto="mailto:geetag54@yahoo.com" target="_blank" href="mailto:geetag54@yahoo.com">geetag54@yahoo.com</a>></span> wrote:<br clear="none"><blockquote class="yiv4269648858gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="yiv4269648858yqt2045730058" id="yiv4269648858yqt59574"><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" ymailto="mailto:ncl-talk@ucar.edu" target="_blank" href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br clear="none">
List instructions, subscriber options, unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">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></body></html>