diff --git a/src/ModelMap.cxx b/src/ModelMap.cxx index 5e08c6891..df295d207 100644 --- a/src/ModelMap.cxx +++ b/src/ModelMap.cxx @@ -14,6 +14,7 @@ #include "tip/IFileSvc.h" #include "tip/Image.h" #include "tip/Table.h" +#include "tip/Header.h" #include "st_facilities/FitsUtil.h" @@ -174,8 +175,16 @@ void ModelMap::writeOutputMap_wcs(const std::string & outfile, if ( itr->getName().find("NAXIS") != std::string::npos ) { continue; } - output_header.append(*itr); + // append any new keywords and any new HISTORY or COMMENT keywords (some of these might end up duplicated) + // or update the value for any existing kewords. - TS 03/21/25 + auto kwItr = output_header.find(itr->getName()); + if (kwItr == output_header.end() || "COMMENT" == kwItr->getName() || "HISTORY" == kwItr->getName()){ + output_header.append(*itr); + } else { + kwItr->setValue(itr->getValue()); + } } + if (outtype == "CMAP") { output_header.erase("CTYPE3"); output_header.erase("CRPIX3");