Source
273
273
for( casacore::String m: msgs ) {
274
274
x.second = m;
275
275
_newHistory.push_back(x);
276
276
}
277
277
}
278
278
279
279
template <class T> void ImageTask<T>::addHistory(
280
280
const casacore::LogOrigin& origin, const casacore::String& taskname,
281
281
const vector<casacore::String>& paramNames, const vector<casac::variant>& paramValues
282
282
) const {
283
-
ThrowIf(
284
-
paramNames.size() != paramValues.size(),
285
-
"paramNames and paramValues must have the same number of elements"
283
+
auto appHistory = ImageHistory<T>::getApplicationHistory(
284
+
origin, taskname, paramNames, paramValues, _image->name()
286
285
);
287
-
std::pair<casacore::String, casacore::String> x;
288
-
x.first = origin.fullName();
289
-
x.second = "Ran " + taskname + " on " + _image->name();
290
-
_newHistory.push_back(x);
291
-
vector<std::pair<casacore::String, casac::variant> > inputs;
292
-
vector<casacore::String>::const_iterator begin = paramNames.begin();
293
-
vector<casacore::String>::const_iterator name = begin;
294
-
vector<casac::variant>::const_iterator value = paramValues.begin();
295
-
vector<casacore::String>::const_iterator end = paramNames.end();
296
-
casacore::String out = taskname + "(";
297
-
casacore::String quote;
298
-
while (name != end) {
299
-
if (name != begin) {
300
-
out += ", ";
301
-
}
302
-
quote = value->type() == casac::variant::STRING ? "'" : "";
303
-
out += *name + "=" + quote;
304
-
out += value->toString();
305
-
out += quote;
306
-
name++;
307
-
value++;
308
-
}
309
-
x.second = out + ")";
310
-
_newHistory.push_back(x);
286
+
_newHistory.insert(_newHistory.end(), appHistory.begin(), appHistory.end());
311
287
}
312
288
313
289
template <class T> void ImageTask<T>::_copyMask(
314
290
casacore::Lattice<casacore::Bool>& mask, const casacore::ImageInterface<T>& image
315
291
) {
316
292
auto cursorShape = image.niceCursorShape(4096*4096);
317
293
casacore::LatticeStepper stepper(image.shape(), cursorShape, casacore::LatticeStepper::RESIZE);
318
294
casacore::RO_MaskedLatticeIterator<T> iter(image, stepper);
319
295
casacore::LatticeIterator<casacore::Bool> miter(mask, stepper);
320
296
std::unique_ptr<casacore::RO_LatticeIterator<casacore::Bool>> pmiter;
471
447
return outImage;
472
448
}
473
449
474
450
template <class T>
475
451
template <class U> void ImageTask<T>::_doHistory(std::shared_ptr<casacore::ImageInterface<U>>& image) const {
476
452
if (! _suppressHistory) {
477
453
ImageHistory<U> history(image);
478
454
if (history.get(false).empty()) {
479
455
history.append(_image);
480
456
}
457
+
history.addHistory(_newHistory);
458
+
/*
481
459
for (const auto& line: _newHistory) {
482
460
history.addHistory(line.first, line.second);
483
461
}
462
+
*/
484
463
}
485
464
}
486
465
487
466
template <class T> void ImageTask<T>::_reportOldNewImageShapes(const IPosition& outShape) const {
488
467
LogOrigin lor(getClass(), __func__);
489
468
ostringstream os;
490
469
os << "Original " << _getImage()->name() << " size => "
491
470
<< _getImage()->shape();
492
471
addHistory(lor, os.str());
493
472
*_getLog() << LogIO::NORMAL << os.str() << LogIO::POST;