HiRISE
 Observation

Defines | Functions | Variables

HiRISE_Observation.cc File Reference

#include "Data_Component.hh"
#include "Observation.hh"
#include "FELICS_Line_Cache.hh"
#include "Channel_ID.hh"
#include "Exceptions.hh"
#include "PVL.hh"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <exception>
#include <stdexcept>
Include dependency graph for HiRISE_Observation.cc:

Defines

#define EDR_FILENAME_EXTENSION   "IMG"
#define CHANNEL_FILENAME_EXTENSION   "DAT"
#define PVL_FILENAME_EXTENSION   "PVL"
#define _VERSION_   " "

Functions

int usage (char *program, bool list_descriptions=false)
 HiRISE_Observation.
void list_selections (const Observation &observation, unsigned int data_selections, bool verbose)
void list_selections (PVL::Aggregate &parameters, vector< char * > &parameter_names, PVL::Lister &lister, bool verbose)
Gap_Mapgap_map (istream &source, long location, unsigned int entries)
int main (int count, char **arguments)

Variables

const char * EDR_Filename_Extension = EDR_FILENAME_EXTENSION
 Filename extension for output EDR files.
const char * Channel_Filename_Extension = CHANNEL_FILENAME_EXTENSION
 Filename extension for output channel data files.
const char * PVL_Filename_Extension = PVL_FILENAME_EXTENSION
 Filename extension for output detailed PVL data description files.
const int SUCCESS = 0
 Exit status values.
const int BAD_SYNTAX = 1
const int UNFEASIBLE = 2
const int INVALID_ARGUMENT = 11
const int LENGTH_ERROR = 12
const int UNDERFLOW_ERROR = 13
const int OUT_OF_RANGE = 14
const int LOGIC_ERROR = 19
const int RUNTIME_ERROR = 40
const int NO_OBSERVATION_FILE = 20
const int NO_EDR_FILE = 21
const int NO_CHANNEL_FILE = 22
const int NO_PVL_FILE = 23
const int IO_FAILURE = 29
const int PVL_ERROR = 30
const int UNKNOWN_ERROR = -1
const char * ID = "(2.48 2010/11/25 02:51:30)"
 Application identification name with source code version and date.
const char * Software_Name_Parameter = "SOFTWARE_NAME"
 Names of EDR PDS parameters that will have their values updated.
const char * Source_Filename_Parameter = "SOURCE_FILE_NAME"
const char * Target_Name_Parameter = "TARGET_NAME"
const char * Rationale_Description_Parameter = "RATIONALE_DESC"
const char * Commanded_ID_Parameter = "MRO:COMMANDED_ID"
const char * Gap_Table_Rows_Parameter = "GAP_TABLE/ROWS"
const char * Label_Records_Parameter = "LABEL_RECORDS"
 EDR PDS parameters accessed.
const char * Gap_Table_Location_Parameter = "^GAP_TABLE"
const char * Pixel_Bits_Parameter = "IMAGE/SAMPLE_BITS"
const char * Lookup_Conversion_Table_Parameter = "MRO:LOOKUP_CONVERSION_TABLE"
const int LABEL_WIDTH = 20
 Listing format widths.
const int VALUE_WIDTH = 9
const unsigned int NO_DATA = 0
 Data list selectors.
const unsigned int MROSP = (1 << 0)
const unsigned int SCIENCE = (1 << 1)
const unsigned int LOOKUP_TABLE = (1 << 2)
const unsigned int ENGINEERING = (1 << 3)
const unsigned int PDS_LABEL = (1 << 4)
const unsigned int GAP_MAP = (1 << 5)
const unsigned int HEADERS
const unsigned int PVL_FORMAT = (1 << 7)

Define Documentation

#define EDR_FILENAME_EXTENSION   "IMG"
#define CHANNEL_FILENAME_EXTENSION   "DAT"
#define PVL_FILENAME_EXTENSION   "PVL"
#define _VERSION_   " "

Function Documentation

int usage ( char *  program,
bool  list_descriptions = false 
)

HiRISE_Observation.

Use:

HiRISE_Observation [Options] <filename>

Description:

The HiRISE_Observation application can be used to examine the contents of a HiRISE instrument observation data set file or EDR product file. It can produce detailed data listings of selected data components formatted in both columnar text format or PVL parameter format. It can also list selected parameters, including parameter groups, from an EDR product PDS label.

