Skip to content

Commit a17018b

Browse files
authored
Noseam Parallel Fix (#5878)
* Fixed noseam to correctly create temporary files when processing * Added changelog entry * Removed debug print
1 parent 37300d5 commit a17018b

File tree

6 files changed

+68
-25
lines changed

6 files changed

+68
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ ctest FunctionalTestJigsawApollo to validate this output. [#5710](https://github
6262
- Changed file format to propagate from the input image format to the output image format [#5737](https://github.com/DOI-USGS/ISIS3/pull/5737)
6363
- Changed `StripPolygonSeeder` and `GridPolygonSeeder` to seed individual polygons within each images multipolygon footprint [#5193](https://github.com/DOI-USGS/ISIS3/issues/5193)
6464
- Pinned SpiceQL to 1.2.0 [#5852](https://github.com/DOI-USGS/ISIS3/pull/5852)
65-
- Changed `noseam` to apply `highpass` and `lowpass` to the same mosaic [#5862](https://github.com/DOI-USGS/ISIS3/pull/5862)
6665
- Changed `ControlMeasure` object comparison to no longer factor in creation date for equality [#5862](https://github.com/DOI-USGS/ISIS3/pull/5862)
6766

6867
### Fixed
@@ -87,6 +86,7 @@ ctest FunctionalTestJigsawApollo to validate this output. [#5710](https://github
8786
- Fixed campt reporting when `ALLOWERROR` is set to true [#5845](https://github.com/DOI-USGS/ISIS3/pull/5845)
8887
- Fixed order of observer and target in spiceql call in `ctxcal`. [#5823](https://github.com/DOI-USGS/ISIS3/pull/5823)
8988
- Fixed bundle serialization on MacOS for IPCE [#5808](https://github.com/DOI-USGS/ISIS3/pull/5808)
89+
- Fixed `noseam` to use correct temporary files when running [#5878](https://github.com/DOI-USGS/ISIS3/pull/5878)
9090

9191
## [9.0.0] - 09-25-2024
9292

isis/src/base/apps/noseam/noseam.cpp

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,50 +74,88 @@ namespace Isis {
7474
string msg = "Parameter [LINES] must be entered.";
7575
throw IException(IException::User, msg, _FILEINFO_);
7676
}
77+
std::list<FileName> tempFiles = {};
78+
7779
// Get user parameters
7880
FileList cubes;
7981
cubes.read(cubeListFileName);
8082

8183
QString match = ui.GetAsString("MATCHBANDBIN");
8284

83-
QString pathName = FileName("$TEMPORARY/").expanded();
85+
// Sets up the pathName to be used for most application calls
86+
FileName inFile = cubes[0];
87+
88+
FileName mosaicFile = FileName::createTempFile("$TEMPORARY/OriginalMosaic.cub");
89+
tempFiles.push_back(mosaicFile);
8490

8591
/**
86-
* Creates a mosaic from the original images.
92+
* Creates a mosaic from the original images. It is placed here
93+
* so that the failure MATCHBANDBIN causes does not leave
94+
* highpasses cubes lying around!
8795
*/
8896
QString parameters = "FROMLIST=" + cubeListFileName.original() +
89-
" MOSAIC=" + pathName + "OriginalMosaic.cub" +
97+
" MOSAIC=" + mosaicFile.expanded() +
9098
" MATCHBANDBIN=" + match;
9199
ProgramLauncher::RunIsisProgram("automos", parameters);
92100

93-
// Does a highpass on the original mosaic
94-
parameters = "FROM=" + pathName + "OriginalMosaic.cub" +
95-
" TO=" + pathName + "HighpassMosaic.cub"
96-
+ " SAMPLES=" + toString(samples) + " LINES=" + toString(lines);
97-
ProgramLauncher::RunIsisProgram("highpass", parameters);
101+
// Creates the highpass cubes from the cubes FileList
102+
FileList highPassList;
103+
for(int i = 0; i < cubes.size(); i++) {
104+
inFile = cubes[i];
105+
FileName highpassCube = FileName::createTempFile("$TEMPORARY/" + inFile.baseName() + "_highpass.cub");
106+
tempFiles.push_back(highpassCube);
107+
parameters = "FROM=" + inFile.expanded() +
108+
" TO=" + highpassCube.expanded() +
109+
" SAMPLES=" + toString(samples) +
110+
" LINES=" + toString(lines);
111+
ProgramLauncher::RunIsisProgram("highpass", parameters);
112+
// Reads the just created highpass cube into a list file for automos
113+
highPassList.push_back(highpassCube);
114+
}
115+
FileName highpassListFile = FileName::createTempFile("$TEMPORARY/HighPassList.lis");
116+
highPassList.write(highpassListFile);
117+
tempFiles.push_back(highpassListFile);
118+
119+
// Makes a mosaic out of the highpass cube filelist
120+
FileName highpassFile = FileName::createTempFile("$TEMPORARY/HighpassMosaic.cub");
121+
tempFiles.push_back(highpassFile);
122+
123+
parameters = "FROMLIST=" + highpassListFile.expanded() +
124+
" MOSAIC=" + highpassFile.expanded() +
125+
" MATCHBANDBIN=" + match;
126+
ProgramLauncher::RunIsisProgram("automos", parameters);
127+
128+
FileName lowpassFile = FileName::createTempFile("$TEMPORARY/HighpassMosaic.cub");
129+
tempFiles.push_back(lowpassFile);
98130

99131
// Does a lowpass on the original mosaic
100-
parameters = "FROM=" + pathName + "OriginalMosaic.cub"
101-
+ " TO=" + pathName + "LowpassMosaic.cub"
102-
+ " SAMPLES=" + toString(samples) + " LINES=" + toString(lines);
132+
parameters = "FROM=" + mosaicFile.expanded() +
133+
" TO=" + lowpassFile.expanded() +
134+
" SAMPLES=" + toString(samples) + " LINES=" + toString(lines);
103135
ProgramLauncher::RunIsisProgram("lowpass", parameters);
104136

105137
// Finally combines the highpass and lowpass mosaics
106-
parameters = "FROM=" + pathName + "HighpassMosaic.cub" +
107-
" FROM2=" + pathName + "LowpassMosaic.cub" +
138+
parameters = "FROM=" + highpassFile.expanded() +
139+
" FROM2=" + lowpassFile.expanded() +
108140
" TO=" + ui.GetCubeName("TO") +
109141
" OPERATOR= add";
110142
ProgramLauncher::RunIsisProgram("algebra", parameters);
111143

112144
// Will remove all of the temp files by default
113145
if(ui.GetBoolean("REMOVETEMP")) {
114-
QString file;
115-
file = pathName + "HighpassMosaic.cub";
116-
remove(file.toLatin1().data());
117-
file = pathName + "LowpassMosaic.cub";
118-
remove(file.toLatin1().data());
119-
file = pathName + "OriginalMosaic.cub";
120-
remove(file.toLatin1().data());
146+
QString topLevelMsg = "Failed to remove noseam temp file(s)";
147+
IException e(IException::Unknown, topLevelMsg, _FILEINFO_);
148+
QString msg = "Failed to remove temp file [";
149+
for (FileName file : tempFiles) {
150+
remove(file.expanded().toLatin1().data());
151+
if (file.fileExists()) {
152+
QString fileMsg = msg + file.name() + "]";
153+
e.append(IException(IException::Unknown, fileMsg, _FILEINFO_));
154+
}
155+
}
156+
if (e.length() > 0) {
157+
throw e;
158+
}
121159
}
122160
}
123161
}

isis/src/base/objs/IException/IException.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,12 @@ namespace Isis {
640640
}
641641

642642
int IException::length() {
643-
return m_previousExceptions->length();
643+
if (m_previousExceptions) {
644+
return m_previousExceptions->length();
645+
}
646+
else {
647+
return 0;
648+
}
644649
}
645650

646651

isis/tests/OsirisRexMapCamModuleTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ TEST(OsirisRexMapCamModules, MapCamModuleTwoImageTest) {
12821282

12831283
std::unique_ptr<Histogram> noseamMosaicHist(noseamMosaic.histogram());
12841284
EXPECT_NEAR(noseamMosaicHist->Average(), 0.0040496894214538124, 0.005);
1285-
EXPECT_NEAR(noseamMosaicHist->Sum(), 7338.5876967209242, 0.005);
1285+
EXPECT_NEAR(noseamMosaicHist->Sum(), 7338.8188217326478, 0.005);
12861286
EXPECT_EQ(noseamMosaicHist->ValidPixels(), 1812193);
12871287
EXPECT_NEAR(noseamMosaicHist->StandardDeviation(), 0.0037573821357031172, 0.005);
12881288

isis/tests/OsirisRexPolyCamModuleTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ TEST(OsirisRexPolyCamModules, PolyCamModuleTwoImageTest) {
13091309

13101310
std::unique_ptr<Histogram> noseamMosaicHist(noseamMosaic.histogram());
13111311
EXPECT_NEAR(noseamMosaicHist->Average(), 0.013594249872813711, 0.005);
1312-
EXPECT_NEAR(noseamMosaicHist->Sum(), 28517.175773404939, 0.014);
1312+
EXPECT_NEAR(noseamMosaicHist->Sum(), 28517.09297419725, 0.014);
13131313
EXPECT_EQ(noseamMosaicHist->ValidPixels(), 2097732);
13141314
EXPECT_NEAR(noseamMosaicHist->StandardDeviation(), 0.0073422521190466645, 0.005);
13151315

isis/tests/OsirisRexSamCamModuleTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ TEST(OsirisRexSamCamModules, SamCamModuleTwoImageTest) {
13301330

13311331
std::unique_ptr<Histogram> noseamMosaicHist(noseamMosaic.histogram());
13321332
EXPECT_NEAR(noseamMosaicHist->Average(), 0.010375753089644776, 0.005);
1333-
EXPECT_NEAR(noseamMosaicHist->Sum(), 11976.425999546173, 0.005);
1333+
EXPECT_NEAR(noseamMosaicHist->Sum(), 11976.949682191847, 0.005);
13341334
EXPECT_EQ(noseamMosaicHist->ValidPixels(), 1154321);
13351335
EXPECT_NEAR(noseamMosaicHist->StandardDeviation(), 0.010379350848041419, 0.005);
13361336

0 commit comments

Comments
 (0)