Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update of Existing OSIRIS-REx OCams Instrument Support #5718

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ release.
### Added

### Changed
- Update OSIRIS-REx OCams instrument (Map, Poly, & SamCam) support to current state in UofA code base [#5426](https://github.com/DOI-USGS/ISIS3/issues/5426)

### Fixed
- Fixed kaguyatc2isis invalid BandBin values [#5629](https://github.com/DOI-USGS/ISIS3/issues/5629)
Expand Down
20 changes: 20 additions & 0 deletions isis/appdata/serialnumbers/OsirisRexTagCamsSerialNumber.trn
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# history 2019-01-19 Kris Becker - Original version added to UofA codebase.
# history 2025-01-29 Ken Edmundson - Added Keyword4 group with optional keyword ControlSN

Group = Keyword1
Auto = 1
Expand Down Expand Up @@ -28,3 +29,22 @@ Group = Keyword3
OutputPosition = ("Group","SerialNumberKeywords")
Translation = (*,*)
EndGroup

/* This keyword is an optional keyword that is to be used to */
/* create unique serial numbers for images derived from the */
/* original. This is intended for use such as applying the */
/* local incidence backplane as a control source. By manually */
/* adding this keyword to the Instrument group with any */
/* value, it creates a new (unique) serial number for control */
/* processing. It has no effect if the keyword does not */
/* exist. */
Group = Keyword4
Auto = 1
Optional = 1
InputKey = ControlSN
InputGroup = "IsisCube,Instrument"
InputPosition = (IsisCube, Instrument)
OutputName = Keyword4
OutputPosition = ("Group","SerialNumberKeywords")
Translation = (*,*)
EndGroup
69 changes: 3 additions & 66 deletions isis/src/osirisrex/apps/ocams2isis/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,13 @@ find files of those names at the top level of this repository. **/

#include "Isis.h"

#include <fstream>
#include <iostream>

#include <QString>

#include "Cube.h"
#include "IException.h"
#include "IString.h"
#include "OriginalLabel.h"
#include "ProcessBySample.h"
#include "ProcessImportFits.h"
#include "Pvl.h"
#include "PvlGroup.h"
#include "PvlKeyword.h"
#include "Application.h"
#include "UserInterface.h"
#include "ocams2isis.h"

using namespace std;
using namespace Isis;

void IsisMain() {

UserInterface &ui = Application::GetUserInterface();

QString error_message = "WARNING: This camera model is out of date. See ocam2isis documentation for details.";
std::cerr << error_message << std::endl;

ProcessImportFits importFits;

importFits.setFitsFile(FileName(ui.GetFileName("FROM")));

importFits.setProcessFileStructure(0);

Cube *output = importFits.SetOutputCube("TO");

// Get the directory where the OSIRIS-REx translation tables are.
QString transDir = "$ISISROOT/appdata/translations/";

// Temp storage of translated labels
Pvl outLabel;

// Get the FITS label
Pvl fitsLabel;
fitsLabel.addGroup(importFits.fitsImageLabel(0));

// Create an Instrument group
FileName insTransFile(transDir + "OsirisRexOcamsInstrument_fit.trn");
PvlToPvlTranslationManager insXlater(fitsLabel, insTransFile.expanded());
insXlater.Auto(outLabel);
output->putGroup(outLabel.findGroup("Instrument", Pvl::Traverse));


// Create a Band Bin group
FileName bandTransFile(transDir + "OsirisRexOcamsBandBin_fit.trn");
PvlToPvlTranslationManager bandBinXlater(fitsLabel, bandTransFile.expanded());
bandBinXlater.Auto(outLabel);
output->putGroup(outLabel.findGroup("BandBin", Pvl::Traverse));

// Create a Kernels group
FileName kernelsTransFile(transDir + "OsirisRexOcamsKernels_fit.trn");
PvlToPvlTranslationManager kernelsXlater(fitsLabel, kernelsTransFile.expanded());
kernelsXlater.Auto(outLabel);
output->putGroup(outLabel.findGroup("Kernels", Pvl::Traverse));

// Save the input FITS label in the Cube original labels
Pvl pvl;
pvl += importFits.fitsImageLabel(0);
OriginalLabel originals(pvl);
output->write(originals);

// Convert the image data
importFits.StartProcess();
importFits.Finalize();
ocams2isis(ui);
}
95 changes: 95 additions & 0 deletions isis/src/osirisrex/apps/ocams2isis/ocams2isis.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/** This is free and unencumbered software released into the public domain.

The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

/* SPDX-License-Identifier: CC0-1.0 */

#include "ocams2isis.h"

#include <fstream>
#include <iostream>

#include <QString>

#include "Cube.h"
#include "IException.h"
#include "IString.h"
#include "OriginalLabel.h"
#include "ProcessBySample.h"
#include "ProcessImportFits.h"
#include "Pvl.h"
#include "PvlGroup.h"
#include "PvlKeyword.h"
#include "UserInterface.h"

using namespace std;

namespace Isis {

/**
* Ingest OSIRIS-REx OCams fits file as ISIS cube.
*
* @param ui UserInterface object containing parameters
*/
void ocams2isis(UserInterface &ui) {

FileName fitsFileName(ui.GetFileName("FROM"));

return ocams2isis(fitsFileName, ui);
}


void ocams2isis(FileName &fitsFileName, UserInterface &ui) {

// open fits file
ProcessImportFits importFits;
importFits.setFitsFile(fitsFileName);

importFits.setProcessFileStructure(0);

// Get the primary FITS label so we can confirm its the proper format
// and get some values for processing
Pvl fLabel;
fLabel.addGroup(importFits.fitsImageLabel(0));

// instantiate output cube
Cube *output = importFits.SetOutputCube("TO", ui);

// Get the directory where the OSIRIS-REx translation tables are.
QString transDir = "$ISISROOT/appdata/translations/";

// Temp storage of translated labels
Pvl outLabel;

// Create an Instrument group
FileName insTransFile(transDir + "OsirisRexOcamsInstrument_fit.trn");
PvlToPvlTranslationManager insXlater(fLabel, insTransFile.expanded());
insXlater.Auto(outLabel);
output->putGroup(outLabel.findGroup("Instrument", Pvl::Traverse));


// Create a Band Bin group
FileName bandTransFile(transDir + "OsirisRexOcamsBandBin_fit.trn");
PvlToPvlTranslationManager bandBinXlater(fLabel, bandTransFile.expanded());
bandBinXlater.Auto(outLabel);
output->putGroup(outLabel.findGroup("BandBin", Pvl::Traverse));

// Create a Kernels group
FileName kernelsTransFile(transDir + "OsirisRexOcamsKernels_fit.trn");
PvlToPvlTranslationManager kernelsXlater(fLabel, kernelsTransFile.expanded());
kernelsXlater.Auto(outLabel);
output->putGroup(outLabel.findGroup("Kernels", Pvl::Traverse));

// Save the input FITS label in the Cube original labels
Pvl pvl;
pvl += importFits.fitsImageLabel(0);
OriginalLabel originals(pvl);
output->write(originals);

// Convert the image data
importFits.StartProcess();
importFits.Finalize();
}
}
20 changes: 20 additions & 0 deletions isis/src/osirisrex/apps/ocams2isis/ocams2isis.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef ocams2isis_h
#define ocams2isis_h

/** This is free and unencumbered software released into the public domain.

The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

/* SPDX-License-Identifier: CC0-1.0 */

#include "FileName.h"
#include "UserInterface.h"

namespace Isis{
extern void ocams2isis(UserInterface &ui);
extern void ocams2isis(FileName &fitsFileName, UserInterface &ui);
}

#endif
3 changes: 3 additions & 0 deletions isis/src/osirisrex/apps/ocams2isis/ocams2isis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
Reverted code to only deal with a single kernels translation file for all instruments. Added
PolyCamFocusPositionNaifId keyoword to kernels translation file. References #5127
</change>
<change name="Ken Edmundson" date="2025-01-28">
Converted ocams2isis to callable app.
</change>
</history>

<seeAlso>
Expand Down
4 changes: 0 additions & 4 deletions isis/src/osirisrex/apps/ocams2isis/tsts/Makefile

This file was deleted.

12 changes: 0 additions & 12 deletions isis/src/osirisrex/apps/ocams2isis/tsts/mapcam/Makefile

This file was deleted.

12 changes: 0 additions & 12 deletions isis/src/osirisrex/apps/ocams2isis/tsts/polycam/Makefile

This file was deleted.

14 changes: 0 additions & 14 deletions isis/src/osirisrex/apps/ocams2isis/tsts/samcam/Makefile

This file was deleted.

6 changes: 3 additions & 3 deletions isis/src/osirisrex/objs/OsirisRexOcamsCamera/Camera.plugin
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Group = OSIRIS-REX/MAPCAM
Version = 1
Version = 2
Library = OsirisRexOcamsCamera
Routine = OsirisRexOcamsCameraPlugin
EndGroup

Group = OSIRIS-REX/POLYCAM
Version = 1
Version = 2
Library = OsirisRexOcamsCamera
Routine = OsirisRexOcamsCameraPlugin
EndGroup

Group = OSIRIS-REX/SAMCAM
Version = 1
Version = 2
Library = OsirisRexOcamsCamera
Routine = OsirisRexOcamsCameraPlugin
EndGroup
Expand Down
Loading