home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / graphics.formats / hdf / NCSA_HDF / HDF.7.ascii.Z / HDF.7.ascii
Encoding:
Text File  |  1991-09-24  |  31.7 KB  |  855 lines

  1. NCSA HDF Command Line Utilities7.1
  2.  
  3. National Center for Supercomputing Applications
  4.  
  5. November 1989
  6.  
  7.  
  8.  
  9. 7.1NCSA HDF Calling Interfaces and Utilities
  10.  
  11. NCSA HDF Command Line Utilities7.1
  12.  
  13. National Center for Supercomputing Applications
  14.  
  15. November 1989
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. Chapter 7NCSA HDF Command Line Utilities
  25.  
  26.  
  27.  
  28. Chapter Overview
  29. Introduction
  30. hdfls:  Listing Basic Information about an HDF
  31. hdfed:  Editing an HDF File
  32. Basics
  33. Tutorial Session
  34. hdfed with the -batch Option
  35. fptohdf:  Converting Floating-Point Data to SDS and/or RIS8
  36. Basics
  37. Notes
  38. Examples
  39. Utilities for Working with Raster Image Sets
  40. r8tohdf:  Converting 8-Bit Raster Images to HDF
  41. hdftor8:  Extracting 8-Bit Raster Images and Palettes from an HDF File
  42. r24tohdf:  Converting 24-Bit Raster Images to HDF 8-Bit Raster Images
  43. paltohdf:  Converting a Raw Palette to HDF
  44. hdftopal:  Extracting a Palette from an HDF file
  45. hdfrseq/hdfseq:  Displaying Images
  46.  
  47. Chapter Overview
  48.  
  49. A small but growing number of utility routines and command line utilities are available for working with HDF files. Currently available programs are described below.
  50.  
  51.  
  52. Introduction
  53.  
  54. The command line utilities are application programs that can be executed by entering them at the command level, just like other UNIX commands. These utilities serve two purposes:
  55.  
  56. 1)They make it possible for you to perform, at the command level, common operations on HDF files for which you would normally have to write your own program. For example, the utility r8tohdf is a program that takes a raw raster image from a file and stores it in an HDF file in a raster image set.
  57.  
  58. 2)They provide capabilities for doing things with HDF files that would be very difficult to do under your own program control. For example, the utility hdfseq takes a a raster image from an HDF file and displays it immediately on a Sun-3 console.
  59.  
  60. Table 7.1 lists the names and the functions of the utilities described in this chapter. The following sections provide descriptions and examples of these routines.
  61.  
  62. Table 7.1Scientific Dataset Routines in the HDF Library
  63. NameFunction
  64.  
  65. hdflsdisplays the tags, ref numbers, and (optionally) lengths of data elements.
  66.  
  67. hdfedlets you browse in an HDF file and manipulate some of the data. 
  68.  
  69. fptohdfconverts floating-point data to HDF floating-point data and/or 8-bit raster images.
  70.  
  71. r8tohdfconverts one or more raw 8-bit images to HDF RIS8 format and writes them to a file, possibly with palettes.
  72.  
  73. hdftor8converts images and or palettes from HDF format to raw format and stores them in two corresponding sets of files.
  74.  
  75. r24tohdfconverts a raw RGB 24-bit image to an 8-bit RIS8 with a palette.
  76.  
  77. paltohdfconverts a raw palette to hdf format.
  78.  
  79. hdftopalconverts palette in an hdf file to raw format.
  80.  
  81. hdfseq/hdfrseqdisplays sequences of images directly to the screen from  HDF files containing raster images.
  82.  
  83.  
  84. hdfls:   Listing Basic Information about  an HDF File
  85.  
  86. The utility hdfls provides a quick look at the tags, reference numbers, and (optionally) lengths of the data elements. The syntax for hdfls is:
  87.  
  88. hdfls [-o] [-l] filename
  89.  
  90. -oOrder: Indicates that the reference numbers are to be displayed in ascending order.
  91.  
  92. -lLong format: Displays more information about the file.
  93.  
  94. Example 1
  95. A file called aa.hdf contains three items associated with a raster image:  (1) the image dimensions, (2) a palette, and (3) the raster image. To display information about the contents of the file, enter:
  96.  
  97. hdfls aa.hdf
  98.  
  99. The following is displayed:
  100.  
  101. aa.hdf:
  102. Image Dimensions-8  (Raster-8)  : (tag 200)
  103. Ref nos: 1
  104. Image Palette-8     (Raster-8)  : (tag 201)
  105. Ref nos: 3
  106. Raster Image-8      (Raster-8)  : (tag 202)
  107. Ref nos: 1
  108.  
  109.  
  110. To display the same information together with the length of each data element, enter:
  111.  
  112. hdfls -l aa.hdf
  113.  
  114. The resulting display is:
  115.  
  116. aa.hdf:
  117. Image Dimensions-8  (Raster-8)  : (tag 200)
  118. Ref no      1          4 bytes
  119.  
  120. Image Palette-8     (Raster-8)  : (tag 201)
  121. Ref no      3        768 bytes
  122.  
  123. Raster Image-8      (Raster-8)  : (tag 202)
  124. Ref no      1     120000 bytes
  125.  
  126.  
  127. hdfed:   Editing an HDF File
  128.  
  129. Basics
  130. The hdfed utility provides all the capabilities of hdfls, but also allows you to examine the data itself and to move data between two HDF files. It is not currently possible to edit individual data objects with hdfed.
  131.  
  132. hdfed is modeled to some extent after ed, the Unix line editor. When you invoke hdfed, your terminal screen acts as a window into an HDF file. Your initial view of the file is as a set of tags and reference numbers. Each tag/ref combination uniquely identifies a data object in the file. 
  133.  
  134. NOTE:  The term data object in this context refers to the tag/ref for the data, plus the data itself. The term data or  data element  refers to the actual data that the tag/ref refers to. This "data" may be descriptive information, such as a label or dimension record for an image. The term group refers to a predefined collection of data objects that correspond to a particular application. For instance, a "raster image group" refers to the collection of data objects that are used to store all of the information in a Raster Image Set.)
  135.  
  136. Once you have opened an HDF file with hdfed, you can do several things with the file, including the following:
  137.  
  138. ÑSelect an HDF object to examine more closely.
  139. ÑMove forward or backward among the objects in the file.
  140. ÑGet information about an object (tag, ref, size, label).
  141. ÑDisplay a raster image  using the ICR protocol.
  142. ÑDisplay a dump of any object.
  143. ÑDelete an object.
  144. ÑAnnotate an object.
  145. ÑWrite an object to another HDF file.
  146. ÑWrite a data element in its binary form to a non-HDF file.
  147. ÑClose the file and exit, or open a new file.
  148.  
  149. hdfed also has a small set of special commands, including a conditional statement, a looping statement, an alias command and an unalias command. A simple 'help' feature also exists.
  150.  
  151. The syntax for hdfed is:
  152.  
  153. hdfed [filename] [-nobackup] [-batch]
  154.  
  155.  
  156. If filename is present, the corresponding file is opened, and a backup is made of the file. Otherwise, a file may be opened from within the editor. 
  157.  
  158.  
  159. Options
  160. Ñ- nobackup
  161. Specifies that no backup file is to be made. If this option
  162. is omitted, a backup file is automatically created.
  163.  
  164.  
  165. Ñ- batch
  166. Specifies that input to hdfed is to be input via a stream of
  167. hdfed commands, rather than interactively.
  168.  
  169. To receive usage information, as well as a quick list of the hdfed commands, type the command:
  170.  
  171. hdfed -help
  172.  
  173. While you are using the editor, you receive the prompt:
  174.  
  175. he>
  176.  
  177. You can now enter hdfed commands. 
  178.  
  179. Many hdfed commands have qualifiers, or flags. For instance the info command may optionally be followed by  -all, -long, 
  180. -group, or -label. 
  181.  
  182. All of the commands and flags can be abbreviated to the extent that their abbreviations are unique. For example -he is an ambiguous abbreviation because it could stand for either the flag 
  183. -hexadecimal or the flag -help; on the other hand, the flag 
  184. -hel is not ambiguous.
  185.  
  186. To obtain information about the usage of a command, type:
  187.  
  188. <command> -help
  189.  
  190. Do not just type the command and expect a help line. Some commands, such as delete, do not need any argument, so this could have unfortunate results.
  191.  
  192. Table 7.2 lists the hdfed commands:
  193.  
  194. Table 7.2hdfed Commands
  195. NameFunction
  196.  
  197. helpProvide help on use of hdfed
  198. openOpen HDF file
  199. closeClose HDF file
  200. revertRevert to original file
  201. nextGo to next object/group that satisfies predicate
  202. prevGo to previous object/group that satisfies predicate
  203. infoShow information about data object
  204. dumpDisplay data in binary, ASCII, etc.
  205. displayDisplay a raster image using ICR
  206. Table 7.2hdfed Commands (Continued)
  207. NameFunction
  208.  
  209. putPut data element as binary into raw file
  210. putr8Put an ris8 group into raw file
  211. getr8Get an ris8 group from raw file
  212. deleteDelete an object/group
  213. writeWrite an object/group to another HDF file
  214. annotateAnnotate an object
  215. ifConditional statement
  216. selectLoop for each object
  217. aliasSet or show aliases
  218. unaliasRemove an alias
  219. waitMessage and wait for return
  220.  
  221.  
  222. Tutorial Session
  223.  
  224. In the absence of a user's manual for hdfed, this document contains a tutorial in the form of a session on the editor. Examples of almost all of the commands are given below. In the following script, bold characters represent those typed by a user. Plain text characters represent characters that were printed by the computer.
  225.  
  226. Figure 7.1Tutorial Session
  227.  
  228. zaphod|2% he
  229. he> ! This is a script of a session on the HDF editor.
  230. he> ! It is meant as an example for anyone learning to use 
  231. he> ! the editor.
  232. he> ! The exclamation mark in the FIRST column starts 
  233. !he> ! a comment
  234. he> 
  235. helphe> ! help command
  236. he> help
  237. Type <command> -help for usage of command
  238. e.g. "open -help" give help on the open command
  239. DO NOT just type the command and expect a help line
  240. Some commands like delete do not need any argument
  241. If you are just starting to learn, try this program on 
  242. a file that is expendable
  243.  
  244. List of commands:
  245. ----------------
  246. openOpen HDF file
  247. closeClose HDF file
  248. ...
  249. ...
  250. openhe> ! opening a file
  251. he> 
  252. he> open -help
  253. open <file> [-nobackup]
  254. -nobackupDon't make a backup for this file.
  255. he> 
  256.  
  257. he> open h1
  258. he> 
  259. infohe> ! look into the contents of this file
  260. he> ! using info
  261. he> 
  262. he> info -help
  263. Figure 7.1Tutorial Session (Continued)
  264.  
  265. info [-all] [-long] [-group] [-label]
  266. -allShow info for all elements in file
  267. -longShow more info
  268. -groupOrganize info in group(s)
  269. -labelShow label if any
  270. he> 
  271. he> info -all -label -long
  272. (1) Machine type        (Utility)   : (tag 107)
  273. Ref: 4369, Offset: 0, Length: 0 (bytes)
  274. Label: Sun Machine type??
  275. (2) Scientific Data     (SciData)   : (tag 702)
  276. Ref: 1, Offset: 202, Length: 40000 (bytes)
  277. (3) Number type         (Utility)   : (tag 106)
  278. Ref: 1, Offset: 40202, Length: 4 (bytes)
  279. (4) SciData description (SciData)   : (tag 701)
  280. Ref: 1, Offset: 40206, Length: 22 (bytes)
  281. (5) SciData scales      (SciData)   : (tag 703)
  282. Ref: 1, Offset: 40228, Length: 802 (bytes)
  283. (6) SciData max/min     (SciData)   : (tag 707)
  284. Ref: 1, Offset: 41030, Length: 8 (bytes)
  285. *(7) Scientific Data Group (SciData) : (tag 700)
  286. Ref: 1, Offset: 41038, Length: 16 (bytes)
  287. Label: testing 1 2 3 4 5 6 7 8 9 0....<additional stuff>
  288. (8) Data Id Label       (Utility)   : (tag 104)
  289. Ref: 2, Offset: 41275, Length: 53 (bytes)
  290. (9) Data Id Label       (Utility)   : (tag 104)
  291. Ref: 3, Offset: 41230, Length: 22 (bytes)
  292. (10) Data Id Annotation  (Utility)   : (tag 105)
  293. Ref: 4, Offset: 41252, Length: 23 (bytes)
  294. Empty (tag 1) : 6 slots.
  295. he> info -group -all
  296. **Group 1:
  297. Scientific Data Group (SciData) : (tag 700), Ref: 1
  298. Scientific Data     (SciData)   : (tag 702), Ref: 1
  299. SciData description (SciData)   : (tag 701), Ref: 1
  300. SciData scales      (SciData)   : (tag 703), Ref: 1
  301. SciData max/min     (SciData)   : (tag 707), Ref: 1
  302.  
  303. **These do not belong to any group:
  304. Machine type        (Utility)   : (tag 107), Ref: 4369
  305. Number type         (Utility)   : (tag 106), Ref: 1
  306. Data Id Label       (Utility)   : (tag 104), Ref: 2
  307. Data Id Label       (Utility)   : (tag 104), Ref: 3
  308. Data Id Annotation  (Utility)   : (tag 105), Ref: 4
  309. Empty (tag 1) : 6 slots.
  310. he> 
  311. nexthe> ! Move in the file using next and prev.
  312. prevhe> ! The move direction depends on the relative positions,
  313. predicateshe> ! so it is often necessary to do an 'info -all' first
  314. he> 
  315. he> info -all
  316. (1) Machine type        (Utility)   : (tag 107), Ref: 4369
  317. (2) Scientific Data     (SciData)   : (tag 702), Ref: 1
  318. (3) Number type         (Utility)   : (tag 106), Ref: 1
  319.  
  320. (4) SciData description (SciData)   : (tag 701), Ref: 1
  321. (5) SciData scales      (SciData)   : (tag 703), Ref: 1
  322. (6) SciData max/min     (SciData)   : (tag 707), Ref: 1
  323. *(7) Scientific Data Group (SciData) : (tag 700), Ref: 1
  324. (8) Data Id Label       (Utility)   : (tag 104), Ref: 2
  325. (9) Data Id Label       (Utility)   : (tag 104), Ref: 3
  326. Figure 7.1Tutorial Session (Continued)
  327.  
  328. (10) Data Id Annotation  (Utility)   : (tag 105), Ref: 4
  329. Empty (tag 1) : 6 slots.
  330. he> 
  331. *he> ! The '*' in the first column marks the current
  332. he> ! position.
  333. he> ! The next and prev commands work on predicates.
  334. he> ! Default predicate is "group".
  335. he> ! This means that each move will move to the next/prev
  336. he> ! group if I now want to move to the max/min element,
  337. he> ! I can use the 'tag=' predicate
  338. he> 
  339. he> prev tag=707
  340. he> info 
  341. (6) SciData max/min     (SciData)   : (tag 707), Ref: 1
  342. he> 
  343. he> ! Other predicates are ref", "any", with comparators 
  344. he> ! "=", "!=", ">", "<", ">=", "<=" 
  345. he> ! For example, "group ref >= 10" is legal and matches
  346. he> ! a group with ref>=10.
  347. he> 
  348. he> ! This predicate persist for next and prev. 
  349. he> ! That means that if I now do another 'next'
  350. he> ! it will look for a tag=707
  351. he> 
  352. he> next
  353. Reached end of file. Not moved.
  354. he> info
  355. (6) SciData max/min     (SciData)   : (tag 707), Ref: 1
  356. he> 
  357. he> ! to go back to groups 
  358. he> next group
  359. he> info
  360. (7) Scientific Data Group (SciData) : (tag 700), Ref: 1
  361. he> 
  362. dumphe> ! to see the binary representation of this element
  363. he> 
  364. he> dump -help
  365. dump [-offset <offset>] [-length <len>]
  366. [-decimal|-octal|-hexadecimal|-float|-ascii]
  367. Od the present element
  368. -offsetStart offset
  369. -lengthLength to look at
  370. -decimalDecimal format
  371. -octalOctal format
  372. -hexadecimalHexadecimal format
  373. -floatFloat format
  374. -asciiAscii format
  375. he> 
  376. he> dump 
  377. 0000000  001276 000001 001275 000001 001277 000001 001303 000001
  378. 0000020
  379. he> 
  380. he> dump -decimal
  381. 0000000  00702 00001 00701 00001 00703 00001 00707 00001
  382. 0000020
  383. he> 
  384. deletehe> ! deleting groups
  385. he> 
  386. he> delete -help
  387. delete
  388.  
  389. Figure 7.1Tutorial Session (Continued)
  390.  
  391. Delete this element or group.
  392. he> 
  393. he> ! If an element is required by other groups it is
  394. he> ! alone.  However, this is not perfect since the way
  395. he> ! group membership is determined can be pretty ad hoc
  396. he> 
  397. he> info -all -group
  398. **Group 1:
  399. Scientific Data Group (SciData) : (tag 700), Ref: 1
  400. Scientific Data     (SciData)   : (tag 702), Ref: 1
  401. SciData description (SciData)   : (tag 701), Ref: 1
  402. SciData scales      (SciData)   : (tag 703), Ref: 1
  403. SciData max/min     (SciData)   : (tag 707), Ref: 1
  404.  
  405. **These do not belong to any group:
  406. Machine type        (Utility)   : (tag 107), Ref: 4369
  407. Number type         (Utility)   : (tag 106), Ref: 1
  408. Data Id Label       (Utility)   : (tag 104), Ref: 2
  409. Data Id Label       (Utility)   : (tag 104), Ref: 3
  410. Data Id Annotation  (Utility)   : (tag 105), Ref: 4
  411. Empty (tag 1) : 6 slots.
  412. he> delete
  413. he> ! This deletes the Scientific Data Group.
  414. he> info -all
  415. (1) Machine type        (Utility)   : (tag 107), Ref: 4369
  416. (3) Number type         (Utility)   : (tag 106), Ref: 1
  417. (8) Data Id Label       (Utility)   : (tag 104), Ref: 2
  418. (9) Data Id Label       (Utility)   : (tag 104), Ref: 3
  419. (10) Data Id Annotation  (Utility)   : (tag 105), Ref: 4
  420. Empty (tag 1) : 11 slots.
  421. he> 
  422. he> ! Let's delete an element.
  423. he> 
  424. he> next tag=104 ref=3
  425. he> info -all
  426. (1) Machine type        (Utility)   : (tag 107), Ref: 4369
  427. (3) Number type         (Utility)   : (tag 106), Ref: 1
  428. (8) Data Id Label       (Utility)   : (tag 104), Ref: 2
  429. *(9) Data Id Label       (Utility)   : (tag 104), Ref: 3
  430. (10) Data Id Annotation  (Utility)   : (tag 105), Ref: 4
  431. Empty (tag 1) : 11 slots.
  432. he> delete
  433. he> info -all
  434. (1) Machine type        (Utility)   : (tag 107), Ref: 4369
  435. (3) Number type         (Utility)   : (tag 106), Ref: 1
  436. (8) Data Id Label       (Utility)   : (tag 104), Ref: 2
  437. (10) Data Id Annotation  (Utility)   : (tag 105), Ref: 4
  438. Empty (tag 1) : 12 slots.
  439. he> 
  440. reverthe> ! Reverting to original, unaltered file. This
  441. he> ! cannot work if nobackup is used when opening.
  442. he> ! the file.
  443. he> ! Here we revert back to the original file:
  444. he> revert
  445. he> 
  446. annotatehe> ! Annotations are labels and descriptors.
  447. he> 
  448. he> annotate -help
  449. annotate [-label|-descriptor] [-editor <editor>]
  450. Edit an annotation
  451. -labelEdit label (default)
  452. Figure 7.1Tutorial Session (Continued)
  453.  
  454. -descriptorEdit descriptor
  455. -editorUse editor (default EDITOR env value)
  456. he> 
  457. he> annotate -editor /usr/ucb/ex
  458. "/tmp/he965.0" 1 line, 32 characters
  459. :p
  460. testing 1 2 3 4 5 6 7 8 9 0....
  461. :s/$/<some additional stuff>/
  462. testing 1 2 3 4 5 6 7 8 9 0....<some additional stuff>
  463. :wq
  464. "/tmp/he965.0" 1 line, 55 characters
  465. he> info -label
  466. (7) Scientific Data Group (SciData) : (tag 700), Ref: 1
  467. Label: testing 1 2 3 4 5 6 7 8 9 0....<some additional stuff>
  468. he> 
  469. he> annotate -descriptor -editor /usr/ucb/ex
  470. "/tmp/he965.1" 1 line, 48 characters
  471. :p
  472. gdshjfhjdf asdgy sdf sdgf sdfg sgdfh as dbf asl
  473. :c
  474. This is the descriptor, it can have non-graphic characters
  475. .
  476. :wq
  477. "/tmp/he965.1" 1 line, 58 characters
  478. he> 
  479. he> info -all
  480. (1) Machine type        (Utility)   : (tag 107), Ref: 4369
  481. ...
  482. *(7) Scientific Data Group (SciData) : (tag 700), Ref: 1
  483. (8) Data Id Label       (Utility)   : (tag 104), Ref: 2
  484. (9) Data Id Label       (Utility)   : (tag 104), Ref: 3
  485. (10) Data Id Annotation  (Utility)   : (tag 105), Ref: 4
  486. (11) Data Id Annotation  (Utility)   : (tag 105), Ref: 5
  487. (12) Data Id Annotation  (Utility)   : (tag 105), Ref: 6
  488. (13) Data Id Annotation  (Utility)   : (tag 105), Ref: 7
  489. Empty (tag 1) : 3 slots.
  490. he> 
  491. writehe> ! Write to another HDF file
  492. he> 
  493. he> write -help
  494. write <file> [-attachto <atag> <aref>]
  495. Write an element or group into another HDF file
  496.   -attachto:     ONLY for writing annotations
  497.   <atag>/<aref>: What element to attach annotation to
  498. he> 
  499. he> write test
  500. he> 
  501. he> ! Let's look at the file 'test'.
  502. he> close;open test;info -all
  503. (1) Scientific Data     (SciData)   : (tag 702), Ref: 1
  504. (2) Scientific Data     (SciData)   : (tag 702), Ref: 2
  505. (3) Scientific Data     (SciData)   : (tag 702), Ref: 3
  506. (4) Number type         (Utility)   : (tag 106), Ref: 3
  507. (5) SciData description (SciData)   : (tag 701), Ref: 3
  508. (6) SciData scales      (SciData)   : (tag 703), Ref: 3
  509. (7) SciData max/min     (SciData)   : (tag 707), Ref: 3
  510. *(8) Scientific Data Group (SciData) : (tag 700), Ref: 3
  511. Empty (tag 1) : 8 slots.
  512. he> 
  513. he> close;
  514. he> 
  515. displayhe> !We will open a file with some RIS8 images.
  516. Figure 7.1Tutorial Session (Continued)
  517.  
  518. he> 
  519. he> open denm.HDF
  520. he> display
  521. he>
  522. he> ! display displays the current r8 group image via ICR.
  523. he> ! I.e. if you are using NCSA Telnet on a MacII, this
  524. he> ! would display the images from denm.hdf on your screen
  525. he> ! NOTE: not guaranteed to work otherwise.
  526. he> 
  527. putr8he> ! putr8 puts an r8 group into raw files
  528. he> putr8 -help
  529. putr8 [-image <image>] [-palette <pal>] [-verbose]
  530. Put an r8 group into raw image and palette files
  531. -imageImage file name template (default "img#.@.%")
  532. -palettePalette file name template (default "pal#")
  533. -verboseTo give output of steps taken
  534. he> 
  535. he> putr8 -image my_image#.@.% -palette my_palette -verbose
  536. Writing to file: my_image5.512.256
  537. Writing to file: my_palette
  538. he> 
  539. getr8he> ! getr8 works in the reverse fashion
  540. he> getr8 -help
  541. getr8 <image> <xdim> <ydim> [-palette <palette>] [-raster|-rle|-imcomp]
  542. Get a r8 group from raw files
  543. -paletteRaw palette file
  544. -rasterNo compression (default)
  545. -rleRun-length compression
  546. -imcompImcomp compression
  547. he> 
  548. selecthe> ! To step through a file and, say, putr8 on all r8
  549. he> ! groups we can use the select command
  550. he> 
  551. he> select -help
  552. select [<predicates>]
  553. <commands>*
  554. end
  555. Steps through all elements in the file that satisfies the
  556. predicates and execute the commands on them.
  557. he> 
  558. he> select tag=306
  559. >> putr8 -image testImages# -palette testPalettes# -verbose
  560. >> end
  561. Writing to file: testImages5
  562. Writing to file: testPalettes5
  563. Writing to file: testImages12
  564. Writing to file: testPalettes12
  565. Writing to file: testImages19
  566. Writing to file: testPalettes19
  567. he> 
  568. he> ! select and if commands take the same predicates as
  569. he> ! next and pref.  There are also the predicates 
  570. he> ! "succeed" and "fail" that test the return status
  571. he> ! of the last command.
  572. he> 
  573. puthe> ! put puts an element into a binary file
  574. he> ! This is a dumb routine and does not know about the
  575. he> ! formats of the element
  576. he> 
  577. he> put -help
  578. Figure 7.1Tutorial Session (Continued)
  579.  
  580. put [-file <file>] [-verbose]
  581. Put the raw binary of this element in a file
  582. -fileOut file name (default "element#.@")
  583. -verboseOutput diagnostic info
  584. he> 
  585. he> put -file binary#
  586. he> put -file myBinary -verbose
  587. Writing to file: myBinary
  588. he> 
  589. he> ! that's it for now
  590. he> revert;close;quit
  591. zaphod|2% 
  592.  
  593.  
  594.  
  595.  
  596. hdfed with the -batch Option
  597. Sometimes we want to have hdfed execute a series of commands, without waiting for a prompt between commands. This process is useful when a certain sequence of hdfed commands is commonly used, as illustrated in the following shell script:
  598.  
  599. #!/bin/csh -f
  600. set file=$1
  601. shift
  602. hdfed -batch $file -nobackup << EOF
  603. info -all -group $*
  604. close
  605. quit
  606. EOF
  607. echo ""
  608.  
  609. This shell script lists information about the groups in an HDF file. The "-batch"  in the line that calls hdfed tells hdfed that the edit commands are to be taken from the stream of characters beginning on the next line and ending with the EOF symbol.
  610.  
  611.  
  612. fptohdf:   Converting Floating-Point Data to SDS and/or RIS8
  613.  
  614. Basics
  615. fptohdf is a utility that converts floating-point arrays  (from either text files or HDF scientific datasets) to either HDF 8-bit raster image sets (RIS8) or HDF scientific datasets (SDS), or both, and stores the results in an HDF file (see Fig. 7.2).
  616.  
  617. Figure 7.2The fptohdf Utility
  618.  
  619.  
  620. The syntax for fptohdf is as follows:
  621.  
  622. fptohdf infile [infile ...] -o outfile [out_opts]
  623.  
  624. out_opts: 
  625. [[-I] [[-e|-i] <horiz> <vert>] [-p palfile]] 
  626. [-F]
  627.  
  628. Ñinfile is a file containing a single floating-point array in 
  629. either text or HDF SDS format. If the format is text, see "Notes" below on how it must be organized.
  630.  
  631. Ñoutfile is a file containing the converted dataset in HDF format. Depending on out_opts, outfile contains a scientific dataset and/or raster  image set for each of the datasets in the input files.
  632.  
  633.  
  634. Options
  635. -IStores as image in raster image set in output file
  636.  
  637. -e  Expands float data via pixel replication to produce image (default if -I option chosen)
  638.  
  639. -i  Applies bilinear interpolation when expanding float data to produce image
  640.  
  641. <horiz> <vert>
  642.  
  643. when -e or -i options are chosen, these give the resolution in pixels of the desired image
  644.  
  645. -p palfile
  646. Stores palette with image; get palette from HDF file palfile.
  647.  
  648. -FStores as scientific dataset in output file (default)
  649. Notes
  650. Image expansion is available via either pixel replication (-e) or bilinear interpolation (-i), but not both.
  651.  
  652. An optional palette can accompany the image by loading it from an HDF file that contains a palette.
  653.  
  654. Data from several input files (one set per input file) are stored as several datasets and/or images in one output file. Alternatively, a shell script can be used to call fptohdf repeatedly to convert data from several input files to several corresponding HDF files.
  655.  
  656. If an HDF file is used for input, it must contain an SDS. The SDS need only contain a dimension record and the data, but if it also contains max and min values and/or scales for the horizontal and vertical axes, these will be used also.
  657.  
  658. If a text file is used for input, it must follow the format shown in Figure 7.3.
  659.  
  660. Figure 7.3Format Used in a Text File for Input
  661.  
  662.  
  663.  
  664. Note:  There are nrows vertical axis scale values and ncols horizontal axis scale values. data1, data2, etc., are the floating-point data and are assumed to be ordered by rows, left to right and top to bottom.
  665.  
  666.  
  667. Examples
  668. Example 1
  669. Convert floating-point data in file f1.txt to a SDS format, and store it as an SDS in HDF file o1:
  670.  
  671. fptohdf f1.txt -o o1 
  672.  
  673.  
  674. Example 2
  675. Convert floating-point data in file f2 to an 8-bit raster image and store it as an RIS8 in file o2:
  676.  
  677. fptohdf f2 -o o2 -I
  678.  
  679. Example 3
  680. Convert floating-point data in file f3 to RIS8 format and SDS format and store both the RIS8 and the SDS in file o3:
  681.  
  682. fptohdf f3 -o o3 -I -F
  683.  
  684. Example 4
  685. Convert floating-point data in file f4 to a 500 x 600 raster image, storing the corresponding RIS8 in file o4. Also store a palette from palfile with the image:
  686.  
  687. fptohdf f4 -o o4 -I -e 500 600 -p palfile
  688.  
  689.  
  690. Example 5
  691. Convert floating-point data in all files whose names begin with the letter 'f ' to 500 x 600 images and store the corresponding RIS8s in file o5:
  692.  
  693. fptohdf f* -o o5 -I -i 500 600 
  694.  
  695.  
  696. Utilities for Working with Raster Image Sets
  697.  
  698. There are three utility programs for working with HDF files that contain raster image sets. These routines can be executed interactively at the command level without being embedded in programs.
  699.  
  700.  
  701. r8tohdf:  Converting 8-Bit Raster Images to HDF
  702. The utility r8tohdf converts one or more raw images to HDF RIS8 format and writes them to a file. The syntax for storing one RIS8 in a file using r8tohdf is as follows:
  703.  
  704. r8tohdf rows cols outfile [-p palfile] {[-c],[-r],
  705. [-i]} imf1 imf2 ...
  706.  
  707.  
  708. where
  709.  
  710. Ñrows and cols are the number of rows and columns, respectively, of the raster image
  711.  
  712. Ñoutfile is the file that will contain the raster image set, and
  713.  
  714. Ñimf1, imf2, and so forth, are files containing 8-bit raw raster images.
  715.  
  716.  
  717. Options
  718. -p palfileoptionally stores a file containing a palette in the RIS8. If -p is not specified, no palette is stored in the RIS8.
  719.  
  720. {[-c],[-r],[-i]}optionally chooses compression by run length encoding (-c), compression by the IMCOMP method 
  721. (-i), or no compression (-r). The default is -r.
  722.  
  723. Example 1
  724. A 256 x 512 byte raw raster image is contained in a file called rawras, and the palette with which it is to be used is stored in a file called mypal. To convert this information to an RIS8 without compression and store the result in a file called ras.hdf, enter:
  725.  
  726. r8tohdf 256 512 ras.hdf -p mypal rawras
  727.  
  728.  
  729. Example 2
  730. A 800 x 1000 byte raw raster image is stored in a file called bigpic. You want to first convert this information to an RIS8 with run length encoding for compression and no palette, and then store the result in a file called bigpic.hdf. Enter:
  731.  
  732. r8tohdf 800 1000 bigpic.hdf -c bigpic
  733.  
  734.  
  735. Example 3
  736. Three 300 x 400 raw images are contained in files pic1, pic2, and pic3. To convert all three files to RIS8s with imcomp compression and store them in pic.hdf, enter:
  737.  
  738. r8tohdf 300 400 pic.hdf -i pic1 pic2 pic3
  739.  
  740.  
  741. Example 4
  742. A combination of different types of raster image sets is to be stored in a file called ras.hdf. The image from file rawras1 is to be stored without a palette. The images from rawras2 are to be stored with a palette that is copied from a file called mypal. The images from rawras1 and rawras2 are to be compressed using run length encoding, and rawras3 is not to be compressed. All images are 
  743. 256 x 512.
  744.  
  745. r8tohdf 256 512 ras.hdf -c rawras1 -p mypal rawras2 -r rawras3
  746.  
  747.  
  748.  
  749. hdftor8:  Extracting Images and Palettes from an HDF File
  750. The utility hdftor8 extracts the images and or palettes from an HDF file and stores them in two sets of files that contain only images and palettes, respectively. The syntax for hdftor8 is as follows:
  751.  
  752. hdftor8 hdf_file [-i] [-v] [-r image_file] [-p palette_file]
  753.  
  754.  
  755. Where hdf_file is the file to extract images and palettes from, and image_file and palette_file are basic names of  the files that will contain the images and palettes. These names are extended as follows:  For each image file, the filename is given the extension ".#.@.%", where # stands for the image number from the original file, @ is the x dimension of the image, and % is the y dimension of the image. For each palette file, the filename is given the extension ".#", where # stands for the palette number from the original file.
  756.  
  757. If no names are given for the image file, the default name "img.#.@.%" is used, where #, @ and % are defined as in the preceding paragraph. Similarly the default name for a palette file is "pal.#".
  758.  
  759.  
  760. Options
  761. -iputs the program in interactive mode, so you can specify filenames interactively.
  762.  
  763. -vspecifies verbose mode, providing descriptive messages.
  764.  
  765. -rindicates that the file whose name follows is to hold images.
  766.  
  767. -pindicates that the file whose name follows is to hold palettes.
  768.  
  769.  
  770. Example 5
  771. A file called denm.hdf contains three 512 x 256 images and three palettes. To extract these images and palettes and put them in separate files, enter:
  772.  
  773. hdftor8 denm.hdf
  774.  
  775. Six files are produced with the names img1.512.256, img2.512.256, img3.512.256, pal.1, pal.2, and pal.3.
  776.  
  777.  
  778. r24tohdf8:  Converting 24-bit Raster Image to HDF 8-Bit Raster Images
  779. The command line utility r24tohdf8 quantizes a raw RGB 24-bit pixel image into an 8-bit image with a 256-color palette and stores both the palette and image in an HDF file.
  780.  
  781. The syntax for r24tohdf8 is:
  782.  
  783. r24tohdf8 x_dim y_dim r24_file hdf8_file
  784.  
  785.  
  786. x_dim is the x dimension of the image (horizontal zize).
  787.  
  788. y_dim is the y dimension of the image (vertical zize).
  789.  
  790. r24_file is a file containing the raw RGB 24 bit image. The order of pixels is left to right and top to bottom. Each pixel is three contiguous bytes: red byte, green byte,  and blue byte. Use filter ptox to convert  from "planar" to "pixel" where planar means all red bytes for the whole image, followed  by all green bytes for the whole image,  followed by all blue bytes for the whole  image.
  791.  
  792. hdf8_file, the output file, is an HDF file with one 8-bit raster image set; i.e. 8-bit image, dimensions, and RGB palette.
  793.  
  794.  
  795. paltohdf:  Converting a Raw Palette to HDF
  796. paltohdf converts a raw palette to HDF format. The incoming palette is assumed to have 768 bytes organized in the following order:  256 red values, 256 green values, and 256 blue values. The palette in the HDF file will have the RGB values interlaced: RGB RGB RGB... This is standard HDF format for 8-bit palettes.
  797.  
  798. The syntax for paltohdf is:
  799.  
  800. paltohdf rawpalfile hdffile
  801.  
  802.  
  803. rawpalfile is a 768-byte input file with the red, green, and blue components stored as described above.
  804.  
  805. hdffile, the output file, is an HDF file. If hdffile does not exist, it is created and the palette is added to it. If it already exists, the palette is appended to it.
  806.  
  807.  
  808. hdftopal:  Extracting a palette from an HDF file
  809. hdftopal converts a palette from an HDF file to a raw palette in a raw palette file. The outgoing palette will have 768 bytes: first 256 red values, then 256 greens, then 256 blues.
  810.  
  811. The syntax for hdftopal is:
  812.  
  813. hdftopal hdffile rawpalfile
  814.  
  815.  
  816. hdffile, the input file, is an HDF file containing a palette.
  817.  
  818. rawpalfile is a 768-byte output file with the red, green, and blue components stored as described above.
  819.  
  820.  
  821. hdfrseq and hdfseq:  Displaying Images
  822. The utilities hdfseq and hdfrseq display sequences of images, one after the other, from files containing raster image sets. 
  823.  
  824. Although hdfseq and hdfrseq perform essentially the same function, the situations in which they are used are different. hdfseq displays images on a Sun-3 console and on any SGI IRIS that has gllib, when those images are stored at  the Sun 3 or IRIS workstation. When hdfseq executes on a file, it causes the raster image to be displayed immediately on the console.
  825.  
  826. hdfrseq performs the same operation, only remotely, via a terminal emulator such as Telnet 2.3 or Teltool 1.2. (The "r" in hdfrseq stands for remote.)  When hdfrseq executes on a file, it converts the image from RIS8 format to NCSA's ICR (interactive color raster) format and sends it to the receiving terminal. ICR is a protocol that is easy to transmit to a remote display station. If the receiving software on the display station can decipher the ICR protocol, it displays the image on the console. 
  827.  
  828. In a typical application, the display station would be running a program, such as NCSA Telnet (Version 2.3 or later) or NCSA Teltool (Version 1.2 or later), that understands ICR and immediately converts the incoming stream to a screen display.
  829.  
  830. The syntax for hdfseq is:
  831.  
  832. hdfseq [-s] [-l] [-p xloc yloc] [-e expansion] file1 file2 ...
  833.  
  834.  
  835. file1, file2, and so forth are HDF files that contain raster image sets. Only one image is displayed per file. If more than one file is listed, the corresponding images are displayed in sequence, that is, in the order in which the files are listed. Each new image overwrites the preceding image on the screen.
  836.  
  837.  
  838. Options
  839. -ssingle step through the images. Once an image is displayed, it remains on the screen until you press RETURN to display the next image or enter Q to quit.
  840.  
  841. -lmakes the image as large as possible on the screen.
  842.  
  843. -p xloc ylocplaces the upper left corner of the display at position (xloc, yloc) on the screen.
  844.  
  845. -e expansionexpands the image by the expansion factor specified by expansion.
  846.  
  847. The syntax for hdfrseq is exactly the same. 
  848.  
  849. Example 6
  850. Five images are stored in RIS8 form in the files star1, star2, star3, star4, and star5. You want to use hdfrseq to display all five images, in sequence, but with a pause between them. To make them appear on screen three times their normal size, enter:
  851.  
  852. hdfrseq -s -e 3 star1 star2 star3 star4 star5
  853.  
  854.  
  855.