<div dir="ltr"><div><div><div><div><div><div><div><div><div><div>Kyle is correct. You must read the documentation more carefully. The 'addfiles' and 'addfile' function documentation clearly state they are for grib-1/2, netCDF-3/4, hdf-4/5. <br><br></div>If you Click on 'Functions' ... then 'Category' ... then 'File IO' you will see a list of all IO related functions. Look at the 'binary' file suite.<br><br></div>The '<a href="http://www.ncl.ucar.edu/Applications/Scripts/cpcuni_1.ncl">cpcuni_1.ncl</a>' example at<br><br> <a href="http://www.ncl.ucar.edu/Applications/HiResPrc.shtml">http://www.ncl.ucar.edu/Applications/HiResPrc.shtml</a><br><br></div>contains a GrADS control file outlining the contents and structure of the file. Please look at this.<br><br></div>It is not clear to me if the data should be scaled. I did scale the data prior to plotting and writing to netCDF. Please change appropriately.<br><br>===<br></div>Really ... just minor changes to the '<a href="http://www.ncl.ucar.edu/Applications/Scripts/cpcuni_1.ncl">cpcuni_1.ncl</a>' example are necessary.<br></div><div>See Attached script<br></div><div><br></div>I prefer to loop over each binary file and create a corresponding netCDF file. Then, use the 'ncrcat' operator to concatenate all the files; then delete the intermediate daily netCDF files. This is done via the 'system' procedure.<br><br>===<br></div>If you are new to NCL, please read the <br><br><a href="http://www.ncl.ucar.edu/Document/Manuals/">http://www.ncl.ucar.edu/Document/Manuals/</a><br><br></div>(pdf) Mini-Language Manual<br><br></div>An excellent tutorial is at:<br><br><a href="https://dl.dropboxusercontent.com/u/8357888/homepage/tutoriais/ncl/NCL_Tutorial_V1.1.pdf">DKRZ: NCL Tutorial Version 1.1</a><br></div>and<br><a href="https://dl.dropboxusercontent.com/u/8357888/homepage/tutoriais/ncl/NCL_Exercises_and_Tasks_all.pdf">DKRZ:
Examples and Exercises</a><br><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 18, 2016 at 9:28 PM, Kyle Griffin <span dir="ltr"><<a href="mailto:ksgriffin2@wisc.edu" target="_blank">ksgriffin2@wisc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I would suggest starting with the section on "Reading Binary Files" under File I/O examples on the NCL website.<div><br></div><div><a href="http://www.ncl.ucar.edu/Applications/r-binary.shtml" target="_blank">http://www.ncl.ucar.edu/Applications/r-binary.shtml</a><br></div><div><br></div><div>You'll see that 'addfiles' is not the best way to read in such files, as it will be expecting certain data structures that a binary file won't have. 'fbindirread' is the most common function I've used, although I work with only limited binary files, none of which are from CPC. Hopefully your data source provides a bit more info on the type of binary file to help you choose the correct reading function and the correct settings for 'setfileoption' function calls, if necessary.</div><div><br></div><div>Good luck!</div><div><br></div><div><br></div><div>Kyle</div></div><br><div class="gmail_quote"><div><div class="h5"><div dir="ltr">On Fri, Mar 18, 2016 at 5:36 PM Samar Min Allah <<a href="mailto:minallah@umich.edu" target="_blank">minallah@umich.edu</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div class="gmail_quote"><font size="2"><span style="font-family:courier new,monospace"><span style="color:rgb(153,153,153)"></span></span></font><span style="color:rgb(7,55,99)">I am trying to convert multiple binary files (CPC_Unified precip data) to netcdf format using the following NCL script:</span><br><div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div style="color:rgb(7,55,99)"><a href="https://www.ncl.ucar.edu/Applications/Scripts/cpcuni_1.ncl" target="_blank">https://www.ncl.ucar.edu/Applications/Scripts/cpcuni_1.ncl</a><br><br></div><div style="color:rgb(7,55,99)">I modified the script to read multiple files together by adding the following;<br><br>diri = "./" <br>fil = systemfunc("cd "+diri+" ; ls PRCP_CU_GAUGE_V1.0GLB_0.50deg.lnx.*")<br>nfil = dimsizes(fil)<br> <br>do nf = 0,nfil-1 <br> fili = addfiles(diri+fil(nf),"r") <br>netCDF = True <br> PLOT = False <br><br> if (netCDF) then<br> ncDir = "./" <br> ncFil = fili+".nc" <br> end if<br>.<br>.<br></div><div style="color:rgb(7,55,99)">. <i>(the remaining code is same as the script)</i><br></div><div style="color:rgb(7,55,99)">end do<br></div><div style="color:rgb(7,55,99)"><br></div><div style="color:rgb(7,55,99)">When I run the code; I get this error "<i>Could not coerce values for operation</i>"<br></div><div style="color:rgb(7,55,99)">Also, I believe addfiles require a file extension but when I add .bin next to the file name I get the message "<i>...has no file extension, can't determine type of file to open</i>"<br><br></div><div style="color:rgb(7,55,99)">I have also attached two sample files.<br><br></div><div style="color:rgb(7,55,99)">Thanks!<br></div><div style="color:rgb(7,55,99)"><br></div><div style="color:rgb(7,55,99);display:inline"></div><font size="2"><span style="font-family:courier new,monospace"><span style="color:rgb(153,153,153)"></span></span></font><br><div><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><div><div><div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div>
</div><br></div>
</div><br></div></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>_______________________________________________<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>