[ncl-talk] Problem reading hdf5 file

Dennis Shea shea at ucar.edu
Mon Jan 23 15:11:12 MST 2017


Apparently, the attached print file was too big. A **MUCH** smaller version
is attached.

===
Hi Chuck

===
For the benefit of others on ncl-talk:
[1] This contains a template script
[2] Attached is a gzip'd output file [ gzip -d out.gps ]
[3] yellowstone specific information will be sent offline.

I accessed NCL 6.4.0 on yellowstone.

%>ncl -V
6.4.0-23Jan2017_0113
=====

Here is the simple script [ rd_gps.ncl ] I used. It has many 'print' for
informational purposes. The key is to note the syntax ( => ) used to point
(reference) a 'group'. Then, that reference can access individual elements
within the group using standard syntax.
=====

  diri = "/glade/scratch/bardeenc/"
  fili = "gps031001g.002.hdf5"
  pthi = diri+fili
  fgps = addfile(pthi,"r")        ; pointer/reference to entire
file
  print(fgps)                          ; file overview

  var   = "Table Layout"
  fData = fgps=>Data              ; pointer to group 'Data' [ => syntax ]
  print(fData)                            ; all variables in group 'Data'

  table = fData->$var$             ; import variable [ -> syntax]
  print(table)                            ; Note that it is type 'list'
                                               ; it functions as a
container and
                                               ; allows multiple variables
of different types

  year  = table[0]                  ; extract 1st (index 0) list item
  print(year)
  month = table[1]
  print(year+"   "+month)

=====



On Mon, Jan 23, 2017 at 3:03 PM, Dennis Shea <shea at ucar.edu> wrote:

> Hi Chuck
>
> ===
> For the benefit of others on ncl-talk:
> [1] This contains a template script
> [2] Attached is a gzip'd output file [ gzip -d out.gps ]
> [3] yellowstone specific information will be sent offline.
>
> I accessed NCL 6.4.0 on yellowstone.
>
> %>ncl -V
> 6.4.0-23Jan2017_0113
> =====
>
> Here is the simple script [ rd_gps.ncl ] I used. It has many 'print' for
> informational purposes. The key is to note the syntax ( => ) used to point
> (reference) a 'group'. Then, that reference can access individual elements
> within the group using standard syntax.
> =====
>
>   diri = "/glade/scratch/bardeenc/"
>   fili = "gps031001g.002.hdf5"
>   pthi = diri+fili
>   fgps = addfile(pthi,"r")        ; pointer/reference to entire
> file
>   print(fgps)                          ; file overview
>
>   var   = "Table Layout"
>   fData = fgps=>Data              ; pointer to group 'Data' [ => syntax ]
>   print(fData)                            ; all variables in group 'Data'
>
>   table = fData->$var$             ; import variable [ -> syntax]
>   print(table)                            ; Note that it is type 'list'
>                                                ; it functions as a
> container and
>                                                ; allows multiple variables
> of different types
>
>   year  = table[0]                  ; extract 1st (index 0) list item
>   print(year)
>   month = table[1]
>   print(year+"   "+month)
>
> =====
>
> On Mon, Jan 23, 2017 at 1:40 PM, Charles Bardeen <bardeenc at ucar.edu>
> wrote:
>
>> Hi Dennis,
>>
>> I am running it on my desktop (Mac), but have copied a file to
>> Yellowstone. You can see an example at:
>>
>> /glade/scratch/bardeenc/gps031001g.002.hdf5
>>
>> Thanks,
>>
>> Chuck
>>
>> On Jan 23, 2017, at 1:20 PM, Dennis Shea <shea at ucar.edu> wrote:
>>
>> Likely, ncl-6.4.0 will read the file.
>> I went to site and it want us to register. Just don't wan to do that.
>>
>>
>> Are you on a CISL (eg: yellowstone) box? Where?
>>
>>
>> If not, make the data available via WWW or ftp to:
>>
>> ftp ftp.cgd.ucar.edu
>> anonymous
>> your_email
>> cd incoming
>> put your_file
>> quit
>>
>> THX
>>
>> On Mon, Jan 23, 2017 at 12:32 PM, Charles Bardeen <bardeenc at ucar.edu>
>> wrote:
>>
>>> I am trying to read hdf5 data produced from the Madrigal archive (
>>> http://cedar.openmadrigal.org ). The file format contains groups and
>>> compounds. I seem to be able to access the group, but have been unable to
>>> access the data that I want from the compound. Can you tell how to make
>>> this work? The file format and the commands I have tried are shown below.
>>>
>>> Thanks,
>>>
>>> Chuck
>>>
>>> --------------------------------------------------------------
>>> Charles Bardeen
>>> National Center for Atmospheric Research
>>> P.O. Box 3000, Boulder, CO 80307-3000
>>> Phone: (303) 497-1752,  Fax: (303) 497-1400
>>> bardeenc at ucar.edu
>>>
>>>
>>>  Copyright (C) 1995-2015 - All Rights Reserved
>>>  University Corporation for Atmospheric Research
>>>  NCAR Command Language Version 6.3.0
>>>  The use of this software is governed by a License Agreement.
>>>  See http://www.ncl.ucar.edu/ for more details.
>>> ncl 0> x = addfile("gps031001g.002.hdf5", "r")
>>> ncl 1> print(x)
>>>
>>> Variable: x
>>> Type: file
>>> filename:       gps031001g.002
>>> path:   gps031001g.002.hdf5
>>>    file global attributes:
>>>    dimensions:
>>>       DIM_000 = 10
>>>       DIM_001 = 0
>>>       DIM_002 = 0
>>>       DIM_003 = 0
>>>    variables:
>>>       group </Data>
>>>
>>>
>>>       compound <Table_Layout>   (year, month, day, hour, min, sec,
>>> ut1_unix, ut2_unix, recno, gdlat, glon, tec, dtec) (DIM_000)
>>>
>>>       group </Metadata>
>>>
>>>
>>>       compound <Data_Parameters>        (mnemonic, description, isError,
>>> units, category) (DIM_000)
>>>
>>>       compound <Experiment_Notes>       (File Notes) (DIM_000)
>>>
>>>       compound <Experiment_Parameters>  (name, value) (DIM_000)
>>>
>>> ncl 5> g = x=>Data
>>> ncl 6> print(g)
>>>
>>> Variable: g
>>> Type: file
>>> filename:       gps031001g.002
>>> path:   gps031001g.002.hdf5
>>>    file global attributes:
>>>    dimensions:
>>>       DIM_000 = 10
>>>       DIM_001 = 0
>>>       DIM_002 = 0
>>>       DIM_003 = 0
>>>    variables:
>>>       compound <Table_Layout>   (year, month, day, hour, min, sec,
>>> ut1_unix, ut2_unix, recno, gdlat, glon, tec, dtec) (DIM_000)
>>>
>>> ncl 7> tec = g->/Table_Layout.tec
>>> fatal:["Execute.c":6332]:variable (/Table_Layout.tec) is not in file (g)
>>> fatal:["Execute.c":8573]:Execute: Error occurred at or near line 7
>>>
>>> ncl 9> tec = x->/Data/Table_Layout.tec
>>> fatal:["Execute.c":6332]:variable (/Data/Table_Layout.tec) is not in
>>> file (x)
>>> fatal:["Execute.c":8573]:Execute: Error occurred at or near line 9
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>> --------------------------------------------------------------
>> Charles Bardeen
>> National Center for Atmospheric Research
>> P.O. Box 3000, Boulder, CO 80307-3000
>> Phone: (303) 497-1752,  Fax: (303) 497-1400
>> bardeenc at ucar.edu
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170123/ac5aea58/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: out.gps
Type: application/octet-stream
Size: 6438 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170123/ac5aea58/attachment.obj 


More information about the ncl-talk mailing list