From 862f5bcb3911dc2317b7fba18f77bc13940e7cf4 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Thu, 20 May 2021 16:36:01 +0200 Subject: [PATCH] Stamp all output FITS files (#3662) --- ChangeLog | 1 + NEWS | 70 ++++++++++++++++++++++++++++++++++++++++++++++------------------------ cscripts/csebins.py | 3 +++ cscripts/cslightcrv.py | 5 ++++- cscripts/csmodelsois.py | 23 ++++++++++++++--------- cscripts/csobs2caldb.py | 5 ++++- cscripts/csphagen.py | 6 ++++++ cscripts/csphasecrv.py | 3 +++ cscripts/csresmap.py | 9 ++++++--- cscripts/csresspec.py | 3 +++ cscripts/csroot2caldb.py | 5 ++++- cscripts/csscs.py | 5 ++++- cscripts/csspec.py | 3 +++ cscripts/cstsmapmerge.py | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------- cscripts/csviscube.py | 5 ++++- doc/source/admin/release_history/2.0.rst | 2 ++ src/ctbin/ctbin.cpp | 8 +++++++- src/ctbkgcube/ctbkgcube.cpp | 6 ++++-- src/ctcubemask/ctcubemask.cpp | 10 ++++++++-- src/ctedispcube/ctedispcube.cpp | 5 ++++- src/ctexpcube/ctexpcube.cpp | 5 ++++- src/ctfindvar/ctfindvar.cpp | 6 +++++- src/ctmapcube/ctmapcube.cpp | 4 +++- src/ctmodel/ctmodel.cpp | 6 +++++- src/ctobssim/ctobssim.cpp | 8 +++++++- src/ctpsfcube/ctpsfcube.cpp | 5 ++++- src/ctskymap/ctskymap.cpp | 6 +++++- src/cttsmap/cttsmap.cpp | 3 +++ src/support/ctool.cpp | 5 ++++- 29 files changed, 246 insertions(+), 128 deletions(-) diff --git a/ChangeLog b/ChangeLog index ca4e487..9eeb3be 100755 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ ======================== Add source counts constraints to cssens (#3668) + Stamp all output FITS files (#3662) Add ASCL shields to "About" page (#3630) Use file function constructor in csspec (#3626) Add BINS method to csspec (#3606) diff --git a/NEWS b/NEWS index e847bdd..eb13974 100755 --- a/NEWS +++ b/NEWS @@ -39,28 +39,31 @@ None ctbin - CTA event binning ------------------------- +Stamp output counts cube (#3662). + Removed implicit conversion warning during C++ compilation (#3324). ctbkgcube - CTA background cube generation ------------------------------------------ -None +Stamp output background cube (#3662). ctbutterfly - Generate butterfly diagrams ----------------------------------------- The ASCII output file was replaced by a FITS file, and the butterfly() method -now returns a GFits objects instead of a GCsv object (#1707). +now returns a GFits objects instead of a GCsv object (#1707). The output FITS +file is also stamped (#3662). ctcubemask - CTA cube filtering ------------------------------- -None +Stamp output masked cube (#3662). ctedispcube - CTA energy dispersion cube generation --------------------------------------------------- -None +Stamp output energy dispersion cube (#3662). cterror - Likelihood profile error computation @@ -70,12 +73,12 @@ None ctexpcube - CTA exposure cube generation ---------------------------------------- -None +Stamp output exposure cube (#3662). ctfindvar - Variability search ------------------------------ -None +Stamp output FITS files (#3662). ctlike - Maximum likelihood fitting @@ -99,47 +102,53 @@ are fixed for all sky models (#3426). ctmapcube - CTA map cube generation ----------------------------------- -None +Stamp output map cube (#3662). ctmodel - CTA counts cube modelling ----------------------------------- -None +Stamp output model cube (#3662). ctobssim - CTA observation simulation ------------------------------------- +Stamp output event files (#3662). + Added models() method allowing for a setting of the model container without using the "inmodels" parameter (#3441). ctphase - Event phase computation --------------------------------- -None +Stamp output event files (#3662). ctprob - Event probability computation -------------------------------------- -None +Stamp output event files (#3662). ctpsfcube - CTA point spread function cube generation ----------------------------------------------------- -None +Stamp output point spread function cube (#3662). ctselect - CTA event selection ------------------------------ +Stamp output event files (#3662). + Replaced std::tmpnam() by gammalib::tmpnam() function in ctselect (#3324). ctskymap - CTA sky mapping -------------------------- -None +Stamp output sky map (#3662). cttsmap - Generation of Test Statistic map ------------------------------------------ +Stamp output TS map (#3662). + Added hidden "fix_spat" parameter that instructs the tool to fix all spatial model parameters (#3562). @@ -151,7 +160,7 @@ None support - Support classes ------------------------- -None +Add stamping to ctool::save_event_list() method (#3662). csbkgmodel - Generate background model for 3D analysis @@ -166,7 +175,7 @@ None csebins - Generate energy boundaries ------------------------------------ -None +Stamp output energy boundaries file (#3662). csfindobs - Find IACT observations @@ -191,6 +200,8 @@ None cslightcrv - Generate light curve --------------------------------- +Stamp output light curve file (#3662). + Added support for rectangular On/Off regions. The "srcshape" parameter now can now be set to "RECT" to use rectangular sky regions. The parameter is now automatic. The parameters "width", "height", and "posang" were added to specify @@ -214,12 +225,12 @@ None csmodelsois - Puts selected sources in diffuse model cube --------------------------------------------------------- -None +Stamp output diffuse model cube (#3662). csobs2caldb - Generate calibration database entry for an IACT observation ------------------------------------------------------------------------- -None +Stamp output IRF files (#3662). csobsdef - Generate observation definition XML file @@ -239,6 +250,8 @@ None csphagen - Generate On/Off observations --------------------------------------- +Stamp output OGIP files (#3662). + Added support for rectangular On/Off regions. The "srcshape" parameter now can now be set to "RECT" to use rectangular sky regions. The parameter is now automatic. The parameters "width", "height", and "posang" were added to specify @@ -247,6 +260,8 @@ the width, height and position angle of the rectangular sky regions (#3248). csphasecrv - Generate phase curve --------------------------------- +Stamp output phase curve file (#3662). + Added support for rectangular On/Off regions. The "srcshape" parameter now can now be set to "RECT" to use rectangular sky regions. The parameter is now automatic. The parameters "width", "height", and "posang" were added to specify @@ -255,26 +270,29 @@ the width, height and position angle of the rectangular sky regions (#3248). cspull - Generate pull distributions ------------------------------------ -The ASCII output file was replaced by a FITS file (#1707). +The ASCII output file was replaced by a FITS file (#1707). The output FITS file +is stamped (#3662). csresmap - Generate residual map -------------------------------- -None +Stamp output residual map (#3662). csresspec - Generate residual spectrum -------------------------------------- -None +Stamp output residual spectrum (#3662). csroot2caldb - Generates calibration database from ROOT file ------------------------------------------------------------ -None +Stamp output IRF files (#3662). csscs - Spectral component separation ------------------------------------- +Stamp output FITS file (#3662). + Added support for rectangular On/Off regions. The "srcshape" parameter now can now be set to "RECT" to use rectangular sky regions. The parameter is now automatic. The parameters "width", "height", and "posang" were added to specify @@ -293,11 +311,14 @@ The test source position is now used as pointing direction, eventually offset in galactic latitude by a number of degrees specified using the "offset" parameter (#3555). -The ASCII output file was replaced by a FITS file (#1707). +The ASCII output file was replaced by a FITS file (#1707). The output FITS file +is stamped (#3662). csspec - Generates Spectral Energy Distribution ----------------------------------------------- +Stamp output spectrum (#3662). + The GModelSpectralFunc spectral model constructor is now used to convert any spectral model into a file function before spectral model fitting (#3626). @@ -313,12 +334,13 @@ None cstsdist - Computes Test Statistic distribution ----------------------------------------------- -The ASCII output file was replaced by a FITS file (#1707). +The ASCII output file was replaced by a FITS file (#1707). The output FITS +file is stamped (#3662). cstsmapmerge - Merge Test Statistic maps ---------------------------------------- -None +Stamp output TS map (#3662). cstsmapsplit - Prepare split Test Statistic computation @@ -328,7 +350,7 @@ None csviscube - Generate visibility cube ------------------------------------ -None +Stamp output visibility cube (#3662). csworkflow - Execute workflow diff --git a/cscripts/csebins.py b/cscripts/csebins.py index 57dedd4..eae4428 100755 --- a/cscripts/csebins.py +++ b/cscripts/csebins.py @@ -277,6 +277,9 @@ class csebins(ctools.csobservation): # Save energy boundaries self._ebounds.save(outfile, self._clobber()) + # Stamp energy boundaries + self._stamp(outfile) + # Return return diff --git a/cscripts/cslightcrv.py b/cscripts/cslightcrv.py index 3a16987..b1c797c 100755 --- a/cscripts/cslightcrv.py +++ b/cscripts/cslightcrv.py @@ -2,7 +2,7 @@ # ========================================================================== # Generates a lightcurve. # -# Copyright (C) 2014-2019 Michael Mayer +# Copyright (C) 2014-2021 Michael Mayer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -673,6 +673,9 @@ class cslightcrv(ctools.csobservation): self._fits = gammalib.GFits() self._fits.append(table) + # Stamp FITS file + self._stamp(self._fits) + # Optionally publish light curve if self['publish'].boolean(): self.publish() diff --git a/cscripts/csmodelsois.py b/cscripts/csmodelsois.py index 0f1a42d..71b4680 100755 --- a/cscripts/csmodelsois.py +++ b/cscripts/csmodelsois.py @@ -2,7 +2,7 @@ # ========================================================================== # Puts subset of sources in diffuse model cube # -# Copyright (C) 2017-2018 Josh Cardenzana +# Copyright (C) 2017-2021 Josh Cardenzana # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -40,11 +40,11 @@ class csmodelsois(ctools.cscript): def __init__(self, *argv): """ Constructor - + Parameters ---------- argv : list of parameters - + Raises ------ TypeError @@ -52,12 +52,12 @@ class csmodelsois(ctools.cscript): """ # Initialise application by calling the base class constructor self._init_cscript(self.__class__.__name__, ctools.__version__, argv) - + # Initialize parameters self._cubegen = ctools.ctmapcube() self._models = gammalib.GModels() self._cubemodels = gammalib.GModels() - + # Return return @@ -186,15 +186,20 @@ class csmodelsois(ctools.cscript): # Save the generated cube if the cube and filename are not empty if ((not self._cubegen.mapcube().cube().is_empty()) and self['outcube'].is_valid()): + + # Save cube self._cubegen.mapcube().save(self['outcube'].filename(), self['clobber'].boolean()) - + + # Stamp cube + self._stamp(self['outcube'].filename()) + # If requested, save the updated list of models if self['outmodel'].is_valid(): # Generate a list of models that will be output to file outmodels = gammalib.GModels(self._models) - + # Remove all models used in the generated cube for model in self._cubemodels: outmodels.remove(model.name()) @@ -250,9 +255,9 @@ class csmodelsois(ctools.cscript): # Main routine entry point # # ======================== # if __name__ == '__main__': - + # Create instance of application app = csmodelsois(sys.argv) - + # Execute application app.execute() diff --git a/cscripts/csobs2caldb.py b/cscripts/csobs2caldb.py index fdffd84..5b95d36 100755 --- a/cscripts/csobs2caldb.py +++ b/cscripts/csobs2caldb.py @@ -2,7 +2,7 @@ # ========================================================================== # Creates a calibration database entry for an IACT observation # -# Copyright (C) 2015-2018 Michael Mayer +# Copyright (C) 2015-2021 Michael Mayer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -375,6 +375,9 @@ class csobs2caldb(ctools.csobservation): # Save response file self._irf_fits.saveto(filename, self._clobber()) + # Stamp response file + self._stamp(filename) + # Return return diff --git a/cscripts/csphagen.py b/cscripts/csphagen.py index e39a3ca..a5d3829 100755 --- a/cscripts/csphagen.py +++ b/cscripts/csphagen.py @@ -1138,6 +1138,12 @@ class csphagen(ctools.csobservation): obs.arf().save(arfname, clobber) obs.rmf().save(rmfname, clobber) + # Stamp files + self._stamp(onname) + self._stamp(offname) + self._stamp(arfname) + self._stamp(rmfname) + # Log file names self._log_value(gammalib.NORMAL, 'PHA on file', onname) self._log_value(gammalib.NORMAL, 'PHA off file', offname) diff --git a/cscripts/csphasecrv.py b/cscripts/csphasecrv.py index 85febfb..3b6b7d3 100755 --- a/cscripts/csphasecrv.py +++ b/cscripts/csphasecrv.py @@ -318,6 +318,9 @@ class csphasecrv(ctools.csobservation): self._fits = gammalib.GFits() self._fits.append(table) + # Stamp FITS file + self._stamp(self._fits) + # Return return diff --git a/cscripts/csresmap.py b/cscripts/csresmap.py index e93fb80..5d71e38 100755 --- a/cscripts/csresmap.py +++ b/cscripts/csresmap.py @@ -2,7 +2,7 @@ # ========================================================================== # Generates a residual map. # -# Copyright (C) 2014-2020 Michael Mayer +# Copyright (C) 2014-2021 Michael Mayer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -213,7 +213,7 @@ class csresmap(ctools.csobservation): # Get outmap parameter outmap = self['outmap'].filename() - + # Continue only filename and residual map are valid if self._resmap != None: @@ -223,6 +223,9 @@ class csresmap(ctools.csobservation): # Save residual map self._resmap.save(outmap, self['clobber'].boolean()) + # Stamp residual map + self._stamp(outmap) + # Return return @@ -240,7 +243,7 @@ class csresmap(ctools.csobservation): # Continue only if residual map is valid if self._resmap != None: - + # Set default name is user name is empty if not name: user_name = self._name() diff --git a/cscripts/csresspec.py b/cscripts/csresspec.py index 23fa54a..fc74476 100755 --- a/cscripts/csresspec.py +++ b/cscripts/csresspec.py @@ -806,6 +806,9 @@ class csresspec(ctools.csobservation): table = self._results2table(results[0]) self._fits.append(table) + # Stamp FITS file + self._stamp(self._fits) + # Return return diff --git a/cscripts/csroot2caldb.py b/cscripts/csroot2caldb.py index c0a9aeb..8c2c71d 100755 --- a/cscripts/csroot2caldb.py +++ b/cscripts/csroot2caldb.py @@ -2,7 +2,7 @@ # ========================================================================== # Generate IRFs in CALDB format from a ROOT offaxis performance file # -# Copyright (C) 2016-2018 Juergen Knoedlseder +# Copyright (C) 2016-2021 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -406,6 +406,9 @@ class csroot2caldb(ctools.cscript): hdu.card(key, item, 'HDU class') hdu.card('HDUVERS', '0.2', 'HDU version') + # Stamp HDU + self._stamp(hdu) + # Return return diff --git a/cscripts/csscs.py b/cscripts/csscs.py index 1af4e92..2b0ec27 100755 --- a/cscripts/csscs.py +++ b/cscripts/csscs.py @@ -2,7 +2,7 @@ # ========================================================================== # Spectral component separation script # -# Copyright (C) 2020 Luigi Tibaldo +# Copyright (C) 2020-2021 Luigi Tibaldo # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -834,6 +834,9 @@ class csscs(ctools.csobservation): # Fill output Fits self._fits = self._fill_fits(results) + # Stamp FITS file + self._stamp(self._fits) + # Return return diff --git a/cscripts/csspec.py b/cscripts/csspec.py index 8f70550..59efc7f 100755 --- a/cscripts/csspec.py +++ b/cscripts/csspec.py @@ -1229,6 +1229,9 @@ class csspec(ctools.csobservation): table.append(norm_scan) table.append(dloglike_scan) + # Stamp table + self._stamp(table) + # Create the FITS file now self._fits = gammalib.GFits() self._fits.append(table) diff --git a/cscripts/cstsmapmerge.py b/cscripts/cstsmapmerge.py index 8e9bbeb..34c1df2 100755 --- a/cscripts/cstsmapmerge.py +++ b/cscripts/cstsmapmerge.py @@ -2,7 +2,7 @@ # ========================================================================== # Merge Test Statistic maps # -# Copyright (C) 2015-2018 Michael Mayer +# Copyright (C) 2015-2021 Michael Mayer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -79,19 +79,19 @@ class cstsmapmerge(ctools.cscript): fname = f files.append(fname) self._files = files - + # Handle wild card strings elif '*' in inmaps: self._files = glob.glob(inmaps) - + # Handle space-separated list elif ' ' in inmaps: self._files = inmaps.split(' ') - + # Handle semi-colon separated list elif ';' in inmaps: self._files = inmaps.split(';') - + # Throw exception if input models cannot be decoded else: msg = 'Parameter "inmaps" must contain either an @ASCII '\ @@ -108,24 +108,24 @@ class cstsmapmerge(ctools.cscript): # Get other parameters self._overwrite = self['overwrite'].boolean() self._delete = self['delete'].boolean() - + # Read ahead output filename if self._read_ahead(): self['outmap'].filename() - + # Write input parameters into logger self._log_parameters(gammalib.TERSE) # Return return - + def _init_ts_map(self, fitsfile): """ Initialise Test Statistic map. """ # Set filename self._in_filename = fitsfile - + # Open FITS file fits = gammalib.GFits(fitsfile) @@ -134,26 +134,26 @@ class cstsmapmerge(ctools.cscript): self._tsmap.read(fits[0]) self._statusmap = gammalib.GSkyMap() self._statusmap.read(fits['STATUS MAP']) - + # Get other maps self._maps = [] self._mapnames = [] - + # Loop over extensions for hdu in fits: - + # Leave out primary and status extension if hdu.extname() != 'IMAGE' and hdu.extname() != 'STATUS MAP': - + # Add present maps skymap = gammalib.GSkyMap() skymap.read(hdu) self._maps.append(skymap) self._mapnames.append(hdu.extname()) - - # Close FITS file + + # Close FITS file fits.close() - + # Return return @@ -172,24 +172,24 @@ class cstsmapmerge(ctools.cscript): add_tsmap.read(fits[0]) add_statusmap = gammalib.GSkyMap() add_statusmap.read(fits['STATUS MAP']) - + # Get other maps add_maps = [] - + # Loop over extensions for hdu in fits: - + # Leave out primary and status extension if hdu.extname() != 'IMAGE' and hdu.extname() != 'STATUS MAP': - + # Add present maps skymap = gammalib.GSkyMap() skymap.read(hdu) add_maps.append(skymap) - + # Close FITS file fits.close() - + # Compare size of maps if not len(add_maps) == len(self._maps): msg = 'Cannot merge map "'+fitsfile+'" into map "'+\ @@ -197,12 +197,12 @@ class cstsmapmerge(ctools.cscript): 'between both maps is different.' raise RuntimeError(msg) - # Loop over bins + # Loop over bins for i in range(self._tsmap.npix()): # Consider only bins that have been computed if add_statusmap[i] > -0.5: - + # Raise exception if this bin has already been computed if self._statusmap[i] > -0.5 and not self._overwrite: msg = 'Attempt to merge bin which apparently has '+\ @@ -210,17 +210,17 @@ class cstsmapmerge(ctools.cscript): 'contains already merged bins. Set hidden '+\ 'parameter "overwrite=yes" to avoid this error.' raise RuntimeError(msg) - + # Copy TS values self._tsmap[i] = add_tsmap[i] - - # Copy status + + # Copy status self._statusmap[i] = add_statusmap[i] - + # Loop over maps and copy entries for j in range(len(self._maps)): self._maps[j][i] = add_maps[j][i] - + # Return return @@ -258,21 +258,21 @@ class cstsmapmerge(ctools.cscript): # Get parameters self._get_parameters() - + # Write header into logger self._log_header1(gammalib.TERSE, 'Merge TS maps') - + # Initialise file to start with file0 = '' self._merged_files = [] - + # Test files for the entry status map. Use the first one to appear # useful for fitsfile in self._files: # Skip file if it's not a FITS file if not gammalib.GFilename(fitsfile).is_fits(): - + # Log message self._log_value(gammalib.EXPLICIT, 'Skip file', fitsfile + ' (not a FITS file)') @@ -285,32 +285,32 @@ class cstsmapmerge(ctools.cscript): # If file contains a status map then use it if fits.contains('STATUS MAP'): - + # Close FITS file fits.close() - + # Set filename to initial filename file0 = fitsfile - + # Log message pix_info = ' (%d TS pixels computed)' % \ self._get_number_of_ts_pixels(fitsfile) self._log_value(gammalib.TERSE, 'Initial TS map file', fitsfile + pix_info) - + # Leave loop break # ... otherwise signal that file is useless else: - + # Close fits file - fits.close() - - # Info message + fits.close() + + # Info message self._log_value(gammalib.EXPLICIT, 'Skip file', fitsfile + ' (no "STATUS MAP" extension)') - + # Continue continue @@ -323,22 +323,22 @@ class cstsmapmerge(ctools.cscript): # ... otherwise merge files else: - + # Copy file list workfiles = self._files - + # Remove entry which will be used to initalise the map workfiles.remove(file0) - + # Initialise map from first file self._init_ts_map(file0) - + # Append to added files self._merged_files.append(file0) - + # Loop over files for fitsfile in workfiles: - + # Skip if file is not FITS if not gammalib.GFilename(fitsfile).is_fits(): self._log_value(gammalib.EXPLICIT, 'Skip file', fitsfile + @@ -347,7 +347,7 @@ class cstsmapmerge(ctools.cscript): # Open FITS file fits = gammalib.GFits(fitsfile) - + # Skip if file does not contain status map if not fits.contains('STATUS MAP'): fits.close() @@ -357,19 +357,19 @@ class cstsmapmerge(ctools.cscript): # Close FITS file fits.close() - + # Logging pix_info = ' (%d TS pixels computed)' % \ self._get_number_of_ts_pixels(fitsfile) self._log_value(gammalib.TERSE, 'Merge TS map file', fitsfile + pix_info) - + # Merge TS map self._merge_ts_map(fitsfile) - + # Append FITS file to merged files self._merged_files.append(fitsfile) - + # Return return @@ -380,17 +380,17 @@ class cstsmapmerge(ctools.cscript): # Get output filename in case it was not read ahead outmap = self['outmap'].filename() - + # Create FITS file fits = gammalib.GFits() - + # Write TS map into primary self._tsmap.write(fits) # Loop over maps and write them to fits for i in range(len(self._maps)): self._maps[i].write(fits) - + # Set map names as extensions for i in range(len(self._mapnames)): fits[i+1].extname(self._mapnames[i]) @@ -398,7 +398,10 @@ class cstsmapmerge(ctools.cscript): # Treat status map separately self._statusmap.write(fits) fits[fits.size()-1].extname('STATUS MAP') - + + # Stamp FITS file + self._stamp(fits) + # Check if map is fully done bins_merged = 0 for pix in self._statusmap: @@ -407,50 +410,50 @@ class cstsmapmerge(ctools.cscript): # Set boolean if map is fully done done = (bins_merged == self._tsmap.npix()) - + # Log summary header self._log_header2(gammalib.TERSE, 'Merging Summary') - + # Write computing status if we are not done yet if not done: - + # Log bins that were computed and those that were missing self._log_value(gammalib.TERSE, 'TS map bins', self._tsmap.npix()) self._log_value(gammalib.TERSE, 'Bins computed and merged', bins_merged ) self._log_value(gammalib.TERSE, 'Bins missing', self._tsmap.npix() - bins_merged) - + else: - + # Write success message self._log_string(gammalib.TERSE, 'TS map was fully computed and successfully merged') - + # Write header self._log_header1(gammalib.TERSE, 'Save TS map') - + # Log filename self._log_value(gammalib.TERSE, 'TS map file', outmap.url()) - + # Save FITS file - fits.saveto(outmap, self._clobber()) + fits.saveto(outmap, self._clobber()) # Delete TS input maps if requested and map is fully done if self._delete and done: - + # Log header self._log_header2(gammalib.TERSE, 'Delete slices TS map files') - + # Loop over sliced files for filename in self._merged_files: - + # Remove file os.remove(filename) - + # Log message about file self._log_value(gammalib.TERSE,'Deleted input file', filename) - + # Return return - + # ======================== # # Main routine entry point # @@ -459,6 +462,6 @@ if __name__ == '__main__': # Create instance of application app = cstsmapmerge(sys.argv) - + # Execute application app.execute() diff --git a/cscripts/csviscube.py b/cscripts/csviscube.py index 7e79b67..741c43d 100755 --- a/cscripts/csviscube.py +++ b/cscripts/csviscube.py @@ -2,7 +2,7 @@ # ========================================================================== # Compute a visibility cube # -# Copyright (C) 2016-2019 Juergen Knoedlseder +# Copyright (C) 2016-2021 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -671,6 +671,9 @@ class csviscube(ctools.cscript): # Save the results in VISIBILITY table extension self._save_results(outfile, self['clobber'].boolean()) + # Stamp visibility cube + self._stamp(outfile) + # Return return diff --git a/doc/source/admin/release_history/2.0.rst b/doc/source/admin/release_history/2.0.rst index ee35000..a415ec8 100644 --- a/doc/source/admin/release_history/2.0.rst +++ b/doc/source/admin/release_history/2.0.rst @@ -24,6 +24,8 @@ Bug fixes Improvements ------------ +* [`3662 `_] - + Stamp all output FITS files * [`3668 `_] - Add source counts constraints to :ref:`cssens` * [`3630 `_] - diff --git a/src/ctbin/ctbin.cpp b/src/ctbin/ctbin.cpp index a41108e..c29ae90 100755 --- a/src/ctbin/ctbin.cpp +++ b/src/ctbin/ctbin.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctbin - Event binning tool * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2020 by Juergen Knoedlseder * + * copyright (C) 2010-2021 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -509,6 +509,9 @@ void ctbin::save(void) // Save cube obs->save(outobs, clobber()); + // Stamp counts cube + stamp(outobs); + } // endif: observation was valid } // endif: outobs file was valid @@ -534,6 +537,9 @@ void ctbin::save(void) // Save counts cube obs->save(filename, clobber()); + // Stamp counts cube + stamp(filename); + } // endif: observation was valid } // endfor: looped over all observations diff --git a/src/ctbkgcube/ctbkgcube.cpp b/src/ctbkgcube/ctbkgcube.cpp index 6d99048..6caa276 100755 --- a/src/ctbkgcube/ctbkgcube.cpp +++ b/src/ctbkgcube/ctbkgcube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctbkgcube - Background cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2018 by Chia-Chun Lu * + * copyright (C) 2014-2021 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -365,11 +365,13 @@ void ctbkgcube::save(void) if ((*this)["outcube"].is_valid() && !m_background.cube().is_empty()) { // Get background cube file name - m_outcube = (*this)["outcube"].filename(); + m_outcube = (*this)["outcube"].filename(); // Save background cube m_background.save(m_outcube, clobber()); + // Stamp background cube + stamp(m_outcube); } // Save model definition file if requested diff --git a/src/ctcubemask/ctcubemask.cpp b/src/ctcubemask/ctcubemask.cpp index b40223f..2e5f7f7 100755 --- a/src/ctcubemask/ctcubemask.cpp +++ b/src/ctcubemask/ctcubemask.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctcubemask - Cube filter tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2018 by Chia-Chun Lu * + * copyright (C) 2014-2021 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -690,7 +690,10 @@ void ctcubemask::save_fits(void) // Save counts cube obs->save(m_outcube, clobber()); - + + // Stamp counts cube + stamp(m_outcube); + } // endif: observation was a CTA observation } @@ -737,6 +740,9 @@ void ctcubemask::save_xml(void) // Save counts cube obs->save(outfile, clobber()); + // Stamp counts cube + stamp(outfile); + } // endif: observation was a CTA observations } // endfor: looped over observations diff --git a/src/ctedispcube/ctedispcube.cpp b/src/ctedispcube/ctedispcube.cpp index 950bbbe..9d2c884 100755 --- a/src/ctedispcube/ctedispcube.cpp +++ b/src/ctedispcube/ctedispcube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctedispcube - Energy dispersion cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2016-2018 by Maria Haupt * + * copyright (C) 2016-2021 by Maria Haupt * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -270,6 +270,9 @@ void ctedispcube::save(void) // Save energy dispersion cube m_edispcube.save(m_outcube, clobber()); + // Stamp energy dispersion cube + stamp(m_outcube); + } // Write into logger what has been done diff --git a/src/ctexpcube/ctexpcube.cpp b/src/ctexpcube/ctexpcube.cpp index 3be5b66..77bf1b3 100755 --- a/src/ctexpcube/ctexpcube.cpp +++ b/src/ctexpcube/ctexpcube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctexpcube - Exposure cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2018 by Juergen Knoedlseder * + * copyright (C) 2014-2021 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -266,6 +266,9 @@ void ctexpcube::save(void) // Save exposure cube m_expcube.save(m_outcube, clobber()); + // Stamp exposure cube + stamp(m_outcube); + } // Write into logger what has been done diff --git a/src/ctfindvar/ctfindvar.cpp b/src/ctfindvar/ctfindvar.cpp index 3697f7e..1fb86df 100644 --- a/src/ctfindvar/ctfindvar.cpp +++ b/src/ctfindvar/ctfindvar.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctfindvar - Time variability search tool * * ----------------------------------------------------------------------- * - * copyright (C) 2018-2020 by Simon Bonnefoy * + * copyright (C) 2018-2021 by Simon Bonnefoy * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -273,6 +273,7 @@ void ctfindvar::save(void) // counts cube was saved. if (!m_counts.is_empty()) { m_counts.save(outcube, (*this)["clobber"].boolean()); + stamp(outcube); log_value(TERSE, "Counts cube file", outcube.url()); } else { @@ -298,6 +299,9 @@ void ctfindvar::save(void) // Write source histograms write_source_histograms(fits); + // Stamp FITS file + stamp(fits); + // Save significance map fits.saveto(outmap, (*this)["clobber"].boolean()); diff --git a/src/ctmapcube/ctmapcube.cpp b/src/ctmapcube/ctmapcube.cpp index c2e7ec2..2ce618f 100755 --- a/src/ctmapcube/ctmapcube.cpp +++ b/src/ctmapcube/ctmapcube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctmapcube - Map cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2016-2018 by Juergen Knoedlseder * + * copyright (C) 2016-2021 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -231,6 +231,8 @@ void ctmapcube::save(void) // Save map cube m_cube.save(m_outcube, clobber()); + // Stamp map cube + stamp(m_outcube); } // Write into logger what has been done diff --git a/src/ctmodel/ctmodel.cpp b/src/ctmodel/ctmodel.cpp index 5b43766..3799cac 100755 --- a/src/ctmodel/ctmodel.cpp +++ b/src/ctmodel/ctmodel.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctmodel - Model cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2019 by Juergen Knoedlseder * + * copyright (C) 2012-2021 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -326,6 +326,10 @@ void ctmodel::save(void) // Save cube m_cube.save(m_outcube, clobber()); + + // Stamp model cube + stamp(m_outcube); + } // Write into logger what has been done diff --git a/src/ctobssim/ctobssim.cpp b/src/ctobssim/ctobssim.cpp index 6172cba..ed3d1a2 100755 --- a/src/ctobssim/ctobssim.cpp +++ b/src/ctobssim/ctobssim.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctobssim - Observation simulator tool * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2020 by Juergen Knoedlseder * + * copyright (C) 2011-2021 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -1712,6 +1712,9 @@ void ctobssim::save_fits(void) // Save observation into FITS file obs->save(m_outevents, clobber()); + // Stamp FITS file + stamp(m_outevents); + } // endif: event list has not yet been saved and disposed // Return @@ -1764,6 +1767,9 @@ void ctobssim::save_xml(void) // Save observation into FITS file obs->save(outfile, clobber()); + // Stamp FITS file + stamp(outfile); + } } // endif: observation was a CTA observations diff --git a/src/ctpsfcube/ctpsfcube.cpp b/src/ctpsfcube/ctpsfcube.cpp index 42a1585..e65a140 100755 --- a/src/ctpsfcube/ctpsfcube.cpp +++ b/src/ctpsfcube/ctpsfcube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctpsfcube - PSF cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2018 by Chia-Chun Lu * + * copyright (C) 2014-2021 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -257,6 +257,9 @@ void ctpsfcube::save(void) // Save PSF cube m_psfcube.save(m_outcube, clobber()); + // Stamp PSF cube + stamp(m_outcube); + } // Write into logger what has been done diff --git a/src/ctskymap/ctskymap.cpp b/src/ctskymap/ctskymap.cpp index 6b0a285..c0a10e2 100755 --- a/src/ctskymap/ctskymap.cpp +++ b/src/ctskymap/ctskymap.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctskymap - Sky mapping tool * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2019 by Juergen Knoedlseder * + * copyright (C) 2011-2021 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -322,6 +322,10 @@ void ctskymap::construct_fits(void) } // endif: background subtraction was requested + // Stamp FITS file + stamp(m_fits); + + // Return return; } diff --git a/src/cttsmap/cttsmap.cpp b/src/cttsmap/cttsmap.cpp index 565d280..0e98864 100755 --- a/src/cttsmap/cttsmap.cpp +++ b/src/cttsmap/cttsmap.cpp @@ -419,6 +419,9 @@ void cttsmap::save(void) m_statusmap.write(fits); fits[fits.size()-1]->extname("STATUS MAP"); + // Stamp FITS file + stamp(fits); + // Save FITS file fits.saveto(m_outmap, clobber()); diff --git a/src/support/ctool.cpp b/src/support/ctool.cpp index d417a71..5640a89 100755 --- a/src/support/ctool.cpp +++ b/src/support/ctool.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctool - ctool base class * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2020 by Juergen Knoedlseder * + * copyright (C) 2014-2021 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -2266,6 +2266,9 @@ void ctool::save_event_list(const GCTAObservation* obs, // Close input file infits.close(); + // Stamp FITS file + stamp(outfits); + // Save file to disk and close it (we need both operations) outfits.saveto(outname.url(), clobber()); outfits.close(); -- libgit2 0.21.4