[ncl-talk] Calling binary files

Barry Lynn barry.h.lynn at gmail.com
Fri Dec 22 00:18:14 MST 2017


Hi Arka:

I am not sure about this.

The best thing to do would be i) to include ncl-talk, so you can benefit
from the knowledge of the group, and ii) paste the error into google and
see if a solution appears.

Barry

On Fri, Dec 22, 2017 at 8:38 AM, Arka Banerjee <arka354deb at gmail.com> wrote:

> Hi..
>
> I run the attached script as per our last discussion but I get the
> following error msg;
>
> warning:_NclOpenFile: Can not open file </home/arkadeb/Arka/GMFD/GSMap/gsmap_nrt.2
>    0100805.0600.dat>; file format not supported or file is corrupted
> warning:_NclOpenFile: Can not open file </home/arkadeb/Arka/GMFD/GSMap/gsmap_nrt.2
>    0100805.0900.dat>; file format not supported or file is corrupted
> warning:_NclOpenFile: Can not open file </home/arkadeb/Arka/GMFD/GSMap/gsmap_nrt.2
>    0100805.1200.dat>; file format not supported or file is corrupted
> warning:_NclOpenFile: Can not open file </home/arkadeb/Arka/GMFD/GSMap/gsmap_nrt.2
>    0100805.1500.dat>; file format not supported or file is corrupted
> warning:_NclOpenFile: Can not open file </home/arkadeb/Arka/GMFD/GSMap/gsmap_nrt.2
>    0100805.1800.dat>; file format not supported or file is corrupted
> warning:_NclOpenFile: Can not open file </home/arkadeb/Arka/GMFD/GSMap/gsmap_nrt.2
>    0100805.2100.dat>; file format not supported or file is corrupted
> warning:_NclOpenFile: Can not open file </home/arkadeb/Arka/GMFD/GSMap/gsmap_nrt.2
>    0130615.0300.dat>; file format not supported or file is corrupted
> warning:_NclOpenFile: Can not open file </home/arkadeb/Arka/GMFD/GSMap/gsmap_nrt.2
>    0130615.2100.dat>; file format not supported or file is corrupted
> warning:_NclOpenFile: Can not open file </home/arkadeb/Arka/GMFD/GSMap/gsmap_nrt.2
>    0130616.0600.dat>; file format not supported or file is corrupted
> fatal:Could not coerce values for operation
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 30 in
> file Gsmap.     ncl
>
> My script is attached below.
>
> Please inform me how to fix it.
>
> Thanks,
> Arka
>
>
>
>
>
> On Thu, Dec 21, 2017 at 2:48 PM, Arka Banerjee <arka354deb at gmail.com>
> wrote:
>
>> Ok..I will inform you.
>> Right now I am communicating and writing program in my mobile.
>> When I will be with my system I will let you know.
>>
>> Thanks,
>> Arka
>>
>> On Dec 21, 2017 2:18 PM, "Barry Lynn" <barry.h.lynn at gmail.com> wrote:
>>
>> Hi:
>>
>> I'm not sure until you try it.
>>
>> You can use a different name for the variable if you want.
>>
>> Barry
>>
>> On Thu, Dec 21, 2017 at 10:39 AM, Arka Banerjee <arka354deb at gmail.com>
>> wrote:
>>
>>> Thanks!
>>> Above attached program is ok then?
>>>
>>> I have to use 'fn' some where else in this program thats why I am asking.
>>>
>>> Arka
>>>
>>> On Dec 21, 2017 14:05, "Barry Lynn" <barry.h.lynn at gmail.com> wrote:
>>>
>>>> Hi:
>>>>
>>>> You don't need a dot unless you need it in order to choose between
>>>> files with and without.
>>>>
>>>> You can print("all_files = " + all_files) to see if you list is correct.
>>>>
>>>> Barry
>>>>
>>>> On Thu, Dec 21, 2017 at 10:10 AM, Arka Banerjee <arka354deb at gmail.com>
>>>> wrote:
>>>>
>>>>> If I modify according to the example is it correct now for dat files?
>>>>>
>>>>> Datadir=("data/model/result/")
>>>>> diri=Datadir
>>>>> all_files=systemfunc("ls " +dir+ "day*dat")
>>>>> n_files=dimsizes(all_files)
>>>>> do n=0,n_files-1,1
>>>>> filename=all_files(n)
>>>>> fn=addfile(filename,"r")
>>>>>
>>>>> ....
>>>>> ....
>>>>> ....
>>>>> ....
>>>>>
>>>>>
>>>>> end
>>>>>
>>>>> 'addfile' is ok or it will be 'addfiles'?
>>>>> Now above fn is same as below mentioned in case of operation?
>>>>> fn=(/"day1.dat","day2.dat"/)
>>>>>
>>>>>
>>>>> On Dec 21, 2017 12:40, "Arka Banerjee" <arka354deb at gmail.com> wrote:
>>>>>
>>>>>> Yes.
>>>>>> But one thing.
>>>>>> There should not be a dot before grb?
>>>>>>
>>>>>> Code is attached below.
>>>>>>
>>>>>>
>>>>>> On Dec 21, 2017 12:35 PM, "Barry Lynn" <barry.h.lynn at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> If you want to access the files within, you need a do loop to
>>>>>>> indicate which file you want to read.
>>>>>>>
>>>>>>> Barry
>>>>>>>
>>>>>>> On Thu, Dec 21, 2017 at 8:54 AM, Arka Banerjee <arka354deb at gmail.com
>>>>>>> > wrote:
>>>>>>>
>>>>>>>> Awesome, thanks!
>>>>>>>>
>>>>>>>> So for this a do loop is required?
>>>>>>>>
>>>>>>>> Arka
>>>>>>>>
>>>>>>>> On Dec 21, 2017 12:22, "Barry Lynn" <barry.h.lynn at gmail.com> wrote:
>>>>>>>>
>>>>>>>>> Hi:
>>>>>>>>>
>>>>>>>>> Here is what you need (example)
>>>>>>>>>
>>>>>>>>>  DATADir = "/data1/wrf/NAM/"
>>>>>>>>>
>>>>>>>>>   diri = DATADir  ; you can add "+ date" if you have files listed
>>>>>>>>> in directories by date.
>>>>>>>>>
>>>>>>>>>  all_files = systemfunc("ls " + diri + "nam*grb")
>>>>>>>>>
>>>>>>>>>  print("all_files = " + all_files)
>>>>>>>>>
>>>>>>>>>  n_files = dimsizes(all_files)
>>>>>>>>>
>>>>>>>>>  print("n_files = " + n_files)
>>>>>>>>>
>>>>>>>>> ;do n=0,n_files -1,1
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  do n=12,14
>>>>>>>>>
>>>>>>>>>    print("all_files(n) = " + all_files(n))
>>>>>>>>>
>>>>>>>>>    filename = all_files(n)
>>>>>>>>>
>>>>>>>>>    print ("filename" + filename)
>>>>>>>>>
>>>>>>>>>    a = addfile(filename,"r")
>>>>>>>>>
>>>>>>>>> On Thu, Dec 21, 2017 at 8:31 AM, Arka Banerjee via ncl-talk <
>>>>>>>>> ncl-talk at ucar.edu> wrote:
>>>>>>>>>
>>>>>>>>>> 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/addfile
>>>>>>>>>> s.shtml
>>>>>>>>>> https://www.ncl.ucar.edu/Document/Functions/Built-in/ListSet
>>>>>>>>>> Type.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
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> ncl-talk mailing list
>>>>>>>>>> ncl-talk at ucar.edu
>>>>>>>>>> List instructions, subscriber options, unsubscribe:
>>>>>>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Barry H. Lynn, Ph.D
>>>>>>>>> Senior Lecturer,
>>>>>>>>> The Institute of the Earth Science,
>>>>>>>>> The Hebrew University of Jerusalem,
>>>>>>>>> Givat Ram, Jerusalem 91904, Israel
>>>>>>>>> Tel: 972 547 231 170
>>>>>>>>> Fax: (972)-25662581
>>>>>>>>>
>>>>>>>>> C.E.O, Weather It Is, LTD
>>>>>>>>> Weather and Climate Focus
>>>>>>>>> http://weather-it-is.com
>>>>>>>>> Jerusalem, Israel
>>>>>>>>> Local: 02 930 9525
>>>>>>>>> Cell: 054 7 231 170
>>>>>>>>> Int-IS: x972 2 930 9525
>>>>>>>>> US 914 432 3108 <(914)%20432-3108>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Barry H. Lynn, Ph.D
>>>>>>> Senior Lecturer,
>>>>>>> The Institute of the Earth Science,
>>>>>>> The Hebrew University of Jerusalem,
>>>>>>> Givat Ram, Jerusalem 91904, Israel
>>>>>>> Tel: 972 547 231 170
>>>>>>> Fax: (972)-25662581
>>>>>>>
>>>>>>> C.E.O, Weather It Is, LTD
>>>>>>> Weather and Climate Focus
>>>>>>> http://weather-it-is.com
>>>>>>> Jerusalem, Israel
>>>>>>> Local: 02 930 9525
>>>>>>> Cell: 054 7 231 170
>>>>>>> Int-IS: x972 2 930 9525
>>>>>>> US 914 432 3108 <(914)%20432-3108>
>>>>>>>
>>>>>>
>>>>
>>>>
>>>> --
>>>> Barry H. Lynn, Ph.D
>>>> Senior Lecturer,
>>>> The Institute of the Earth Science,
>>>> The Hebrew University of Jerusalem,
>>>> Givat Ram, Jerusalem 91904, Israel
>>>> Tel: 972 547 231 170
>>>> Fax: (972)-25662581
>>>>
>>>> C.E.O, Weather It Is, LTD
>>>> Weather and Climate Focus
>>>> http://weather-it-is.com
>>>> Jerusalem, Israel
>>>> Local: 02 930 9525
>>>> Cell: 054 7 231 170
>>>> Int-IS: x972 2 930 9525
>>>> US 914 432 3108 <(914)%20432-3108>
>>>>
>>>
>>
>>
>> --
>> Barry H. Lynn, Ph.D
>> Senior Lecturer,
>> The Institute of the Earth Science,
>> The Hebrew University of Jerusalem,
>> Givat Ram, Jerusalem 91904, Israel
>> Tel: 972 547 231 170
>> Fax: (972)-25662581
>>
>> C.E.O, Weather It Is, LTD
>> Weather and Climate Focus
>> http://weather-it-is.com
>> Jerusalem, Israel
>> Local: 02 930 9525
>> Cell: 054 7 231 170
>> Int-IS: x972 2 930 9525
>> US 914 432 3108 <(914)%20432-3108>
>>
>>
>>
>


-- 
Barry H. Lynn, Ph.D
Senior Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
US 914 432 3108
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171222/ec89ab35/attachment.html>


More information about the ncl-talk mailing list