[ncl-talk] Calling binary files

Arka Banerjee arka354deb at gmail.com
Wed Dec 20 23:31:22 MST 2017


If one write the following line what does it mean?

Fn=(/"day1.dat","day2.dat","day3.dat","day4.dat"/)

The above line is not mean that all dat file names are concatenate in
variable Fn?
I required the same thing for 100 files but without manually putting the
file name.

That was the question.

Thanks,
Arka

On Dec 21, 2017 01:37, "Dennis Shea" <shea at ucar.edu> wrote:

@Arka: Please read the

https://www.ncl.ucar.edu/Document/Manuals/


   - NCL User Guide, V1.1
   <https://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide>
   - Mini-Language (pdf)
   <https://www.ncl.ucar.edu/Document/Manuals/language_man.pdf>

====================================
NCL does allow a user to specify a *variable *which spans multiple netCDF,
grib or HDF files to (effectively) be concatenated via *addfiles *and the
appropriate* ListSetType *options.
*NOTE: the files are not concatenated ....only the specified variable.*
https://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml
https://www.ncl.ucar.edu/Document/Functions/Built-in/ListSetType.shtml

=====
There is *no *explicit NCL function which concatenates *binary* or *text*
(ascii)* files*.
Please Read: https://www.ncl.ucar.edu/Applications/r-binary.shtml

===
Some options:

[1] On the {U/Li}nix command line:

%> *cat* LocalBinaryFiles*dat *>!* BigBinary.dat

The *!* will overwrite 'BigBinary.dat' if the file currently exits.

Depending on the binary file type, use:

    Direct Access:            data = *fbindirread*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/fbindirread.shtml>("BigBinary.dat",rec,dim,type)

    Sequential Access:        data = *fbinrecread*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/fbinrecread.shtml>("BigBinary.dat",rec,dim,type)

*Please read* the documentation for these function:

http://www.ncl.ucar.edu/Document/Functions/Built-in/fbindirread.shtml
http://www.ncl.ucar.edu/Document/Functions/Built-in/fbinrecread.shtml

also, binary files could be '*BigEndian*" or '*LittleEndian**. *The
following allows you to specify

http://www.ncl.ucar.edu/Document/Functions/Built-in/isbigendian.shtml

 if (*isbigendian*() ) then   ; is local machine big or little endian?
     *setfileoption*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/setfileoption.shtml>("bin","ReadByteOrder","LittleEndian")
 end if

 x = *fbindirread*(...)

or

 c = *fbinrecread*(...)

Sfter you are finished, you may want to delete the 'BigBinary.dat' file

%> rm BigBinary.dat

Or, perhaps the individual binary files and keep the concatenated file:

%> rm LittleBinary*dat


[2]

diri = ".../"    ; input dir

if (*.not.fileexists*("BigBinary.dat")) then

    system("cat LocalBinary*dat >! "BigBinary.dat")

end if


    Direct Access:            data = *fbindirread*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/fbindirread.shtml>("BigBinary.dat",rec,dim,type)

    Sequential Access:        data = *fbinrecread*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/fbinrecread.shtml>("BigBinary.dat",rec,dim,type)








On Wed, Dec 20, 2017 at 10:27 AM, Laura Fowler via ncl-talk <
ncl-talk at ucar.edu> wrote:

> Hi Arka:
>
> I usually use systemfunc, followed with ListSetType, and then addfiles
> to read a bunch of the same kind of files together. There are lots of
> examples on how to use systemfun on the ncl web site.
>
> Hope this helps,
> Laura
>
>
> On Wed, Dec 20, 2017 at 9:13 AM, Arka Banerjee via ncl-talk
> <ncl-talk at ucar.edu> wrote:
> > Hi all,
> >
> > How to concatenate all file names in a single variable in NCL? I have
> 100 of
> > .dat files in a directory and I want to call them all in a variable like
> > below;
> >
> > fn=(/"gsmap_nrt.20100805.0600.dat","gsmap_nrt.20100805.0900.dat"/)
> >
> > So that 'fn' will be re-structured for 100 of .dat files in the same way
> of
> > above line.
> >
> >
> > How to execute this thing? Function 'addfiles' helps in this case? As I
> have
> > found it is not for ascii formate.
> >
> >
> > Thanks,
> >
> > Arka
> >
> > _______________________________________________
> > ncl-talk mailing list
> > ncl-talk at ucar.edu
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
>
>
>
> --
> !-----------------------------------------------------------
> --------------------------------------------------
> Laura D. Fowler
> Mesoscale and Microscale Meteorology Division (MMM)
> National Center for Atmospheric Research
> P.O. Box 3000, Boulder CO 80307-3000
>
> e-mail: laura at ucar.edu
> phone: 303-497-1628
>
> !-----------------------------------------------------------
> --------------------------------------------------
> _______________________________________________
> 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/20171221/e215f079/attachment.html>


More information about the ncl-talk mailing list