diff --git a/AUTHORS.rst b/AUTHORS.rst
index 23124c7c1e..93b262096a 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -55,6 +55,7 @@ ISIS3 Contributors
- Steven Lambright
- Stuart Sides
- Summer Stapleton
+- Timothy Giroux
- Tracie Sucharski
- Travis Addair
- Tyler Wilson
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 737a463fa9..fe8ad6c5c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,6 +38,7 @@ update the Unreleased link so that it compares against the latest release tag.
- Equalizer now reports the correct equation and values used to perform the adjustment. [#3987](https://github.com/USGS-Astrogeology/ISIS3/issues/3987)
- Map2cam now works correctly when specifying bands for input cubes. [#3856](https://github.com/USGS-Astrogeology/ISIS3/issues/3856)
+ - mro/hideal2pds app now writes the correct SAMPLE_BIT_MASK values to the output label. [#3978](https://github.com/USGS-Astrogeology/ISIS3/issues/3978)
### Added
diff --git a/isis/src/mro/apps/hidtmgen/MroHiriseIdealPds.pft b/isis/src/mro/apps/hideal2pds/MroHiriseIdealPds.pft
similarity index 100%
rename from isis/src/mro/apps/hidtmgen/MroHiriseIdealPds.pft
rename to isis/src/mro/apps/hideal2pds/MroHiriseIdealPds.pft
diff --git a/isis/src/mro/apps/hidtmgen/MroHiriseIdealPds.typ b/isis/src/mro/apps/hideal2pds/MroHiriseIdealPds_16bit.typ
similarity index 100%
rename from isis/src/mro/apps/hidtmgen/MroHiriseIdealPds.typ
rename to isis/src/mro/apps/hideal2pds/MroHiriseIdealPds_16bit.typ
diff --git a/isis/src/mro/apps/hideal2pds/hiriseIdealPds.typ b/isis/src/mro/apps/hideal2pds/MroHiriseIdealPds_8bit.typ
similarity index 96%
rename from isis/src/mro/apps/hideal2pds/hiriseIdealPds.typ
rename to isis/src/mro/apps/hideal2pds/MroHiriseIdealPds_8bit.typ
index 9dff8d1e5c..f76ce2452f 100644
--- a/isis/src/mro/apps/hideal2pds/hiriseIdealPds.typ
+++ b/isis/src/mro/apps/hideal2pds/MroHiriseIdealPds_8bit.typ
@@ -25,7 +25,7 @@ INSTRUMENT_HOST_NAME = String
TARGET_NAME = String
MISSION_PHASE_NAME = String
ORBIT_NUMBER = Integer
-SOURCE_PRODUCT_ID = String
+#SOURCE_PRODUCT_ID = String
RATIONALE_DESC = String
SOFTWARE_NAME = String
SAMPLE_DETECTORS = Integer
@@ -33,7 +33,7 @@ LINE_DETECTORS = Integer
INSTRUMENT_TYPE = Enum
EPHEMERIS_TIME = Real
FOCAL_PLANE_X_DEPENDENCY = Integer
-EXPOSURE_DURATION = (Real, 4)
+EXPOSURE_DURATION = (Real, 6)
IMAGE_JITTER_CORRECTED = Integer
SHAPE_MODEL = String
A_AXIS_RADIUS = (Real, 2)
@@ -68,7 +68,7 @@ BANDS = Integer
OFFSET = Real
SCALING_FACTOR = Real
SAMPLE_BITS = Integer
-SAMPLE_BIT_MASK = ("Binary",16)
+SAMPLE_BIT_MASK = ("Binary",8)
SAMPLE_TYPE = Enum
FILTER_NAME = String
CENTER_FILTER_WAVELENGTH = Real
diff --git a/isis/src/mro/apps/hideal2pds/hideal2pds.xml b/isis/src/mro/apps/hideal2pds/hideal2pds.xml
index d128f56e97..6a624d3642 100644
--- a/isis/src/mro/apps/hideal2pds/hideal2pds.xml
+++ b/isis/src/mro/apps/hideal2pds/hideal2pds.xml
@@ -59,6 +59,9 @@
Added an option to control the output bits. min = 8, max =16, default = 10. Fixes #5527.
+
+ Output label now has the correct SAMPLE_BIT_MASK value according to bits input. Fixes #3978.
+
diff --git a/isis/src/mro/apps/hideal2pds/hiriseIdealPds.pft b/isis/src/mro/apps/hideal2pds/hiriseIdealPds.pft
deleted file mode 100644
index 0ba52cc7ba..0000000000
--- a/isis/src/mro/apps/hideal2pds/hiriseIdealPds.pft
+++ /dev/null
@@ -1,173 +0,0 @@
-PDS_VERSION_ID
-RECORD_TYPE
-RECORD_BYTES
-FILE_RECORDS
-LABEL_RECORDS
-^IMAGE
-^INSTRUMENT_POINTING_TABLE
-^INSTRUMENT_POSITION_TABLE
-^BODY_ROTATION_TABLE
-^SUN_POSITION_TABLE
-NOT_APPLICABLE_CONSTANT
-DATA_SET_ID
-DATA_SET_NAME
-PRODUCER_INSTITUTION_NAME
-PRODUCER_ID
-PRODUCER_FULL_NAME
-OBSERVATION_ID
-PRODUCT_ID
-PRODUCT_VERSION_ID
-SPACECRAFT_NAME
-INSTRUMENT_ID
-INSTRUMENT_NAME
-INSTRUMENT_HOST_ID
-INSTRUMENT_HOST_NAME
-TARGET_NAME
-MISSION_PHASE_NAME
-ORBIT_NUMBER
-SOURCE_PRODUCT_ID
-RATIONALE_DESC
-SOFTWARE_NAME
-SAMPLE_DETECTORS
-LINE_DETECTORS
-INSTRUMENT_TYPE
-FOCAL_LENGTH
-PIXEL_PITCH
-EPHEMERIS_TIME
-FOCAL_PLANE_X_DEPENDENCY
-TRANS_X
-TRANS_Y
-EXPOSURE_DURATION
-MATCHED_CUBE
-IMAGE_JITTER_CORRECTED
-SHAPE_MODEL
-A_AXIS_RADIUS
-B_AXIS_RADIUS
-C_AXIS_RADIUS
-BODY_FRAME_CODE
-IDEAL_FOCAL_LENGTH
-IDEAL_PIXEL_PITCH
-IDEAL_TRANSX
-IDEAL_TRANSY
-IDEAL_TRANSL
-IDEAL_TRANSS
-
-/* All xxx_COUNT values are for the MRO spacecraft clock (SCLK) */
-/* in seconds:subseconds form. A subsecond tick = 15.2588 microseconds. */
-/* All xxx_TIME values are referenced to UTC. */
-GROUP = TIME_PARAMETERS
-/* Time when the observation first started */
- MRO:OBSERVATION_START_TIME
- MRO:OBSERVATION_START_COUNT
- /* Time of the first image line */
- START_TIME
- SPACECRAFT_CLOCK_START_COUNT
- /* Time of the last image line */
- STOP_TIME
- SPACECRAFT_CLOCK_STOP_COUNT
- /* Time when this RDR product was created */
- PRODUCT_CREATION_TIME
-END_GROUP = TIME_PARAMETERS
-
-OBJECT = IMAGE
- DESCRIPTION
- LINES
- LINE_SAMPLES
- SOURCE_LINE_SAMPLES
- SOURCE_LINES
- FIRST_LINE_SAMPLE
- FIRST_LINE
- BANDS
- OFFSET
- SCALING_FACTOR
- SAMPLE_BITS
- SAMPLE_BIT_MASK
- SAMPLE_TYPE
- FILTER_NAME
- CENTER_FILTER_WAVELENGTH
- BAND_WIDTH
- BAND_STORAGE_TYPE
- CORE_NULL
- CORE_LOW_REPR_SATURATION
- CORE_LOW_INSTR_SATURATION
- CORE_HIGH_REPR_SATURATION
- CORE_HIGH_INSTR_SATURATION
- VALID_MINIMUM
- INTERCHANGE_FORMAT
-END_OBJECT = IMAGE
-
-OBJECT = INSTRUMENT_POINTING_TABLE
- INTERCHANGE_FORMAT
- ROWS
- COLUMNS
- ROW_BYTES
- ROW_SUFFIX_BYTES
- TIME_DEPENDENT_FRAMES
- CONSTANT_FRAMES
- CONSTANT_ROTATION
- CK_TABLE_START_TIME
- CK_TABLE_END_TIME
- CK_TABLE_ORIGINAL_SIZE
- OBJECT = COLUMN
- COLUMN_NUMBER
- NAME
- DATA_TYPE
- START_BYTE
- BYTES
- END_OBJECT = COLUMN
-END_OBJECT = INSTRUMENT_POINTING_TABLE
-
-OBJECT = INSTRUMENT_POSITION_TABLE
- ROWS
- COLUMNS
- ROW_BYTES
- ROW_SUFFIX_BYTES
- CACHE_TYPE
- SPK_TABLE_START_TIME
- SPK_TABLE_END_TIME
- SPK_TABLE_ORIGINAL_SIZE
- OBJECT = COLUMN
- COLUMN_NUMBER
- NAME
- DATA_TYPE
- START_BYTE
- BYTES
- END_OBJECT = COLUMN
-END_OBJECT = INSTRUMENT_POSITION_TABLE
-
-OBJECT = BODY_ROTATION_TABLE
- ROWS
- COLUMNS
- ROW_BYTES
- ROW_SUFFIX_BYTES
- TIME_DEPENDENT_FRAMES
- CK_TABLE_START_TIME
- CK_TABLE_END_TIME
- CK_TABLE_ORIGINAL_SIZE
- SOLAR_LONGITUDE
- OBJECT = COLUMN
- COLUMN_NUMBER
- NAME
- DATA_TYPE
- START_BYTE
- BYTES
- END_OBJECT = COLUMN
-END_OBJECT = BODY_ROTATION_TABLE
-
-OBJECT = SUN_POSITION_TABLE
- ROWS
- COLUMNS
- ROW_BYTES
- ROW_SUFFIX_BYTES
- CACHE_TYPE
- SPK_TABLE_START_TIME
- SPK_TABLE_END_TIME
- SPK_TABLE_ORIGINAL_SIZE
- OBJECT = COLUMN
- COLUMN_NUMBER
- NAME
- DATA_TYPE
- START_BYTE
- BYTES
- END_OBJECT = COLUMN
-END_OBJECT = SUN_POSITION_TABLE
diff --git a/isis/src/mro/apps/hideal2pds/main.cpp b/isis/src/mro/apps/hideal2pds/main.cpp
index f440be0c63..203f45603b 100644
--- a/isis/src/mro/apps/hideal2pds/main.cpp
+++ b/isis/src/mro/apps/hideal2pds/main.cpp
@@ -184,6 +184,12 @@ void IsisMain() {
updatePdsLabelTimeParametersGroup(pdsLabel);
updatePdsLabelImageObject(isisCubeLab, pdsLabel);
+
+ // change SAMPLE_BIT_MASK value according to BITS input
+ PvlObject &image = pdsLabel.findObject("IMAGE");
+ image.addKeyword(PvlKeyword("SAMPLE_BIT_MASK", toString((int)pow(2.0, (double)nbits) - 1)),
+ Pvl::Replace);
+
Camera *cam = inputCube->camera();
updatePdsLabelRootObject(isisCubeLab, pdsLabel, ui, cam);
@@ -287,7 +293,12 @@ void IsisMain() {
// Read in the proper keyword types (Real, Enum, String, Integer, etc) for
// each PvlKeyword so that the PDS labels have proper format
PvlFormat *formatter = pdsLabel.format();
- formatter->add("$ISISROOT/appdata/translations/MroHiriseIdealPds.typ");
+
+ if( nbits != 8 ) {
+ formatter->add("$ISISROOT/appdata/translations/MroHiriseIdealPds_16bit.typ");
+ } else {
+ formatter->add("$ISISROOT/appdata/translations/MroHiriseIdealPds_8bit.typ");
+ }
// Format ordering of keywords/objects/groups/comments in the PDS labels
pdsLabel.setFormatTemplate("$ISISROOT/appdata/translations/MroHiriseIdealPds.pft");