<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">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 dir="ltr">On Fri, Mar 18, 2016 at 5:36 PM Samar Min Allah <<a href="mailto:minallah@umich.edu">minallah@umich.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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>
_______________________________________________<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>