第八章 HDF命令行工具本章简介本章将介绍HDF命令行实用工具。
在本章中,用户将有机会练习一些最有用的HDF实用命令行工具,如hdp和vshow。
8.2 HDF命令行实用工具介绍HDF软件包提供了一组命令行实用工具。
HDF命令行实用工具是在命令行提示符下执行一些小的应用程序。
这些程序可使用户不用编写自己的程序即可执行普通操作。
HDF命令行工具分为三类:查询工具,转换工具和压缩工具。
表8a列出了这些工具的名称和描述。
假如已经安装了HDF4.1r3软件包,就可以在HDF4.1r3/bin子目录里找到这些程序。
设置正确的路径后,能从任何子目录执行这些命令行工具。
完整的HDF命令行工具列表可以在/UG41r3_html/UG_BookTOC15.html中找到。
表8a HDF命令行工具8.3 HDF查询工具8.3.1 hdphdp(HDF dumper)工具是从指定的HDF文件中获取所有对象通用信息最为有用的工具。
它可列出HDF 文件在各层的细节内容。
它还能把倾印出文件中一个或多个特定对象的数据。
hdf提供一组命令,允许用户确定显示何种信息。
下面例子展示怎样使用hdf获得example.hdf的信息,example.hdf是由前面章节的程序创建的。
如果没有创建你自己的example.hdf,可以下载example.hdf。
进入example.hdf文件所在的子目录,确保命令路径包含HDF工具目录,然后键入下列命令:示例输出:hdp list显示HDF文件的内容。
C:\HDF4.1r3\bin>hdp list example.hdfFile: example.hdfFile library version: Major= 4, Minor=1, Release=3String=NCSA HDF Version 4.1 Release 3, May 1999Version Descriptor : (tag 30)Ref nos: 1File Identifier : (tag 100)Ref nos: 1File Description : (tag 101)Ref nos: 1Number type : (tag 106)Ref nos: 1 12Image Dimensions : (tag 300)Ref nos: 1Raster Image Data : (tag 302)Ref nos: 1Raster Image Group : (tag 306)Ref nos: 1SciData dimension record: (tag 701)Ref nos: 12Scientific Data : (tag 702)Ref nos: 5Numeric Data Group : (tag 720)Ref nos: 4Vdata : (tag 1962)Ref nos: 6 8 10 15Vdata Storage : (tag 1963)Ref nos: 6 8 10 15Vgroup : (tag 1965)Ref nos: 2 3 7 9 11 13 14 16示例输出:hdp dumpsds显示HDF文件中科学数据集的内容C:\HDF4.1r3\bin>hdp dumpsds example.hdfFile name: example.hdfVariable Name = my SDSIndex = 0Type= 64-bit floating pointRef. = 4Rank = 3Number of attributes = 0Dim0: Name=fakeDim0Size = 2Scale Type = number-type not setNumber of attributes = 0Dim1: Name=fakeDim1Size = 5Scale Type = number-type not setNumber of attributes = 0Dim2: Name=fakeDim2Size = 3Scale Type = number-type not setNumber of attributes = 0Data :1.0000002.0000003.0000004.0000005.0000006.0000007.000000 8.000000 9.00000010.000000 11.000000 12.00000013.000000 14.000000 15.00000016.000000 17.000000 18.00000019.000000 20.000000 21.00000022.000000 23.000000 24.00000025.000000 26.000000 27.00000028.000000 29.000000 30.000000示例输出:hdp dumpsds显示HDF文件中科学数据集的内容。
C:\HDF4.1r3\bin>hdp dumpgr example.hdfFile name: example.hdfImage Name = My ImageIndex = 0Type= 8朾it unsigned integerwidth=10; height=8Ref. = 2ncomps = 1Number of attributes = 0Interlace= 0Data :0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1920 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 3637 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 5354 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 7071 72 73 74 75 76 77 78 79示例输出:hdp dumpgr显示example.hdf文件中GR对象的内容。
C:\HDF4.1r3\bin>hdp dumpvd 杗 "Simulation Data 1" example.hdfFile name: example.hdfFile Label #0: This is a file labelFile description #0: This is a file descriptionVdata: 3tag = 1962; reference = 15;number of records = 4; interlace = FULL_INTERLACE (0);fields = [X, Y, Temp];record size (in bytes) = 12;name = Simulation Data 1; class = 2D_Temperature_Grid;number of attributes = 0?field index 0: [X], type=5, order=1number of attributes = 0?field index 1: [Y], type=5, order=1number of attributes = 0?field index 2: [Temp], type=5, order=1number of attributes = 0Loc. Data0 2.300000 1.500000 23.500000 3.400000 5.700000 8.0300000.500000 3.500000 1.220000 1.800000 2.600000 0.000000注意:命令“vshow example.hdf +”可用来找出存于“example.hdf”文件中数据对象的名称。
示例输出:hdp dumpvg显示HDF文件中Vgroups的内容。
C:\HDF4.1r3\bin>hdp dumpvg 杗 "My Vgroup" example.hdfFile name: example.hdfFile Label #0: This is a file labelFile description #0: This is a file descriptionVgroup:7tag = 1965; reference = 16;name = My Vgroup; class = Example;number of entries = 2;number of attributes = 0Entries:?/P>#0 (Raster Image Group)tag = 306; reference = 2;#1 (Numeric Data Group)tag = 720; reference = 4;注意:命令“vshow example.hdf +”可用来找出存于“example.hdf”文件中数据对象的名称。
注意:每个hdp命令都提供一个可选标志。
完整信息请参见HDF用户指南。
8.3.2 hdflshdfls工具列出HDF文件中每个数据对象的标记和引用号。
这个命令行与hdp list命令的功能类似。
示例输出:hdfls工具C:\HDF4.1r3\bin>hdfls example.hdfexample.hdf:File library version: Major= 4, Minor=1, Release=3String=NCSA HDF Version 4.1 Release 3, May 1999Version Descriptor : (tag 30)Ref nos: 1File Identifier : (tag 100)Ref nos: 1File Description : (tag 101)Ref nos: 1Number type : (tag 106)Ref nos: 1 12Image Dimensions : (tag 300)Ref nos: 1Raster Image Data : (tag 302)Ref nos: 1Raster Image Group : (tag 306)Ref nos: 1SciData dimension record : (tag 701) Ref nos: 12Scientific Data : (tag 702)Ref nos: 5Numeric Data Group : (tag 720)Ref nos: 4Vdata : (tag 1962)Ref nos: 6 8 10 15Vdata Storage : (tag 1963)Ref nos: 6 8 10 15Vgroup : (tag 1965)Ref nos: 2 3 7 9 11 13 14 168.3.3 vshowvshow 工具显示HDF文件中Vdata对象的信息。