Design Document for NDFIN
NDFIN
AUTHOR: Tim Beckmann
Functional Summary:
Reads images from NLAPS Data Format (NDF) tapes, CD's, and disk and converts
them to a LAS image.
Comments:
none
Background:
This application replaces the old NDFIN and NDF2LAS applications. Those
applications only support NDF version 1. This new version of NDFIN adds
support for NDF version 2, multi-volume CD's, and multi-resolution
products.
Requirements:
Main Requirement:
- Convert files in NDF format versions 1 and 2 to LAS format
Input Formats:
- Only lower case file names can be supported due to LAS limitations
- Maintain compatibility to read NDF version 1 from tape or single volume
CD/disk
- Single header file with name extension of ".HD"
- Image file names are assumed to be ".I#" where # is the band number
- Support multi-volume tapes
- Support multi-volume CD's
- Support the capability to issue a mount request for the CD instead of
assuming the CD is already mounted and read the path to the CD from
the device information returned.
- Support the ability to read NDF version 2 from tape, CD, or disk
- Support single resolution BSQ products
- Single header file with name extension of ".h1"
- Support single resolution BIL products
- Single header file with name extension of ".h1"
- Support multi-resolution BSQ products
- Header files named ".H#" where #=resolution number
- Image file names are defined by the BAND#_FILENAME field in the
NDF header file
- Band numbers are extracted from the band file names in the NDF header
by pulling the band number from the ".I#" filename extension from
the BAND#_FILENAME field.
- Support multi-volume tapes and CD's for both NDF format versions 1 and 2
- Multi-volume indicated by the TAPE_SPANNING_FLAG in the
NDF header file being set to something besides 1/1 (like 1/2 and 2/2)
- When the image files for a resolution span multiple volumes,
the header file with the same name will appear on each of the
volumes. The header files on each volume will indicate the
files present on that volume.
- Number of image files per resolution indicated by
NUMBER_OF_DATA_FILES in the NDF header file
- Number of bands for the current resolution is indicated by
NUMBER_OF_BANDS_IN_VOLUME in the NDF header file, for both
BSQ and BIL.
- On multi-volume CD's, it is assumed that PDS will group the files
from each resolution together then order them by band number.
- Support a minimum of 9 CD's or tapes in a multi-volume product.
- Support converting the DEM image to a LAS image format.
- The DEM NDF header is named with a ".DH" extension.
- Support input images containing BYTE, I*2, I*4, and R*4 data.
Output Files:
- LAS image files with the associated DDR file
- The LAS format is constrained to holding a single resolution in each
file (but multiple bands may be included in each file)
- Merge files of the same resolution from different volumes as
directed by the NBANDS input parameter.
- Remove temporary files created during the conversion and merging
process.
- Sort the band list in ascending order, grouping files as directed by
NBANDS.
- If a specified output file name contains more than one resolution,
the different resolutions will be placed in separate files and have
a "_r#" appended to the output file name specified.
- Output file names should be all lower case.
Scope/Limitations:
- Multi-volume CD's and tapes must be mounted in the correct order.
- Only lower case file names are supported.
Overall design:
Flow diagram:
NDFIN
|
|--- FIND_HEADER_FILES
| |
| |--- getpar
| |--- unmount_media
| | |
| | |--- c_tpreop
| | |--- c_tpclos
| |
| |--- mount_media
| | |
| | |--- c_tpopen
| | |--- c_tpclos
| |
| |--- get_header_from_tape
| |--- get_header_from_disk
|
|--- ADD_TO_LIST
|--- READ_NDF_HEADER
| |
| |--- read_ndf_parameters
| | |
| | |--- get_file_size
| |
| |--- c_dtmnum
| |--- get_spheroid
| |--- c_putddr
| |--- c_putbdr
| |--- c_wndconv
| |--- c_wndchk
|
|--- TPIN-EOV
|--- RELDRIVE
|--- CMDEL-FILE
|--- CMRENAME
|--- TRANSLAS-IN
|--- COPY
|--- REMOVE_FROM_LIST
Algorithm:
Check that the parameters are legal
Verify the output files do not exist
Sort the BANDS list for each of the groups in NBANDS
Initialize the header_file_list to be empty
Initialize the file_cleanup_list to be empty
Initialize band_res array to zeros (same size as BANDS)
Initialize band_vol array to zeros (same size as BANDS)
Begin Loop
If the header file list is empty
Call the FIND_HEADER_FILES routine
If there are no files in the header_file_list
break out of loop
Get the first header file from the header_file_list (and remove it from
the list)
Read the header file with READ_NDF_HEADER
If bands appear in the bands_available_list
Update the band_res and band_vol arrays for the current band
If reading tape
Call TPIN to read the image files from the tape
Replace the DDR created by TPIN with the real DDR
Else
While bands remain in the bands_available_list
Remove the bands for the first NBANDS group from the list
Call TRANSLAS to read the image files from CD/disk
Replace the DDR created by TRANSLAS with the real DDR
End Loop
Merge image files from different volumes and remove unneeded _vol# extensions
Rename files to remove unneeded _r# extensions
Remove the temporary files created
Unmount the media if still mounted
On Error:
Unmount the mounted drive
If the DELFLG is YES
Delete the files in the delete list
Delete the files in the files created list
Module Design(s):
NDFIN:
The NDFIN PDF module is the main routine for the NDF ingest implementation.
PARAMETERS:
- COMMENT
- This is the mount message to issue for the tapes or CD's to be
mounted. This should only be entered when the source data is
tape or CD. For multi-volume tapes or CD's, a message should be
specified for each volume to be mounted.
- INFILE
- Pathname of input file for CD's and disk. When on CD's, the path
returned by the mount request must be added to this path.
- BANDS
- BANDS is the list of bands to process. The band numbers are the
band numbers assigned to the image files by PDS when it creates the
products. BANDS defaults to all bands present if it is not
specified.
- NBANDS
- NBANDS specifies how the bands in the BANDS parameter should be
grouped together when creating the output files. For example, if
BANDS=(1,3,2,4) and NBANDS=(2,1,1), three output files will be
created with the first output file containing bands 1 and 3, the
second containing band 2, and the third containing band 4. If
NBANDS is specified, BANDS must be specified and the number of bands
in BANDS must equal the sum of the bands in NBANDS.
- OUT
- List of output file names. If NBANDS is specified, the number of
entries in OUT must equal the number of entries in NBANDS. If NBANDS
is not specified and a single OUT file name is provided, all the
output bands with the same resolution will be placed in the same
file (with the _r# appended to the name if the source is NDF
version 2).
- DEMOUT
- Pathname to use for the DEM output file. If this parameter is set,
the source media will be searched for the NDF DEM header and
associated image file.
- WINDOW and UNITS
- Allows sub-windowing of the image files. The WINDOW is an array with
four members. The UNITS parameter may be set to LS (line/sample),
DEG(degrees), DMS(degrees-minutes-seconds), or PRO(projection). When
UNITS is LS, the WINDOW parameter is interpretted as (SL,SS,NL,NS).
For all other values of UNITS, WINDOW is interpretted as
(ULY, ULX, LRY, LRX). If only a portion of the window intersects
with the image, truncate the window to the image. If the window
does not intersect the image, it is a fatal error. If only the first
two window parameters are entered, default the last two to include
the rest of the image.
- ODTYPE
- Data type to use for the output image. Legal values are SAME, BYTE,
I*2, I*4, and R*4. The default is SAME.
- WRTDSK
- The WRTDSK (write disk) parameter allows auxiliary files on the
media to be copied to the working directory. The options supported
are HST (history file), WOR (work order processing file), and
NHDR (NDF header file). The NDF header files will have the volume
number appended to the file name. The default is none of the files.
ALGORITHM:
Refer to the Algorithm above.
Testing criteria:
The NDFIN module should be tested with the following types of data sets:
- NDF Revision 1 Data
-
- Media
- disk, tape, CD, multi-volume tape, multi-volume CD
- Data Types
- BSQ, BIL, BYTE, I*2, I*4, R*4
- Windowing
- DEG, DMG, LS, PRO
- NDF Revision 2 Data
-
- Media
- disk, tape, CD, multi-volume tape, multi-volume CD
- Data Types
- BSQ, BIL, BYTE, I*2, I*4, R*4, multiple resolution data sets
- Windowing
- DEG, DMG, LS, PRO