Commit 862f5bcb3911dc2317b7fba18f77bc13940e7cf4

Authored by Jürgen Knödlseder
1 parent 78d948d7

Stamp all output FITS files (#3662)

ChangeLog
... ... @@ -4,6 +4,7 @@
4 4 ========================
5 5  
6 6 Add source counts constraints to cssens (#3668)
  7 + Stamp all output FITS files (#3662)
7 8 Add ASCL shields to "About" page (#3630)
8 9 Use file function constructor in csspec (#3626)
9 10 Add BINS method to csspec (#3606)
... ...
... ... @@ -39,28 +39,31 @@ None
39 39  
40 40 ctbin - CTA event binning
41 41 -------------------------
  42 +Stamp output counts cube (#3662).
  43 +
42 44 Removed implicit conversion warning during C++ compilation (#3324).
43 45  
44 46  
45 47 ctbkgcube - CTA background cube generation
46 48 ------------------------------------------
47   -None
  49 +Stamp output background cube (#3662).
48 50  
49 51  
50 52 ctbutterfly - Generate butterfly diagrams
51 53 -----------------------------------------
52 54 The ASCII output file was replaced by a FITS file, and the butterfly() method
53   -now returns a GFits objects instead of a GCsv object (#1707).
  55 +now returns a GFits objects instead of a GCsv object (#1707). The output FITS
  56 +file is also stamped (#3662).
54 57  
55 58  
56 59 ctcubemask - CTA cube filtering
57 60 -------------------------------
58   -None
  61 +Stamp output masked cube (#3662).
59 62  
60 63  
61 64 ctedispcube - CTA energy dispersion cube generation
62 65 ---------------------------------------------------
63   -None
  66 +Stamp output energy dispersion cube (#3662).
64 67  
65 68  
66 69 cterror - Likelihood profile error computation
... ... @@ -70,12 +73,12 @@ None
70 73  
71 74 ctexpcube - CTA exposure cube generation
72 75 ----------------------------------------
73   -None
  76 +Stamp output exposure cube (#3662).
74 77  
75 78  
76 79 ctfindvar - Variability search
77 80 ------------------------------
78   -None
  81 +Stamp output FITS files (#3662).
79 82  
80 83  
81 84 ctlike - Maximum likelihood fitting
... ... @@ -99,47 +102,53 @@ are fixed for all sky models (#3426).
99 102  
100 103 ctmapcube - CTA map cube generation
101 104 -----------------------------------
102   -None
  105 +Stamp output map cube (#3662).
103 106  
104 107  
105 108 ctmodel - CTA counts cube modelling
106 109 -----------------------------------
107   -None
  110 +Stamp output model cube (#3662).
108 111  
109 112  
110 113 ctobssim - CTA observation simulation
111 114 -------------------------------------
  115 +Stamp output event files (#3662).
  116 +
112 117 Added models() method allowing for a setting of the model container without
113 118 using the "inmodels" parameter (#3441).
114 119  
115 120  
116 121 ctphase - Event phase computation
117 122 ---------------------------------
118   -None
  123 +Stamp output event files (#3662).
119 124  
120 125  
121 126 ctprob - Event probability computation
122 127 --------------------------------------
123   -None
  128 +Stamp output event files (#3662).
124 129  
125 130  
126 131 ctpsfcube - CTA point spread function cube generation
127 132 -----------------------------------------------------
128   -None
  133 +Stamp output point spread function cube (#3662).
129 134  
130 135  
131 136 ctselect - CTA event selection
132 137 ------------------------------
  138 +Stamp output event files (#3662).
  139 +
133 140 Replaced std::tmpnam() by gammalib::tmpnam() function in ctselect (#3324).
134 141  
135 142  
136 143 ctskymap - CTA sky mapping
137 144 --------------------------
138   -None
  145 +Stamp output sky map (#3662).
139 146  
140 147  
141 148 cttsmap - Generation of Test Statistic map
142 149 ------------------------------------------
  150 +Stamp output TS map (#3662).
  151 +
143 152 Added hidden "fix_spat" parameter that instructs the tool to fix all spatial
144 153 model parameters (#3562).
145 154  
... ... @@ -151,7 +160,7 @@ None
151 160  
152 161 support - Support classes
153 162 -------------------------
154   -None
  163 +Add stamping to ctool::save_event_list() method (#3662).
155 164  
156 165  
157 166 csbkgmodel - Generate background model for 3D analysis
... ... @@ -166,7 +175,7 @@ None
166 175  
167 176 csebins - Generate energy boundaries
168 177 ------------------------------------
169   -None
  178 +Stamp output energy boundaries file (#3662).
170 179  
171 180  
172 181 csfindobs - Find IACT observations
... ... @@ -191,6 +200,8 @@ None
191 200  
192 201 cslightcrv - Generate light curve
193 202 ---------------------------------
  203 +Stamp output light curve file (#3662).
  204 +
194 205 Added support for rectangular On/Off regions. The "srcshape" parameter now
195 206 can now be set to "RECT" to use rectangular sky regions. The parameter is now
196 207 automatic. The parameters "width", "height", and "posang" were added to specify
... ... @@ -214,12 +225,12 @@ None
214 225  
215 226 csmodelsois - Puts selected sources in diffuse model cube
216 227 ---------------------------------------------------------
217   -None
  228 +Stamp output diffuse model cube (#3662).
218 229  
219 230  
220 231 csobs2caldb - Generate calibration database entry for an IACT observation
221 232 -------------------------------------------------------------------------
222   -None
  233 +Stamp output IRF files (#3662).
223 234  
224 235  
225 236 csobsdef - Generate observation definition XML file
... ... @@ -239,6 +250,8 @@ None
239 250  
240 251 csphagen - Generate On/Off observations
241 252 ---------------------------------------
  253 +Stamp output OGIP files (#3662).
  254 +
242 255 Added support for rectangular On/Off regions. The "srcshape" parameter now
243 256 can now be set to "RECT" to use rectangular sky regions. The parameter is now
244 257 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).
247 260  
248 261 csphasecrv - Generate phase curve
249 262 ---------------------------------
  263 +Stamp output phase curve file (#3662).
  264 +
250 265 Added support for rectangular On/Off regions. The "srcshape" parameter now
251 266 can now be set to "RECT" to use rectangular sky regions. The parameter is now
252 267 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).
255 270  
256 271 cspull - Generate pull distributions
257 272 ------------------------------------
258   -The ASCII output file was replaced by a FITS file (#1707).
  273 +The ASCII output file was replaced by a FITS file (#1707). The output FITS file
  274 +is stamped (#3662).
259 275  
260 276  
261 277 csresmap - Generate residual map
262 278 --------------------------------
263   -None
  279 +Stamp output residual map (#3662).
264 280  
265 281  
266 282 csresspec - Generate residual spectrum
267 283 --------------------------------------
268   -None
  284 +Stamp output residual spectrum (#3662).
269 285  
270 286  
271 287 csroot2caldb - Generates calibration database from ROOT file
272 288 ------------------------------------------------------------
273   -None
  289 +Stamp output IRF files (#3662).
274 290  
275 291  
276 292 csscs - Spectral component separation
277 293 -------------------------------------
  294 +Stamp output FITS file (#3662).
  295 +
278 296 Added support for rectangular On/Off regions. The "srcshape" parameter now
279 297 can now be set to "RECT" to use rectangular sky regions. The parameter is now
280 298 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
293 311 in galactic latitude by a number of degrees specified using the "offset"
294 312 parameter (#3555).
295 313  
296   -The ASCII output file was replaced by a FITS file (#1707).
  314 +The ASCII output file was replaced by a FITS file (#1707). The output FITS file
  315 +is stamped (#3662).
297 316  
298 317  
299 318 csspec - Generates Spectral Energy Distribution
300 319 -----------------------------------------------
  320 +Stamp output spectrum (#3662).
  321 +
301 322 The GModelSpectralFunc spectral model constructor is now used to convert any
302 323 spectral model into a file function before spectral model fitting (#3626).
303 324  
... ... @@ -313,12 +334,13 @@ None
313 334  
314 335 cstsdist - Computes Test Statistic distribution
315 336 -----------------------------------------------
316   -The ASCII output file was replaced by a FITS file (#1707).
  337 +The ASCII output file was replaced by a FITS file (#1707). The output FITS
  338 +file is stamped (#3662).
317 339  
318 340  
319 341 cstsmapmerge - Merge Test Statistic maps
320 342 ----------------------------------------
321   -None
  343 +Stamp output TS map (#3662).
322 344  
323 345  
324 346 cstsmapsplit - Prepare split Test Statistic computation
... ... @@ -328,7 +350,7 @@ None
328 350  
329 351 csviscube - Generate visibility cube
330 352 ------------------------------------
331   -None
  353 +Stamp output visibility cube (#3662).
332 354  
333 355  
334 356 csworkflow - Execute workflow
... ...
cscripts/csebins.py
... ... @@ -277,6 +277,9 @@ class csebins(ctools.csobservation):
277 277 # Save energy boundaries
278 278 self._ebounds.save(outfile, self._clobber())
279 279  
  280 + # Stamp energy boundaries
  281 + self._stamp(outfile)
  282 +
280 283 # Return
281 284 return
282 285  
... ...
cscripts/cslightcrv.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Generates a lightcurve.
4 4 #
5   -# Copyright (C) 2014-2019 Michael Mayer
  5 +# Copyright (C) 2014-2021 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -673,6 +673,9 @@ class cslightcrv(ctools.csobservation):
673 673 self._fits = gammalib.GFits()
674 674 self._fits.append(table)
675 675  
  676 + # Stamp FITS file
  677 + self._stamp(self._fits)
  678 +
676 679 # Optionally publish light curve
677 680 if self['publish'].boolean():
678 681 self.publish()
... ...
cscripts/csmodelsois.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Puts subset of sources in diffuse model cube
4 4 #
5   -# Copyright (C) 2017-2018 Josh Cardenzana
  5 +# Copyright (C) 2017-2021 Josh Cardenzana
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -40,11 +40,11 @@ class csmodelsois(ctools.cscript):
40 40 def __init__(self, *argv):
41 41 """
42 42 Constructor
43   -
  43 +
44 44 Parameters
45 45 ----------
46 46 argv : list of parameters
47   -
  47 +
48 48 Raises
49 49 ------
50 50 TypeError
... ... @@ -52,12 +52,12 @@ class csmodelsois(ctools.cscript):
52 52 """
53 53 # Initialise application by calling the base class constructor
54 54 self._init_cscript(self.__class__.__name__, ctools.__version__, argv)
55   -
  55 +
56 56 # Initialize parameters
57 57 self._cubegen = ctools.ctmapcube()
58 58 self._models = gammalib.GModels()
59 59 self._cubemodels = gammalib.GModels()
60   -
  60 +
61 61 # Return
62 62 return
63 63  
... ... @@ -186,15 +186,20 @@ class csmodelsois(ctools.cscript):
186 186 # Save the generated cube if the cube and filename are not empty
187 187 if ((not self._cubegen.mapcube().cube().is_empty()) and
188 188 self['outcube'].is_valid()):
  189 +
  190 + # Save cube
189 191 self._cubegen.mapcube().save(self['outcube'].filename(),
190 192 self['clobber'].boolean())
191   -
  193 +
  194 + # Stamp cube
  195 + self._stamp(self['outcube'].filename())
  196 +
192 197 # If requested, save the updated list of models
193 198 if self['outmodel'].is_valid():
194 199  
195 200 # Generate a list of models that will be output to file
196 201 outmodels = gammalib.GModels(self._models)
197   -
  202 +
198 203 # Remove all models used in the generated cube
199 204 for model in self._cubemodels:
200 205 outmodels.remove(model.name())
... ... @@ -250,9 +255,9 @@ class csmodelsois(ctools.cscript):
250 255 # Main routine entry point #
251 256 # ======================== #
252 257 if __name__ == '__main__':
253   -
  258 +
254 259 # Create instance of application
255 260 app = csmodelsois(sys.argv)
256   -
  261 +
257 262 # Execute application
258 263 app.execute()
... ...
cscripts/csobs2caldb.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Creates a calibration database entry for an IACT observation
4 4 #
5   -# Copyright (C) 2015-2018 Michael Mayer
  5 +# Copyright (C) 2015-2021 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -375,6 +375,9 @@ class csobs2caldb(ctools.csobservation):
375 375 # Save response file
376 376 self._irf_fits.saveto(filename, self._clobber())
377 377  
  378 + # Stamp response file
  379 + self._stamp(filename)
  380 +
378 381 # Return
379 382 return
380 383  
... ...
cscripts/csphagen.py
... ... @@ -1138,6 +1138,12 @@ class csphagen(ctools.csobservation):
1138 1138 obs.arf().save(arfname, clobber)
1139 1139 obs.rmf().save(rmfname, clobber)
1140 1140  
  1141 + # Stamp files
  1142 + self._stamp(onname)
  1143 + self._stamp(offname)
  1144 + self._stamp(arfname)
  1145 + self._stamp(rmfname)
  1146 +
1141 1147 # Log file names
1142 1148 self._log_value(gammalib.NORMAL, 'PHA on file', onname)
1143 1149 self._log_value(gammalib.NORMAL, 'PHA off file', offname)
... ...
cscripts/csphasecrv.py
... ... @@ -318,6 +318,9 @@ class csphasecrv(ctools.csobservation):
318 318 self._fits = gammalib.GFits()
319 319 self._fits.append(table)
320 320  
  321 + # Stamp FITS file
  322 + self._stamp(self._fits)
  323 +
321 324 # Return
322 325 return
323 326  
... ...
cscripts/csresmap.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Generates a residual map.
4 4 #
5   -# Copyright (C) 2014-2020 Michael Mayer
  5 +# Copyright (C) 2014-2021 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -213,7 +213,7 @@ class csresmap(ctools.csobservation):
213 213  
214 214 # Get outmap parameter
215 215 outmap = self['outmap'].filename()
216   -
  216 +
217 217 # Continue only filename and residual map are valid
218 218 if self._resmap != None:
219 219  
... ... @@ -223,6 +223,9 @@ class csresmap(ctools.csobservation):
223 223 # Save residual map
224 224 self._resmap.save(outmap, self['clobber'].boolean())
225 225  
  226 + # Stamp residual map
  227 + self._stamp(outmap)
  228 +
226 229 # Return
227 230 return
228 231  
... ... @@ -240,7 +243,7 @@ class csresmap(ctools.csobservation):
240 243  
241 244 # Continue only if residual map is valid
242 245 if self._resmap != None:
243   -
  246 +
244 247 # Set default name is user name is empty
245 248 if not name:
246 249 user_name = self._name()
... ...
cscripts/csresspec.py
... ... @@ -806,6 +806,9 @@ class csresspec(ctools.csobservation):
806 806 table = self._results2table(results[0])
807 807 self._fits.append(table)
808 808  
  809 + # Stamp FITS file
  810 + self._stamp(self._fits)
  811 +
809 812 # Return
810 813 return
811 814  
... ...
cscripts/csroot2caldb.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Generate IRFs in CALDB format from a ROOT offaxis performance file
4 4 #
5   -# Copyright (C) 2016-2018 Juergen Knoedlseder
  5 +# Copyright (C) 2016-2021 Juergen Knoedlseder
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -406,6 +406,9 @@ class csroot2caldb(ctools.cscript):
406 406 hdu.card(key, item, 'HDU class')
407 407 hdu.card('HDUVERS', '0.2', 'HDU version')
408 408  
  409 + # Stamp HDU
  410 + self._stamp(hdu)
  411 +
409 412 # Return
410 413 return
411 414  
... ...
cscripts/csscs.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Spectral component separation script
4 4 #
5   -# Copyright (C) 2020 Luigi Tibaldo
  5 +# Copyright (C) 2020-2021 Luigi Tibaldo
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -834,6 +834,9 @@ class csscs(ctools.csobservation):
834 834 # Fill output Fits
835 835 self._fits = self._fill_fits(results)
836 836  
  837 + # Stamp FITS file
  838 + self._stamp(self._fits)
  839 +
837 840 # Return
838 841 return
839 842  
... ...
cscripts/csspec.py
... ... @@ -1229,6 +1229,9 @@ class csspec(ctools.csobservation):
1229 1229 table.append(norm_scan)
1230 1230 table.append(dloglike_scan)
1231 1231  
  1232 + # Stamp table
  1233 + self._stamp(table)
  1234 +
1232 1235 # Create the FITS file now
1233 1236 self._fits = gammalib.GFits()
1234 1237 self._fits.append(table)
... ...
cscripts/cstsmapmerge.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Merge Test Statistic maps
4 4 #
5   -# Copyright (C) 2015-2018 Michael Mayer
  5 +# Copyright (C) 2015-2021 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -79,19 +79,19 @@ class cstsmapmerge(ctools.cscript):
79 79 fname = f
80 80 files.append(fname)
81 81 self._files = files
82   -
  82 +
83 83 # Handle wild card strings
84 84 elif '*' in inmaps:
85 85 self._files = glob.glob(inmaps)
86   -
  86 +
87 87 # Handle space-separated list
88 88 elif ' ' in inmaps:
89 89 self._files = inmaps.split(' ')
90   -
  90 +
91 91 # Handle semi-colon separated list
92 92 elif ';' in inmaps:
93 93 self._files = inmaps.split(';')
94   -
  94 +
95 95 # Throw exception if input models cannot be decoded
96 96 else:
97 97 msg = 'Parameter "inmaps" must contain either an @ASCII '\
... ... @@ -108,24 +108,24 @@ class cstsmapmerge(ctools.cscript):
108 108 # Get other parameters
109 109 self._overwrite = self['overwrite'].boolean()
110 110 self._delete = self['delete'].boolean()
111   -
  111 +
112 112 # Read ahead output filename
113 113 if self._read_ahead():
114 114 self['outmap'].filename()
115   -
  115 +
116 116 # Write input parameters into logger
117 117 self._log_parameters(gammalib.TERSE)
118 118  
119 119 # Return
120 120 return
121   -
  121 +
122 122 def _init_ts_map(self, fitsfile):
123 123 """
124 124 Initialise Test Statistic map.
125 125 """
126 126 # Set filename
127 127 self._in_filename = fitsfile
128   -
  128 +
129 129 # Open FITS file
130 130 fits = gammalib.GFits(fitsfile)
131 131  
... ... @@ -134,26 +134,26 @@ class cstsmapmerge(ctools.cscript):
134 134 self._tsmap.read(fits[0])
135 135 self._statusmap = gammalib.GSkyMap()
136 136 self._statusmap.read(fits['STATUS MAP'])
137   -
  137 +
138 138 # Get other maps
139 139 self._maps = []
140 140 self._mapnames = []
141   -
  141 +
142 142 # Loop over extensions
143 143 for hdu in fits:
144   -
  144 +
145 145 # Leave out primary and status extension
146 146 if hdu.extname() != 'IMAGE' and hdu.extname() != 'STATUS MAP':
147   -
  147 +
148 148 # Add present maps
149 149 skymap = gammalib.GSkyMap()
150 150 skymap.read(hdu)
151 151 self._maps.append(skymap)
152 152 self._mapnames.append(hdu.extname())
153   -
154   - # Close FITS file
  153 +
  154 + # Close FITS file
155 155 fits.close()
156   -
  156 +
157 157 # Return
158 158 return
159 159  
... ... @@ -172,24 +172,24 @@ class cstsmapmerge(ctools.cscript):
172 172 add_tsmap.read(fits[0])
173 173 add_statusmap = gammalib.GSkyMap()
174 174 add_statusmap.read(fits['STATUS MAP'])
175   -
  175 +
176 176 # Get other maps
177 177 add_maps = []
178   -
  178 +
179 179 # Loop over extensions
180 180 for hdu in fits:
181   -
  181 +
182 182 # Leave out primary and status extension
183 183 if hdu.extname() != 'IMAGE' and hdu.extname() != 'STATUS MAP':
184   -
  184 +
185 185 # Add present maps
186 186 skymap = gammalib.GSkyMap()
187 187 skymap.read(hdu)
188 188 add_maps.append(skymap)
189   -
  189 +
190 190 # Close FITS file
191 191 fits.close()
192   -
  192 +
193 193 # Compare size of maps
194 194 if not len(add_maps) == len(self._maps):
195 195 msg = 'Cannot merge map "'+fitsfile+'" into map "'+\
... ... @@ -197,12 +197,12 @@ class cstsmapmerge(ctools.cscript):
197 197 'between both maps is different.'
198 198 raise RuntimeError(msg)
199 199  
200   - # Loop over bins
  200 + # Loop over bins
201 201 for i in range(self._tsmap.npix()):
202 202  
203 203 # Consider only bins that have been computed
204 204 if add_statusmap[i] > -0.5:
205   -
  205 +
206 206 # Raise exception if this bin has already been computed
207 207 if self._statusmap[i] > -0.5 and not self._overwrite:
208 208 msg = 'Attempt to merge bin which apparently has '+\
... ... @@ -210,17 +210,17 @@ class cstsmapmerge(ctools.cscript):
210 210 'contains already merged bins. Set hidden '+\
211 211 'parameter "overwrite=yes" to avoid this error.'
212 212 raise RuntimeError(msg)
213   -
  213 +
214 214 # Copy TS values
215 215 self._tsmap[i] = add_tsmap[i]
216   -
217   - # Copy status
  216 +
  217 + # Copy status
218 218 self._statusmap[i] = add_statusmap[i]
219   -
  219 +
220 220 # Loop over maps and copy entries
221 221 for j in range(len(self._maps)):
222 222 self._maps[j][i] = add_maps[j][i]
223   -
  223 +
224 224 # Return
225 225 return
226 226  
... ... @@ -258,21 +258,21 @@ class cstsmapmerge(ctools.cscript):
258 258  
259 259 # Get parameters
260 260 self._get_parameters()
261   -
  261 +
262 262 # Write header into logger
263 263 self._log_header1(gammalib.TERSE, 'Merge TS maps')
264   -
  264 +
265 265 # Initialise file to start with
266 266 file0 = ''
267 267 self._merged_files = []
268   -
  268 +
269 269 # Test files for the entry status map. Use the first one to appear
270 270 # useful
271 271 for fitsfile in self._files:
272 272  
273 273 # Skip file if it's not a FITS file
274 274 if not gammalib.GFilename(fitsfile).is_fits():
275   -
  275 +
276 276 # Log message
277 277 self._log_value(gammalib.EXPLICIT, 'Skip file', fitsfile +
278 278 ' (not a FITS file)')
... ... @@ -285,32 +285,32 @@ class cstsmapmerge(ctools.cscript):
285 285  
286 286 # If file contains a status map then use it
287 287 if fits.contains('STATUS MAP'):
288   -
  288 +
289 289 # Close FITS file
290 290 fits.close()
291   -
  291 +
292 292 # Set filename to initial filename
293 293 file0 = fitsfile
294   -
  294 +
295 295 # Log message
296 296 pix_info = ' (%d TS pixels computed)' % \
297 297 self._get_number_of_ts_pixels(fitsfile)
298 298 self._log_value(gammalib.TERSE, 'Initial TS map file',
299 299 fitsfile + pix_info)
300   -
  300 +
301 301 # Leave loop
302 302 break
303 303  
304 304 # ... otherwise signal that file is useless
305 305 else:
306   -
  306 +
307 307 # Close fits file
308   - fits.close()
309   -
310   - # Info message
  308 + fits.close()
  309 +
  310 + # Info message
311 311 self._log_value(gammalib.EXPLICIT, 'Skip file', fitsfile +
312 312 ' (no "STATUS MAP" extension)')
313   -
  313 +
314 314 # Continue
315 315 continue
316 316  
... ... @@ -323,22 +323,22 @@ class cstsmapmerge(ctools.cscript):
323 323  
324 324 # ... otherwise merge files
325 325 else:
326   -
  326 +
327 327 # Copy file list
328 328 workfiles = self._files
329   -
  329 +
330 330 # Remove entry which will be used to initalise the map
331 331 workfiles.remove(file0)
332   -
  332 +
333 333 # Initialise map from first file
334 334 self._init_ts_map(file0)
335   -
  335 +
336 336 # Append to added files
337 337 self._merged_files.append(file0)
338   -
  338 +
339 339 # Loop over files
340 340 for fitsfile in workfiles:
341   -
  341 +
342 342 # Skip if file is not FITS
343 343 if not gammalib.GFilename(fitsfile).is_fits():
344 344 self._log_value(gammalib.EXPLICIT, 'Skip file', fitsfile +
... ... @@ -347,7 +347,7 @@ class cstsmapmerge(ctools.cscript):
347 347  
348 348 # Open FITS file
349 349 fits = gammalib.GFits(fitsfile)
350   -
  350 +
351 351 # Skip if file does not contain status map
352 352 if not fits.contains('STATUS MAP'):
353 353 fits.close()
... ... @@ -357,19 +357,19 @@ class cstsmapmerge(ctools.cscript):
357 357  
358 358 # Close FITS file
359 359 fits.close()
360   -
  360 +
361 361 # Logging
362 362 pix_info = ' (%d TS pixels computed)' % \
363 363 self._get_number_of_ts_pixels(fitsfile)
364 364 self._log_value(gammalib.TERSE, 'Merge TS map file',
365 365 fitsfile + pix_info)
366   -
  366 +
367 367 # Merge TS map
368 368 self._merge_ts_map(fitsfile)
369   -
  369 +
370 370 # Append FITS file to merged files
371 371 self._merged_files.append(fitsfile)
372   -
  372 +
373 373 # Return
374 374 return
375 375  
... ... @@ -380,17 +380,17 @@ class cstsmapmerge(ctools.cscript):
380 380  
381 381 # Get output filename in case it was not read ahead
382 382 outmap = self['outmap'].filename()
383   -
  383 +
384 384 # Create FITS file
385 385 fits = gammalib.GFits()
386   -
  386 +
387 387 # Write TS map into primary
388 388 self._tsmap.write(fits)
389 389  
390 390 # Loop over maps and write them to fits
391 391 for i in range(len(self._maps)):
392 392 self._maps[i].write(fits)
393   -
  393 +
394 394 # Set map names as extensions
395 395 for i in range(len(self._mapnames)):
396 396 fits[i+1].extname(self._mapnames[i])
... ... @@ -398,7 +398,10 @@ class cstsmapmerge(ctools.cscript):
398 398 # Treat status map separately
399 399 self._statusmap.write(fits)
400 400 fits[fits.size()-1].extname('STATUS MAP')
401   -
  401 +
  402 + # Stamp FITS file
  403 + self._stamp(fits)
  404 +
402 405 # Check if map is fully done
403 406 bins_merged = 0
404 407 for pix in self._statusmap:
... ... @@ -407,50 +410,50 @@ class cstsmapmerge(ctools.cscript):
407 410  
408 411 # Set boolean if map is fully done
409 412 done = (bins_merged == self._tsmap.npix())
410   -
  413 +
411 414 # Log summary header
412 415 self._log_header2(gammalib.TERSE, 'Merging Summary')
413   -
  416 +
414 417 # Write computing status if we are not done yet
415 418 if not done:
416   -
  419 +
417 420 # Log bins that were computed and those that were missing
418 421 self._log_value(gammalib.TERSE, 'TS map bins', self._tsmap.npix())
419 422 self._log_value(gammalib.TERSE, 'Bins computed and merged', bins_merged )
420 423 self._log_value(gammalib.TERSE, 'Bins missing', self._tsmap.npix() - bins_merged)
421   -
  424 +
422 425 else:
423   -
  426 +
424 427 # Write success message
425 428 self._log_string(gammalib.TERSE, 'TS map was fully computed and successfully merged')
426   -
  429 +
427 430 # Write header
428 431 self._log_header1(gammalib.TERSE, 'Save TS map')
429   -
  432 +
430 433 # Log filename
431 434 self._log_value(gammalib.TERSE, 'TS map file', outmap.url())
432   -
  435 +
433 436 # Save FITS file
434   - fits.saveto(outmap, self._clobber())
  437 + fits.saveto(outmap, self._clobber())
435 438  
436 439 # Delete TS input maps if requested and map is fully done
437 440 if self._delete and done:
438   -
  441 +
439 442 # Log header
440 443 self._log_header2(gammalib.TERSE, 'Delete slices TS map files')
441   -
  444 +
442 445 # Loop over sliced files
443 446 for filename in self._merged_files:
444   -
  447 +
445 448 # Remove file
446 449 os.remove(filename)
447   -
  450 +
448 451 # Log message about file
449 452 self._log_value(gammalib.TERSE,'Deleted input file', filename)
450   -
  453 +
451 454 # Return
452 455 return
453   -
  456 +
454 457  
455 458 # ======================== #
456 459 # Main routine entry point #
... ... @@ -459,6 +462,6 @@ if __name__ == '__main__':
459 462  
460 463 # Create instance of application
461 464 app = cstsmapmerge(sys.argv)
462   -
  465 +
463 466 # Execute application
464 467 app.execute()
... ...
cscripts/csviscube.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Compute a visibility cube
4 4 #
5   -# Copyright (C) 2016-2019 Juergen Knoedlseder
  5 +# Copyright (C) 2016-2021 Juergen Knoedlseder
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -671,6 +671,9 @@ class csviscube(ctools.cscript):
671 671 # Save the results in VISIBILITY table extension
672 672 self._save_results(outfile, self['clobber'].boolean())
673 673  
  674 + # Stamp visibility cube
  675 + self._stamp(outfile)
  676 +
674 677 # Return
675 678 return
676 679  
... ...
doc/source/admin/release_history/2.0.rst
... ... @@ -24,6 +24,8 @@ Bug fixes
24 24 Improvements
25 25 ------------
26 26  
  27 +* [`3662 <https://cta-redmine.irap.omp.eu/issues/3662>`_] -
  28 + Stamp all output FITS files
27 29 * [`3668 <https://cta-redmine.irap.omp.eu/issues/3668>`_] -
28 30 Add source counts constraints to :ref:`cssens`
29 31 * [`3630 <https://cta-redmine.irap.omp.eu/issues/3630>`_] -
... ...
src/ctbin/ctbin.cpp
1 1 /***************************************************************************
2 2 * ctbin - Event binning tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2020 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2021 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -509,6 +509,9 @@ void ctbin::save(void)
509 509 // Save cube
510 510 obs->save(outobs, clobber());
511 511  
  512 + // Stamp counts cube
  513 + stamp(outobs);
  514 +
512 515 } // endif: observation was valid
513 516  
514 517 } // endif: outobs file was valid
... ... @@ -534,6 +537,9 @@ void ctbin::save(void)
534 537 // Save counts cube
535 538 obs->save(filename, clobber());
536 539  
  540 + // Stamp counts cube
  541 + stamp(filename);
  542 +
537 543 } // endif: observation was valid
538 544  
539 545 } // endfor: looped over all observations
... ...
src/ctbkgcube/ctbkgcube.cpp
1 1 /***************************************************************************
2 2 * ctbkgcube - Background cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2018 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2021 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -365,11 +365,13 @@ void ctbkgcube::save(void)
365 365 if ((*this)["outcube"].is_valid() && !m_background.cube().is_empty()) {
366 366  
367 367 // Get background cube file name
368   - m_outcube = (*this)["outcube"].filename();
  368 + m_outcube = (*this)["outcube"].filename();
369 369  
370 370 // Save background cube
371 371 m_background.save(m_outcube, clobber());
372 372  
  373 + // Stamp background cube
  374 + stamp(m_outcube);
373 375 }
374 376  
375 377 // Save model definition file if requested
... ...
src/ctcubemask/ctcubemask.cpp
1 1 /***************************************************************************
2 2 * ctcubemask - Cube filter tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2018 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2021 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -690,7 +690,10 @@ void ctcubemask::save_fits(void)
690 690  
691 691 // Save counts cube
692 692 obs->save(m_outcube, clobber());
693   -
  693 +
  694 + // Stamp counts cube
  695 + stamp(m_outcube);
  696 +
694 697 } // endif: observation was a CTA observation
695 698  
696 699 }
... ... @@ -737,6 +740,9 @@ void ctcubemask::save_xml(void)
737 740 // Save counts cube
738 741 obs->save(outfile, clobber());
739 742  
  743 + // Stamp counts cube
  744 + stamp(outfile);
  745 +
740 746 } // endif: observation was a CTA observations
741 747  
742 748 } // endfor: looped over observations
... ...
src/ctedispcube/ctedispcube.cpp
1 1 /***************************************************************************
2 2 * ctedispcube - Energy dispersion cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2016-2018 by Maria Haupt *
  4 + * copyright (C) 2016-2021 by Maria Haupt *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -270,6 +270,9 @@ void ctedispcube::save(void)
270 270 // Save energy dispersion cube
271 271 m_edispcube.save(m_outcube, clobber());
272 272  
  273 + // Stamp energy dispersion cube
  274 + stamp(m_outcube);
  275 +
273 276 }
274 277  
275 278 // Write into logger what has been done
... ...
src/ctexpcube/ctexpcube.cpp
1 1 /***************************************************************************
2 2 * ctexpcube - Exposure cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2018 by Juergen Knoedlseder *
  4 + * copyright (C) 2014-2021 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -266,6 +266,9 @@ void ctexpcube::save(void)
266 266 // Save exposure cube
267 267 m_expcube.save(m_outcube, clobber());
268 268  
  269 + // Stamp exposure cube
  270 + stamp(m_outcube);
  271 +
269 272 }
270 273  
271 274 // Write into logger what has been done
... ...
src/ctfindvar/ctfindvar.cpp
1 1 /***************************************************************************
2 2 * ctfindvar - Time variability search tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2018-2020 by Simon Bonnefoy *
  4 + * copyright (C) 2018-2021 by Simon Bonnefoy *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -273,6 +273,7 @@ void ctfindvar::save(void)
273 273 // counts cube was saved.
274 274 if (!m_counts.is_empty()) {
275 275 m_counts.save(outcube, (*this)["clobber"].boolean());
  276 + stamp(outcube);
276 277 log_value(TERSE, "Counts cube file", outcube.url());
277 278 }
278 279 else {
... ... @@ -298,6 +299,9 @@ void ctfindvar::save(void)
298 299 // Write source histograms
299 300 write_source_histograms(fits);
300 301  
  302 + // Stamp FITS file
  303 + stamp(fits);
  304 +
301 305 // Save significance map
302 306 fits.saveto(outmap, (*this)["clobber"].boolean());
303 307  
... ...
src/ctmapcube/ctmapcube.cpp
1 1 /***************************************************************************
2 2 * ctmapcube - Map cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2016-2018 by Juergen Knoedlseder *
  4 + * copyright (C) 2016-2021 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -231,6 +231,8 @@ void ctmapcube::save(void)
231 231 // Save map cube
232 232 m_cube.save(m_outcube, clobber());
233 233  
  234 + // Stamp map cube
  235 + stamp(m_outcube);
234 236 }
235 237  
236 238 // Write into logger what has been done
... ...
src/ctmodel/ctmodel.cpp
1 1 /***************************************************************************
2 2 * ctmodel - Model cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2019 by Juergen Knoedlseder *
  4 + * copyright (C) 2012-2021 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -326,6 +326,10 @@ void ctmodel::save(void)
326 326  
327 327 // Save cube
328 328 m_cube.save(m_outcube, clobber());
  329 +
  330 + // Stamp model cube
  331 + stamp(m_outcube);
  332 +
329 333 }
330 334  
331 335 // Write into logger what has been done
... ...
src/ctobssim/ctobssim.cpp
1 1 /***************************************************************************
2 2 * ctobssim - Observation simulator tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2020 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2021 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -1712,6 +1712,9 @@ void ctobssim::save_fits(void)
1712 1712 // Save observation into FITS file
1713 1713 obs->save(m_outevents, clobber());
1714 1714  
  1715 + // Stamp FITS file
  1716 + stamp(m_outevents);
  1717 +
1715 1718 } // endif: event list has not yet been saved and disposed
1716 1719  
1717 1720 // Return
... ... @@ -1764,6 +1767,9 @@ void ctobssim::save_xml(void)
1764 1767 // Save observation into FITS file
1765 1768 obs->save(outfile, clobber());
1766 1769  
  1770 + // Stamp FITS file
  1771 + stamp(outfile);
  1772 +
1767 1773 }
1768 1774  
1769 1775 } // endif: observation was a CTA observations
... ...
src/ctpsfcube/ctpsfcube.cpp
1 1 /***************************************************************************
2 2 * ctpsfcube - PSF cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2018 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2021 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -257,6 +257,9 @@ void ctpsfcube::save(void)
257 257 // Save PSF cube
258 258 m_psfcube.save(m_outcube, clobber());
259 259  
  260 + // Stamp PSF cube
  261 + stamp(m_outcube);
  262 +
260 263 }
261 264  
262 265 // Write into logger what has been done
... ...
src/ctskymap/ctskymap.cpp
1 1 /***************************************************************************
2 2 * ctskymap - Sky mapping tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2019 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2021 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -322,6 +322,10 @@ void ctskymap::construct_fits(void)
322 322  
323 323 } // endif: background subtraction was requested
324 324  
  325 + // Stamp FITS file
  326 + stamp(m_fits);
  327 +
  328 + // Return
325 329 return;
326 330 }
327 331  
... ...
src/cttsmap/cttsmap.cpp
... ... @@ -419,6 +419,9 @@ void cttsmap::save(void)
419 419 m_statusmap.write(fits);
420 420 fits[fits.size()-1]->extname("STATUS MAP");
421 421  
  422 + // Stamp FITS file
  423 + stamp(fits);
  424 +
422 425 // Save FITS file
423 426 fits.saveto(m_outmap, clobber());
424 427  
... ...
src/support/ctool.cpp
1 1 /***************************************************************************
2 2 * ctool - ctool base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2020 by Juergen Knoedlseder *
  4 + * copyright (C) 2014-2021 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -2266,6 +2266,9 @@ void ctool::save_event_list(const GCTAObservation* obs,
2266 2266 // Close input file
2267 2267 infits.close();
2268 2268  
  2269 + // Stamp FITS file
  2270 + stamp(outfits);
  2271 +
2269 2272 // Save file to disk and close it (we need both operations)
2270 2273 outfits.saveto(outname.url(), clobber());
2271 2274 outfits.close();
... ...