[ncl-talk] Fwd: Reading multiple binary files using addfiles

Kyle Griffin ksgriffin2 at wisc.edu
Fri Mar 18 21:28:08 MDT 2016


I would suggest starting with the section on "Reading Binary Files" under
File I/O examples on the NCL website.

http://www.ncl.ucar.edu/Applications/r-binary.shtml

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.

Good luck!


Kyle

On Fri, Mar 18, 2016 at 5:36 PM Samar Min Allah <minallah at umich.edu> wrote:

> I am trying to convert multiple binary files (CPC_Unified precip data) to
> netcdf format using the following NCL script:
> https://www.ncl.ucar.edu/Applications/Scripts/cpcuni_1.ncl
>
> I modified the script to read multiple files together by adding the
> following;
>
> diri   = "./"
> fil   = systemfunc("cd "+diri+" ; ls PRCP_CU_GAUGE_V1.0GLB_0.50deg.lnx.*")
> nfil = dimsizes(fil)
>
> do nf = 0,nfil-1
>    fili = addfiles(diri+fil(nf),"r")
> netCDF = True
>    PLOT   = False
>
>    if (netCDF) then
>        ncDir   = "./"
>        ncFil   = fili+".nc"
>    end if
> .
> .
> . *(the remaining code is same as the script)*
> end do
>
> When I run the code; I get this error "*Could not coerce values for
> operation*"
> Also, I believe addfiles require a file extension but when I add .bin next
> to the file name I get the message "*...has no file extension, can't
> determine type of file to open*"
>
> I have also attached two sample files.
>
> Thanks!
>
> ​​
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160319/ed5e9351/attachment.html 


More information about the ncl-talk mailing list