Source
3228
3228
}
3229
3229
else {
3230
3230
ThrowCc("Unrecognized infiles datatype");
3231
3231
}
3232
3232
auto imageNames = Directory::shellExpand(inFiles, false).tovector();
3233
3233
ThrowIf(
3234
3234
imageNames.size() < 2,
3235
3235
"You must provide at least two images to concatentate"
3236
3236
);
3237
3237
auto first = imageNames[0];
3238
-
// imageNames.erase(imageNames.begin());
3239
3238
std::shared_ptr<LatticeBase> latt(ImageOpener::openImage(first));
3240
3239
ThrowIf (! latt, "Unable to open image " + first);
3241
3240
auto dataType = latt->dataType();
3242
3241
if (dataType == TpFloat) {
3243
3242
return new image(
3244
3243
_concat<Float>(
3245
-
latt, outfile, infiles, axis, relax, tempclose,
3244
+
outfile, infiles, axis, relax, tempclose,
3246
3245
overwrite, reorder, imageNames, mode
3247
3246
)
3248
3247
);
3249
3248
}
3250
3249
else if (dataType == TpComplex) {
3251
3250
return new image(
3252
3251
_concat<Complex>(
3253
-
latt, outfile, infiles, axis, relax, tempclose,
3252
+
outfile, infiles, axis, relax, tempclose,
3254
3253
overwrite, reorder, imageNames, mode
3255
3254
)
3256
3255
);
3257
3256
}
3258
3257
else if (dataType == TpDouble) {
3259
3258
return new image(
3260
3259
_concat<Double>(
3261
-
latt, outfile, infiles, axis, relax, tempclose,
3260
+
outfile, infiles, axis, relax, tempclose,
3262
3261
overwrite, reorder, imageNames, mode
3263
3262
)
3264
3263
);
3265
3264
}
3266
3265
else if (dataType == TpDComplex) {
3267
3266
return new image(
3268
3267
_concat<DComplex>(
3269
-
latt, outfile, infiles, axis, relax, tempclose,
3268
+
outfile, infiles, axis, relax, tempclose,
3270
3269
overwrite, reorder, imageNames, mode
3271
3270
)
3272
3271
);
3273
3272
}
3274
3273
else {
3275
3274
ostringstream x;
3276
3275
x << dataType;
3277
3276
ThrowCc("Unsupported data type " + x.str());
3278
3277
}
3279
3278
}
3280
3279
catch (const AipsError& x) {
3281
3280
_log << LogIO::SEVERE << "Exception Reported: " << x.getMesg()
3282
3281
<< LogIO::POST;
3283
3282
RETHROW(x);
3284
3283
}
3285
3284
return nullptr;
3286
3285
}
3287
3286
3288
3287
template<class T> SPIIT image::_concat(
3289
-
std::shared_ptr<LatticeBase> latt, const string& outfile,
3288
+
const string& outfile,
3290
3289
const variant& infiles, int axis, bool relax, bool tempclose,
3291
3290
bool overwrite, bool reorder, vector<String>& imageNames,
3292
3291
const string& mode
3293
3292
) {
3294
-
// SPIIT im = std::dynamic_pointer_cast<ImageInterface<T>>(latt);
3295
-
// ThrowIf(! im, "dynamic cast failed");
3296
-
// ImageConcatenator<T> concat(im, outfile, overwrite);
3297
3293
ImageConcatenator<T> concat(imageNames, outfile, overwrite);
3298
3294
concat.setAxis(axis);
3299
3295
concat.setRelax(relax);
3300
3296
concat.setReorder(reorder);
3301
3297
concat.setTempClose(tempclose);
3302
3298
concat.setMode(mode);
3299
+
auto finalImage = concat.concatenate();
3303
3300
if (_doHistory) {
3304
3301
vector<String> names {
3305
3302
"outfile", "infiles", "axis", "relax", "tempclose",
3306
3303
"overwrite", "reorder", "mode"
3307
3304
};
3308
3305
vector<variant> values {
3309
3306
outfile, infiles, axis, relax, tempclose,
3310
3307
overwrite, reorder, mode
3311
3308
};
3312
-
concat.addHistory(_ORIGIN, "ia.imageconcat", names, values);
3309
+
ImageHistory<T> history(finalImage);
3310
+
history.addHistory(
3311
+
history.getApplicationHistory(
3312
+
_ORIGIN, "ia.imageconcat", names,
3313
+
values, finalImage->name()
3314
+
)
3315
+
);
3313
3316
}
3314
-
return concat.concatenate();
3317
+
return finalImage;
3315
3318
}
3316
3319
3317
3320
bool image::insert(
3318
3321
const std::string& infile, const variant& region,
3319
3322
const std::vector<double>& locate, bool verbose
3320
3323
) {
3321
3324
try {
3322
3325
_log << _ORIGIN;
3323
3326
if (_detached()) {
3324
3327
return false;