HiRISE_Observation accepts both single channel and multi-channel observation data sets, with or without an initial MROSP header component. It is able to generate a PDS compliant EDR product file from each channel data sequence it finds in an observation data set file. The number of image lines designated as calibration data in the EDR product file may be specified. It can be used to break a multi-channel observation data set into single channel data files, and can produce a channel data file from an EDR product file. During channel data sequence processing, channel 1 image pixels may be mirrored, and single byte pixels may be reverse LUT mapped (pukool) to two byte pixel values.

Options:

Channel selection

-Sequence <number> | <name>

All of the options that follow may be limited to a single channel data sequence. A sequence number may be specified, where the first channel is number 1. A channel ID may be specified in the form:

<CCD>_<channel>

where

CCD is RED{0-9}|IR{10,11}|BG{12,13} and channel is 0|1.

Default: All channel data sequences are processed.

Product generation

-EDR <directory>

The directory where PDS EDR product files will be written. One file will be written for each channel data sequence selected. The EDR product filename will be the channel ID for component data written to the file with a ".IMG" extension.

Default: No EDR product is generated.

-Channels <directory>

The directory where the channel data file will be written. One file will be written for each channel data sequence selected. The channel data filename will be the channel ID for the channel data written to the file with a ".DAT" extension.

Default: No channel data is written.

-Force
Force overwritting of files with the same name. Normally if a file exists with the same name and location as an intended output EDR or Channel file the existing file will not be overwritten; an exit is taken with a NO_EDR_FILE (21) or NO_CHANNEL_FILE (22) exit status.

Product specifications

-Data_Version <version>

The version identification to be appended to the DATA_SET_ID and DATA_SET_NAME parameters in the PDS label of output EDR files.

Default: "1.0"

-Product_Version <version>

The version identification to be appended to the PRODUCT_VERSION_ID in the PDS label of output EDR files.

Default: "1.0"

-Target <name>

The value of the TARGET_NAME PDS parameter." << endl

Default: "MARS"

-Description <description>

The text for the RATIONALE_DESC EDR PDS label parameter.

Default: ""

-CAlibration_lines <lines>

The minimum number of initial channel data set image lines to be designated as calibration data in output EDR product files.

Default: 20

N.B.: The actual number of calibration lines for each channel will not be less than a calculated amount that depends on the number of TDI stages and binning factors of the instrument.

-[No_]Mirror[_0]

Mirroring causes the image pixel data of each channel 1 sequence to be reverse ordered; i.e. horizontally flipped. The buffer and black (dark) pixels are not mirrored.

Default: Mirroring is enabled for EDR output generation; EDR source data is only mirrored if specified. Output channel data is only mirrored if specified. Channel 0 image data is only mirrored if specified with '0' in the option name." << endl;

-[No_]PUkool [<percent>]

All pixels are mapped through the reverse lookup table from 1-byte output values back to 2-byte CCD sensor values. For an EDR product the LOOKUP_CONVERSION_TABLE is used. For an observation data set the LUT component pukool table is used. The percent value - an integer in the range 0 to 100 inclusive - selects the offset in the possible range of 2-byte sensor values where the 1-byte value will be located.

Defaults: No pukool; 50 percent offset.

Report listings

-ID

The channel ID text representation - which includes the Observation ID plus CPMM and channel number extensions - of each channel data sequence found is listed. No other output will be generated. All other options will be disabled.

Default: Off

-Report[_PVL] [<selection>[,...]]

Detailed listings of selected data components are written to stdout. If a PVL report is specified the report will be formatted as a PVL listing rather than the more detailed tablular listing. The <selection> may be:

Headers (i.e. MROSP,Science,LUT,Engineering)
MROSP
Science
LUT
Engineering
Line:<first>[-<last>]
Gaps
PDS[:<parameter>[:...]

Multiple, comma separated (no spaces) data components may be selected. One or a range of lines may be selected. Multiple, colon separated (no spaces) parameters may be selected. If the PDS label component of an EDR product file is specified but no parameter is selected the entire PDS label is listed. EDR source input and/or EDR product output parameters are listed. Component selections are cumulative for each use of this option.

Default: No reports

-Quiet | Verbose

Verbose operation provides some additional annotations and very detailed (and long) data listings.

Default: Quiet

-Help

This usage description.

-VERSION
Software version identification. When preceded by -verbose the versions of the classes used are also provided.

Exit status:

0 Success
   
1 Command line usage syntax
1 Unfeasible operation

Software/data problem

11 Invalid argument
12 Length error
13 Underflow error
14 Out of range
19 Logic error

I/O

20 No observation file
21 No EDR file
22 No channel file
23 No PVL file
29 I/O failure

PVL

30 PVL processing failure
   
-1 Unknown error

Author:

Bradford Castalia, UA/PIRL

2.48 2010/11/25 02:51:30

References BAD_SYNTAX, Channel_Filename_Extension, Image_Line::DEFAULT_CALIBRATION_LINES, Observation::DEFAULT_DATA_SET_VERSION, Observation::DEFAULT_PRODUCT_VERSION, LUT::DEFAULT_PUKOOL_OFFSET, EDR_Filename_Extension, Observation::mirror_channel_1_default(), and Observation::TARGET_NAME.

Referenced by Label_Patcher::Label_Patcher(), and main().

void list_selections ( const Observation observation,
unsigned int  data_selections,
bool  verbose 
)
void list_selections ( PVL::Aggregate parameters,
vector< char * > &  parameter_names,
PVL::Lister lister,
bool  verbose 
)
Gap_Map * gap_map ( istream &  source,
long  location,
unsigned int  entries 
)

Referenced by main().

int main ( int  count,
char **  arguments 
)

References Image_Line::bad_line(), Image_Line::bad_line_description(), Image_Line::Black_Pixels, Image_Line::Buffer_Pixels, Image_Line::bytes_read(), Observation::bytes_read(), Image_Line::calibration_lines(), Instrument::CCD_NAMES, Instrument::CCDS, Science_Channel_Header::Channel, Channel_Filename_Extension, Channel_ID::channel_number(), Science_Channel_Header::Checksum, Commanded_ID_Parameter, Observation::components(), Image_Line::compressed_bytes(), Image_Line::compressed_data(), Data_Block::count_of(), Science_Channel_Header::CPMM, CCD_ID::cpmm_number(), Observation::data_set_version(), Image_Line::decompressed_bytes(), Image_Line::DEFAULT_CALIBRATION_LINES, LUT::DEFAULT_PUKOOL_OFFSET, EDR_file(), EDR_Filename_Extension, Observation::Engineering, ENGINEERING, file_exists(), gap_map(), GAP_MAP, Gap_Table_Location_Parameter, Gap_Table_Rows_Parameter, Observation::Gaps, Data_Component::get(), HEADERS, hostname(), Observation_ID::ID, Instrument::ID, Data_Component::ID, FELICS_Line_Cache::ID, Line_Cache::ID, Image_Line::ID, Engineering_Header::ID, LUT::ID, Science_Channel_Header::ID, MROSP_Header::ID, Observation::ID, ID, Image_Line::Image_Pixels, Data_Component::internet_checksum(), INVALID_ARGUMENT, Observation_ID::INVALID_OBSERVATION_ID, IO_FAILURE, Label_Records_Parameter, LABEL_WIDTH, Observation_ID::LAUNCH, LENGTH_ERROR, Observation::line(), Observation::Line, list_selections(), LOGIC_ERROR, Lookup_Conversion_Table_Parameter, Observation::Lookup_Table, LOOKUP_TABLE, Engineering_Header::LUT_Compressed, Image_Line::mirror(), Observation::mirror_channel_1(), Observation::mirror_channel_1_default(), Observation_ID::mission_phase(), MROSP, NO_CHANNEL_FILE, NO_DATA, NO_EDR_FILE, NO_OBSERVATION_FILE, Science_Channel_Header::Observation_ID, OUT_OF_RANGE, Data_Block::output(), PDS_LABEL, Pixel_Bits_Parameter, Science_Channel_Header::Pixel_Bytes, Image_Line::pixel_bytes(), Image_Line::pixel_count(), Science_Channel_Header::Pixel_Data_Bytes, Image_Line::print(), Gap_Map::print(), Observation::product_version(), Image_Line::pukool(), LUT::pukool_table(), Data_Component::put(), Image_Line::PVL(), Gap_Map::PVL(), PVL_ERROR, PVL_FORMAT, Observation::PVL_PDS(), Observation::PVL_PDS_BYTES, Rationale_Description_Parameter, RUNTIME_ERROR, Observation::Science, SCIENCE, Data_Block::size(), Software_Name_Parameter, Image_Line::source_bytes(), Source_Filename_Parameter, Lister::strict(), SUCCESS, Target_Name_Parameter, Channel_ID::text(), Observation_ID::text(), Lister::total(), Gap_Map::total_gaps(), Image_Line::total_lines(), UNDERFLOW_ERROR, UNFEASIBLE, UNKNOWN_ERROR, usage(), Parameter::value(), Observation_ID::value(), and VALUE_WIDTH.


Variable Documentation

const char* EDR_Filename_Extension = EDR_FILENAME_EXTENSION

Filename extension for output EDR files.

Referenced by main(), and usage().

const char* Channel_Filename_Extension = CHANNEL_FILENAME_EXTENSION

Filename extension for output channel data files.

Referenced by main(), and usage().

const char* PVL_Filename_Extension = PVL_FILENAME_EXTENSION

Filename extension for output detailed PVL data description files.

const int SUCCESS = 0

Exit status values.

Referenced by Label_Patcher::apply_patch(), Label_Patcher::Label_Patcher(), and main().

const int BAD_SYNTAX = 1

Referenced by set_effective_values(), and usage().

const int UNFEASIBLE = 2

Referenced by main().

const int INVALID_ARGUMENT = 11

Referenced by main().

const int LENGTH_ERROR = 12

Referenced by main().

const int UNDERFLOW_ERROR = 13

Referenced by main().

const int OUT_OF_RANGE = 14

Referenced by main().

const int LOGIC_ERROR = 19

Referenced by main().

const int RUNTIME_ERROR = 40

Referenced by main().

const int NO_OBSERVATION_FILE = 20

Referenced by main().

const int NO_EDR_FILE = 21

Referenced by main().

const int NO_CHANNEL_FILE = 22

Referenced by main().

const int NO_PVL_FILE = 23

Referenced by main().

const int IO_FAILURE = 29

Referenced by Label_Patcher::apply_patch(), and main().

const int PVL_ERROR = 30

Referenced by main().

const int UNKNOWN_ERROR = -1

Referenced by main().

const char* ID = "(2.48 2010/11/25 02:51:30)"
const char* Software_Name_Parameter = "SOFTWARE_NAME"

Names of EDR PDS parameters that will have their values updated.

Referenced by main().

const char * Source_Filename_Parameter = "SOURCE_FILE_NAME"

Referenced by main().

const char * Target_Name_Parameter = "TARGET_NAME"

Referenced by main().

const char * Rationale_Description_Parameter = "RATIONALE_DESC"

Referenced by main().

const char * Commanded_ID_Parameter = "MRO:COMMANDED_ID"

Referenced by main().

const char * Gap_Table_Rows_Parameter = "GAP_TABLE/ROWS"

Referenced by main().

const char* Label_Records_Parameter = "LABEL_RECORDS"

EDR PDS parameters accessed.

Referenced by main().

const char * Gap_Table_Location_Parameter = "^GAP_TABLE"

Referenced by main().

const char * Pixel_Bits_Parameter = "IMAGE/SAMPLE_BITS"

Referenced by main().

const char * Lookup_Conversion_Table_Parameter = "MRO:LOOKUP_CONVERSION_TABLE"

Referenced by main().

const int LABEL_WIDTH = 20

Listing format widths.

Referenced by main().

const int VALUE_WIDTH = 9

Referenced by main().

const unsigned int NO_DATA = 0

Data list selectors.

Referenced by list_data(), list_selections(), and main().

const unsigned int MROSP = (1 << 0)
const unsigned int SCIENCE = (1 << 1)

Referenced by list_data(), list_selections(), and main().

const unsigned int LOOKUP_TABLE = (1 << 2)

Referenced by list_data(), list_selections(), and main().

const unsigned int ENGINEERING = (1 << 3)

Referenced by list_data(), list_selections(), and main().

const unsigned int PDS_LABEL = (1 << 4)

Referenced by main().

const unsigned int GAP_MAP = (1 << 5)

Referenced by list_selections(), and main().

const unsigned int HEADERS
Initial value:

Referenced by main().

const unsigned int PVL_FORMAT = (1 << 7)

Referenced by list_selections(), and main().