HiRISE
 Observation

Macros | 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:

Macros

#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. More...
 
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. More...
 
const char * Channel_Filename_Extension = CHANNEL_FILENAME_EXTENSION
 Filename extension for output channel data files. More...
 
const char * PVL_Filename_Extension = PVL_FILENAME_EXTENSION
 Filename extension for output detailed PVL data description files. More...
 
const int SUCCESS = 0
 Exit status values. More...
 
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
 Application identification name with source code version and date. More...
 
const char * Software_Name_Parameter = "SOFTWARE_NAME"
 Names of EDR PDS parameters that will have their values updated. More...
 
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. More...
 
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. More...
 
const int VALUE_WIDTH = 9
 
const unsigned int NO_DATA = 0
 Data list selectors. More...
 
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)
 

Macro Definition Documentation

◆ EDR_FILENAME_EXTENSION

#define EDR_FILENAME_EXTENSION   "IMG"

◆ CHANNEL_FILENAME_EXTENSION

#define CHANNEL_FILENAME_EXTENSION   "DAT"

◆ PVL_FILENAME_EXTENSION

#define PVL_FILENAME_EXTENSION   "PVL"

◆ _VERSION_

#define _VERSION_   " "

Function Documentation

◆ usage()

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

HiRISE_Observation.

Use:

<b>HiRISE_Observation</b> [<i>Options</i>] &lt;<i>filename</i>&gt;

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.49 2020/02/14 01:17:17

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().

◆ list_selections() [1/2]

void list_selections ( const Observation observation,
unsigned int  data_selections,
bool  verbose 
)

◆ list_selections() [2/2]

void list_selections ( PVL::Aggregate parameters,
vector< char * > &  parameter_names,
PVL::Lister lister,
bool  verbose 
)

◆ gap_map()

Gap_Map * gap_map ( istream &  source,
long  location,
unsigned int  entries 
)

Referenced by Observation::gap_map_shift(), and main().

◆ main()

int main ( int  count,
char **  arguments 
)

References Image_Line::bad_line(), Image_Line::bad_line_description(), Lister::begin_aggregates(), 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, UA::HiRISE::file_exists(), UA::HiRISE::filename(), GAP_MAP, gap_map(), Gap_Table_Location_Parameter, Gap_Table_Rows_Parameter, Observation::Gaps, Data_Component::get(), HEADERS, UA::HiRISE::hostname(), Observation_ID::ID, Instrument::ID, Data_Component::ID, Engineering_Header::ID, FELICS_Line_Cache::ID, Image_Line::ID, Line_Cache::ID, LUT::ID, MROSP_Header::ID, Observation::ID, Science_Channel_Header::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(), UA::HiRISE::pathname(), PDS_LABEL, Pixel_Bits_Parameter, Image_Line::pixel_bytes(), Science_Channel_Header::Pixel_Bytes, Image_Line::pixel_count(), Science_Channel_Header::Pixel_Data_Bytes, Gap_Map::print(), Image_Line::print(), Observation::product_version(), Image_Line::pukool(), UA::HiRISE::pukool_table(), LUT::pukool_table(), Data_Component::put(), Gap_Map::PVL(), Image_Line::PVL(), PVL_ERROR, PVL_FORMAT, UA::HiRISE::PVL_parameter(), Observation::PVL_PDS(), Observation::PVL_PDS_BYTES, UA::HiRISE::PVL_value(), Rationale_Description_Parameter, RUNTIME_ERROR, Observation::Science, SCIENCE, UA::HiRISE::shift(), Data_Block::size(), Software_Name_Parameter, Image_Line::source_bytes(), Source_Filename_Parameter, Lister::strict(), SUCCESS, Target_Name_Parameter, Observation_ID::text(), Channel_ID::text(), Lister::total(), Gap_Map::total_gaps(), Image_Line::total_lines(), UNDERFLOW_ERROR, UNFEASIBLE, UNKNOWN_ERROR, usage(), Observation_ID::value(), Parameter::value(), and VALUE_WIDTH.

Variable Documentation

◆ EDR_Filename_Extension

const char* EDR_Filename_Extension = EDR_FILENAME_EXTENSION

Filename extension for output EDR files.

Referenced by main(), and usage().

◆ Channel_Filename_Extension

const char* Channel_Filename_Extension = CHANNEL_FILENAME_EXTENSION

Filename extension for output channel data files.

Referenced by main(), and usage().

◆ PVL_Filename_Extension

const char* PVL_Filename_Extension = PVL_FILENAME_EXTENSION

Filename extension for output detailed PVL data description files.

◆ SUCCESS

const int SUCCESS = 0

Exit status values.

Referenced by main().

◆ BAD_SYNTAX

const int BAD_SYNTAX = 1

