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

Noseam has been refactored to be callable. Makefile test has been converted to a gtest and removed. #5600

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -41,6 +41,7 @@ release.
- Added backplane options for SunIllumination and SurfaceObliqueDetectorResolution to phocube [#5467](https://github.com/DOI-USGS/ISIS3/issues/5467)

### Changed
- Noseam has been refactored to be callable; old Makefile test has been removed and replaced by a gtest. Issue: [#5599](https://github.com/USGS-Astrogeology/ISIS3/issues/5599)
- Photrim has been refactored to be callable; old Makefile tests have been removed and replaced by gtests. Issue: [#5581](https://github.com/USGS-Astrogeology/ISIS3/issues/5581)
- Bandtrim has been refactored to be callable; old Makefile tests have been removed and replaced by gtests. Issue: [#5571](https://github.com/USGS-Astrogeology/ISIS3/issues/5571)
- Modified kaguyasp2isis to work with new (detached) data [#5436](https://github.com/DOI-USGS/ISIS3/issues/5436)
Expand Down
96 changes: 12 additions & 84 deletions isis/src/base/apps/noseam/main.cpp
Original file line number Diff line number Diff line change
@@ -1,92 +1,20 @@
#include "Isis.h"
#include "Application.h"
#include "FileList.h"
#include "Cube.h"
#include "Preference.h"
#include "ProgramLauncher.h"

#include <iostream>
#include <fstream>

using namespace std;
using namespace Isis;

void IsisMain() {

//Get user parameters
UserInterface &ui = Application::GetUserInterface();
FileList cubes;
cubes.read(ui.GetFileName("FROMLIST"));
/** This is free and unencumbered software released into the public domain.

int samples = ui.GetInteger("SAMPLES");
int lines = ui.GetInteger("LINES");
QString match = ui.GetAsString("MATCHBANDBIN");
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. **/

//Sets upt the pathName to be used for most application calls
FileName inFile = cubes[0];
/* SPDX-License-Identifier: CC0-1.0 */

Pvl &pref = Preference::Preferences();
QString pathName = (QString)pref.findGroup("DataDirectory")["Temporary"] + "/";

/**
* Creates a mosaic from the original images. It is placed here
* so that the failure MATCHBANDBIN causes does not leave
* highpasses cubes lying around!
*/
QString parameters = "FROMLIST=" + ui.GetFileName("FROMLIST") +
" MOSAIC=" + pathName + "OriginalMosaic.cub" +
" MATCHBANDBIN=" + match;
ProgramLauncher::RunIsisProgram("automos", parameters);

//Creates the highpass cubes from the cubes FileList
std::ofstream highPassList;
highPassList.open("HighPassList.lis");
for(int i = 0; i < cubes.size(); i++) {
inFile = cubes[i];
QString outParam = pathName + inFile.baseName() + "_highpass.cub";
parameters = "FROM=" + inFile.expanded() +
" TO=" + outParam
+ " SAMPLES=" + toString(samples) + " LINES=" + toString(lines);
ProgramLauncher::RunIsisProgram("highpass", parameters);
//Reads the just created highpass cube into a list file for automos
highPassList << outParam << endl;
}
highPassList.close();

//Makes a mosaic out of the highpass cube filelist
parameters = "FROMLIST=HighPassList.lis MOSAIC=" + pathName + "HighpassMosaic.cub"
+ " MATCHBANDBIN=" + match;
ProgramLauncher::RunIsisProgram("automos", parameters);

//Does a lowpass on the original mosaic
parameters = "FROM=" + pathName + "OriginalMosaic.cub"
+ " TO=" + pathName + "LowpassMosaic.cub"
+ " SAMPLES=" + toString(samples) + " LINES=" + toString(lines);
ProgramLauncher::RunIsisProgram("lowpass", parameters);
#include "Isis.h"

//Finally combines the highpass and lowpass mosaics
parameters = "FROM=" + pathName + "HighpassMosaic.cub" +
" FROM2=" + pathName + "LowpassMosaic.cub" +
" TO=" + ui.GetCubeName("TO") +
" OPERATOR= add";
ProgramLauncher::RunIsisProgram("algebra", parameters);
#include "noseam.h"

//Will remove all of the temp files by default
if(ui.GetBoolean("REMOVETEMP")) {
QString file("HighPassList.lis");
remove(file.toLatin1().data());
file = pathName + "HighpassMosaic.cub";
remove(file.toLatin1().data());
file = pathName + "LowpassMosaic.cub";
remove(file.toLatin1().data());
file = pathName + "OriginalMosaic.cub";
remove(file.toLatin1().data());
#include "Application.h"

for(int i = 0; i < cubes.size(); i++) {
inFile = cubes[i];
file = pathName + inFile.baseName() + "_highpass.cub";
remove(file.toLatin1().data());
}
}
using namespace Isis;

void IsisMain() {
UserInterface &ui = Application::GetUserInterface();
noseam(ui);
}
124 changes: 124 additions & 0 deletions isis/src/base/apps/noseam/noseam.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/** 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 "noseam.h"

#include <iostream>
#include <fstream>

#include "automos.h"
#include "FileList.h"
#include "FileName.h"
#include "Cube.h"
#include "Preference.h"
#include "ProgramLauncher.h"

using namespace std;

namespace Isis {

/**
* Noseam creates a mosaic from a list of input cubes using an
* algorithm that minimizes seams.
*
* @param ui UserInterface object containing parameters
*/
void noseam(UserInterface &ui) {

// Get Filename with list of cubes to mosaic
FileName cubeListFileName(ui.GetFileName("FROMLIST"));

return noseam(cubeListFileName, ui);
}


/**
* Noseam creates a mosaic from a list of input cubes using an
* algorithm that minimizes seams.
*
* @param cubeListFileName Filename with list of cubes to mosaic
* @param ui UserInterface object containing parameters
*/
void noseam(FileName &cubeListFileName, UserInterface &ui) {

// Get user parameters
FileList cubes;
cubes.read(cubeListFileName);

int samples = ui.GetInteger("SAMPLES");
int lines = ui.GetInteger("LINES");
QString match = ui.GetAsString("MATCHBANDBIN");

// Sets up the pathName to be used for most application calls
FileName inFile = cubes[0];

Pvl &pref = Preference::Preferences();
QString pathName = (QString)pref.findGroup("DataDirectory")["Temporary"] + "/";

/**
* Creates a mosaic from the original images. It is placed here
* so that the failure MATCHBANDBIN causes does not leave
* highpasses cubes lying around!
*/
QString parameters = "FROMLIST=" + cubeListFileName.original() +
" MOSAIC=" + pathName + "OriginalMosaic.cub" +
" MATCHBANDBIN=" + match;
ProgramLauncher::RunIsisProgram("automos", parameters);

// Creates the highpass cubes from the cubes FileList
ofstream highPassList;
highPassList.open("HighPassList.lis");
for(int i = 0; i < cubes.size(); i++) {
inFile = cubes[i];
QString outParam = pathName + inFile.baseName() + "_highpass.cub";
parameters = "FROM=" + inFile.expanded() +
" TO=" + outParam
+ " SAMPLES=" + toString(samples) + " LINES=" + toString(lines);
ProgramLauncher::RunIsisProgram("highpass", parameters);
// Reads the just created highpass cube into a list file for automos
highPassList << outParam << endl;
}
highPassList.close();

// Makes a mosaic out of the highpass cube filelist
parameters = "FROMLIST=HighPassList.lis MOSAIC=" + pathName + "HighpassMosaic.cub"
+ " MATCHBANDBIN=" + match;
ProgramLauncher::RunIsisProgram("automos", parameters);

// Does a lowpass on the original mosaic
parameters = "FROM=" + pathName + "OriginalMosaic.cub"
+ " TO=" + pathName + "LowpassMosaic.cub"
+ " SAMPLES=" + toString(samples) + " LINES=" + toString(lines);
ProgramLauncher::RunIsisProgram("lowpass", parameters);

// Finally combines the highpass and lowpass mosaics
parameters = "FROM=" + pathName + "HighpassMosaic.cub" +
" FROM2=" + pathName + "LowpassMosaic.cub" +
" TO=" + ui.GetCubeName("TO") +
" OPERATOR= add";
ProgramLauncher::RunIsisProgram("algebra", parameters);

// Will remove all of the temp files by default
if(ui.GetBoolean("REMOVETEMP")) {
QString file("HighPassList.lis");
remove(file.toLatin1().data());
file = pathName + "HighpassMosaic.cub";
remove(file.toLatin1().data());
file = pathName + "LowpassMosaic.cub";
remove(file.toLatin1().data());
file = pathName + "OriginalMosaic.cub";
remove(file.toLatin1().data());

for(int i = 0; i < cubes.size(); i++) {
inFile = cubes[i];
file = pathName + inFile.baseName() + "_highpass.cub";
remove(file.toLatin1().data());
}
}
}
}
20 changes: 20 additions & 0 deletions isis/src/base/apps/noseam/noseam.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** 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 */

#ifndef noseam_h
#define noseam_h

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

namespace Isis{
extern void noseam(UserInterface &ui);
extern void noseam(FileName &cubeListFileName, UserInterface &ui);
}

#endif
3 changes: 3 additions & 0 deletions isis/src/base/apps/noseam/noseam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
boxcar for the highpass and lowpass filters, have been condensed down to two
parameters, SAMPLES and LINES as the size of the boxcars must be the same. Fixes #258.
</change>
<change name="Ken Edmundson" date="2024-8-25">
Converted noseam to callable app. Also converted Makefile test to gtest format.
</change>
</history>

<groups>
Expand Down
4 changes: 0 additions & 4 deletions isis/src/base/apps/noseam/tsts/Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions isis/src/base/apps/noseam/tsts/default/Makefile

This file was deleted.

Loading