Referenced by usage().

◆ UNFEASIBLE

const int UNFEASIBLE = 2

Referenced by main().

◆ INVALID_ARGUMENT

const int INVALID_ARGUMENT = 11

Referenced by main().

◆ LENGTH_ERROR

const int LENGTH_ERROR = 12

Referenced by main().

◆ UNDERFLOW_ERROR

const int UNDERFLOW_ERROR = 13

Referenced by main().

◆ OUT_OF_RANGE

const int OUT_OF_RANGE = 14

Referenced by main().

◆ LOGIC_ERROR

const int LOGIC_ERROR = 19

Referenced by main().

◆ RUNTIME_ERROR

const int RUNTIME_ERROR = 40

Referenced by main().

◆ NO_OBSERVATION_FILE

const int NO_OBSERVATION_FILE = 20

Referenced by main().

◆ NO_EDR_FILE

const int NO_EDR_FILE = 21

Referenced by main().

◆ NO_CHANNEL_FILE

const int NO_CHANNEL_FILE = 22

Referenced by main().

◆ NO_PVL_FILE

const int NO_PVL_FILE = 23

◆ IO_FAILURE

const int IO_FAILURE = 29

Referenced by main().

◆ PVL_ERROR

const int PVL_ERROR = 30

Referenced by main().

◆ UNKNOWN_ERROR

const int UNKNOWN_ERROR = -1

Referenced by main().

◆ ID

const char* ID
Initial value:
=
"HiRISE_Observation"
"(2.49 2020/02/14 01:17:17)"
#define _VERSION_
Definition: HiRISE_Observation.cc:526

Application identification name with source code version and date.

Referenced by Data_Component::id(), and main().

◆ Software_Name_Parameter

const char* Software_Name_Parameter = "SOFTWARE_NAME"

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

Referenced by main().

◆ Source_Filename_Parameter

const char * Source_Filename_Parameter = "SOURCE_FILE_NAME"

Referenced by main().

◆ Target_Name_Parameter

const char * Target_Name_Parameter = "TARGET_NAME"

Referenced by main().

◆ Rationale_Description_Parameter

const char * Rationale_Description_Parameter = "RATIONALE_DESC"

Referenced by main().

◆ Commanded_ID_Parameter

const char * Commanded_ID_Parameter = "MRO:COMMANDED_ID"

Referenced by main().

◆ Gap_Table_Rows_Parameter

const char * Gap_Table_Rows_Parameter = "GAP_TABLE/ROWS"

Referenced by main().

◆ Label_Records_Parameter

const char* Label_Records_Parameter = "LABEL_RECORDS"

EDR PDS parameters accessed.

Referenced by main().

◆ Gap_Table_Location_Parameter

const char * Gap_Table_Location_Parameter = "^GAP_TABLE"

Referenced by main().

◆ Pixel_Bits_Parameter

const char * Pixel_Bits_Parameter = "IMAGE/SAMPLE_BITS"

Referenced by main().

◆ Lookup_Conversion_Table_Parameter

const char * Lookup_Conversion_Table_Parameter = "MRO:LOOKUP_CONVERSION_TABLE"

Referenced by main().

◆ LABEL_WIDTH

const int LABEL_WIDTH = 20

Listing format widths.

Referenced by main().

◆ VALUE_WIDTH

const int VALUE_WIDTH = 9

Referenced by main().

◆ NO_DATA

const unsigned int NO_DATA = 0

Data list selectors.

Referenced by list_selections(), and main().

◆ MROSP

const unsigned int MROSP = (1 << 0)

Referenced by list_selections(), and main().

◆ SCIENCE

const unsigned int SCIENCE = (1 << 1)

Referenced by list_selections(), and main().

◆ LOOKUP_TABLE

const unsigned int LOOKUP_TABLE = (1 << 2)

Referenced by list_selections(), and main().

◆ ENGINEERING

const unsigned int ENGINEERING = (1 << 3)

Referenced by list_selections(), and main().

◆ PDS_LABEL

const unsigned int PDS_LABEL = (1 << 4)

Referenced by main().

◆ GAP_MAP

const unsigned int GAP_MAP = (1 << 5)

Referenced by list_selections(), and main().

◆ HEADERS

const unsigned int HEADERS
Initial value:
= MROSP |
const unsigned int LOOKUP_TABLE
Definition: HiRISE_Observation.cc:564
const unsigned int ENGINEERING
Definition: HiRISE_Observation.cc:565
const unsigned int MROSP
Definition: HiRISE_Observation.cc:562
const unsigned int SCIENCE
Definition: HiRISE_Observation.cc:563

Referenced by main().

◆ PVL_FORMAT

const unsigned int PVL_FORMAT = (1 << 7)

Referenced by list_selections(), and main().