Commit 040da64481194d7ac601d9f8feb0afbdfe272720

Authored by Jürgen Knödlseder
1 parent df193cc3

Change CTA 3D background "BGD" keywords to "BKG" (#2343)

ChangeLog
1 -2018-07-27 1 +2018-07-31
2 2
3 * Version 1.6.0 released 3 * Version 1.6.0 released
4 ======================== 4 ========================
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 Keep existing library path in installation script on Mac OS X (#2420) 16 Keep existing library path in installation script on Mac OS X (#2420)
17 csphagen produces Xspec compliant data (#2404) 17 csphagen produces Xspec compliant data (#2404)
18 Add show_rmf.py example script 18 Add show_rmf.py example script
  19 + Change CTA 3D background "BGD" keywords to "BKG" (#2343)
19 Add ras() and decs() methods to csobsinfo (#2313) 20 Add ras() and decs() methods to csobsinfo (#2313)
20 Also compute TS in csspec for On/Off analysis using wstat statistic (#2312) 21 Also compute TS in csspec for On/Off analysis using wstat statistic (#2312)
21 Allow specifying of input sky map in ctskymap (#2311) 22 Allow specifying of input sky map in ctskymap (#2311)
1 New Features and Important Changes in ctools 1.6.0 1 New Features and Important Changes in ctools 1.6.0
2 2
3 -27 July 2018 3 +31 July 2018
4 4
5 5
6 Introduction 6 Introduction
@@ -226,7 +226,7 @@ None @@ -226,7 +226,7 @@ None
226 226
227 csobs2caldb - Generate calibration database entry for an IACT observation 227 csobs2caldb - Generate calibration database entry for an IACT observation
228 ------------------------------------------------------------------------- 228 -------------------------------------------------------------------------
229 -None 229 +Change background template table name from "BGD" to "BKG" (#2343).
230 230
231 231
232 csobsdef - Generate observation definition XML file 232 csobsdef - Generate observation definition XML file
@@ -288,6 +288,8 @@ parameter due to a bug in the code. This bug was fixed (#2448). @@ -288,6 +288,8 @@ parameter due to a bug in the code. This bug was fixed (#2448).
288 288
289 csroot2caldb - Generates calibration database from ROOT file 289 csroot2caldb - Generates calibration database from ROOT file
290 ------------------------------------------------------------ 290 ------------------------------------------------------------
  291 +Change background template table name from "BGD" to "BKG" (#2343).
  292 +
291 The ROOT Python module is now imported in the run method and not globally so 293 The ROOT Python module is now imported in the run method and not globally so
292 that no conflit arises with the "--help" option (#2652). 294 that no conflit arises with the "--help" option (#2652).
293 295
caldb/data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz
No preview for this file type
caldb/data/cta/prod2/bcf/North_50h/irf_file.fits.gz
No preview for this file type
caldb/data/cta/prod2/bcf/North_5h/irf_file.fits.gz
No preview for this file type
caldb/data/cta/prod2/bcf/South_0.5h/irf_file.fits.gz
No preview for this file type
caldb/data/cta/prod2/bcf/South_50h/irf_file.fits.gz
No preview for this file type
caldb/data/cta/prod2/bcf/South_5h/irf_file.fits.gz
No preview for this file type
caldb/data/cta/prod2/caldb.indx
No preview for this file type
cscripts/csobs2caldb.py
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 # ========================================================================== 2 # ==========================================================================
3 # Creates a calibration database entry for an IACT observation 3 # Creates a calibration database entry for an IACT observation
4 # 4 #
5 -# Copyright (C) 2015-2017 Michael Mayer 5 +# Copyright (C) 2015-2018 Michael Mayer
6 # 6 #
7 # This program is free software: you can redistribute it and/or modify 7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by 8 # it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@ from cscripts import calutils @@ -32,7 +32,7 @@ from cscripts import calutils
32 class csobs2caldb(ctools.csobservation): 32 class csobs2caldb(ctools.csobservation):
33 """ 33 """
34 Creates a calibration database entry for an IACT observation. 34 Creates a calibration database entry for an IACT observation.
35 - 35 +
36 The creation of a calibration database entry is useful for performing 36 The creation of a calibration database entry is useful for performing
37 simulations for current Imaging Air Cherenkov Telescopes (IACTs). 37 simulations for current Imaging Air Cherenkov Telescopes (IACTs).
38 The class takes an observation definition XML file as input and uses 38 The class takes an observation definition XML file as input and uses
@@ -40,7 +40,7 @@ class csobs2caldb(ctools.csobservation): @@ -40,7 +40,7 @@ class csobs2caldb(ctools.csobservation):
40 the first observation will be used, but the user can specify the 40 the first observation will be used, but the user can specify the
41 index of any observation using the hidden "index" parameter. 41 index of any observation using the hidden "index" parameter.
42 """ 42 """
43 - 43 +
44 # Constructor 44 # Constructor
45 def __init__(self, *argv): 45 def __init__(self, *argv):
46 """ 46 """
@@ -81,7 +81,7 @@ class csobs2caldb(ctools.csobservation): @@ -81,7 +81,7 @@ class csobs2caldb(ctools.csobservation):
81 if self.obs().is_empty(): 81 if self.obs().is_empty():
82 raise ValueError('No or empty observation provided for ' 82 raise ValueError('No or empty observation provided for '
83 'parameter "inobs".') 83 'parameter "inobs".')
84 - 84 +
85 # Get index of observation to be used 85 # Get index of observation to be used
86 index = self['index'].integer() 86 index = self['index'].integer()
87 87
@@ -89,7 +89,7 @@ class csobs2caldb(ctools.csobservation): @@ -89,7 +89,7 @@ class csobs2caldb(ctools.csobservation):
89 if index < 0 or index >= self.obs().size(): 89 if index < 0 or index >= self.obs().size():
90 raise IndexError('Parameter "index=%d" outside the validity ' 90 raise IndexError('Parameter "index=%d" outside the validity '
91 'range [0,%d].' % (index, self.obs().size())) 91 'range [0,%d].' % (index, self.obs().size()))
92 - 92 +
93 # Get observation 93 # Get observation
94 self._observation = self.obs()[index] 94 self._observation = self.obs()[index]
95 95
@@ -97,13 +97,13 @@ class csobs2caldb(ctools.csobservation): @@ -97,13 +97,13 @@ class csobs2caldb(ctools.csobservation):
97 if not self._observation.classname() == 'GCTAObservation': 97 if not self._observation.classname() == 'GCTAObservation':
98 raise RuntimeError('Input observation not of type ' 98 raise RuntimeError('Input observation not of type '
99 '"GCTAObservation".') 99 '"GCTAObservation".')
100 - 100 +
101 # Make sure we have an IRF response associated with the CTA 101 # Make sure we have an IRF response associated with the CTA
102 # observation 102 # observation
103 if not self._observation.response().classname() == 'GCTAResponseIrf': 103 if not self._observation.response().classname() == 'GCTAResponseIrf':
104 raise RuntimeError('Response of input observation not of ' 104 raise RuntimeError('Response of input observation not of '
105 'type "GCTAResponseIrf".') 105 'type "GCTAResponseIrf".')
106 - 106 +
107 # Get calibration database name. If the "caldb" parameter is "NONE" 107 # Get calibration database name. If the "caldb" parameter is "NONE"
108 # or empty then use the instrument name from the observation as 108 # or empty then use the instrument name from the observation as
109 # calibration database name. 109 # calibration database name.
@@ -132,13 +132,11 @@ class csobs2caldb(ctools.csobservation): @@ -132,13 +132,11 @@ class csobs2caldb(ctools.csobservation):
132 Creates an IRF FITS file 132 Creates an IRF FITS file
133 """ 133 """
134 # Write header into logger 134 # Write header into logger
135 - if self._logTerse():  
136 - self._log("\n")  
137 - self._log.header2("Creating IRF file") 135 + self._log_header2(gammalib.TERSE, 'Creating IRF file')
138 136
139 # Get response for the observation 137 # Get response for the observation
140 rsp = self._observation.response() 138 rsp = self._observation.response()
141 - 139 +
142 # Extract response file names 140 # Extract response file names
143 fname_aeff = rsp.aeff().filename() 141 fname_aeff = rsp.aeff().filename()
144 fname_psf = rsp.psf().filename() 142 fname_psf = rsp.psf().filename()
@@ -151,7 +149,7 @@ class csobs2caldb(ctools.csobservation): @@ -151,7 +149,7 @@ class csobs2caldb(ctools.csobservation):
151 self._log_value(gammalib.NORMAL, 'Point spread function', fname_psf.url()) 149 self._log_value(gammalib.NORMAL, 'Point spread function', fname_psf.url())
152 self._log_value(gammalib.NORMAL, 'Energy dispersion', fname_edisp.url()) 150 self._log_value(gammalib.NORMAL, 'Energy dispersion', fname_edisp.url())
153 self._log_value(gammalib.NORMAL, 'Background rate', fname_bkg.url()) 151 self._log_value(gammalib.NORMAL, 'Background rate', fname_bkg.url())
154 - 152 +
155 # Open FITS files of response components 153 # Open FITS files of response components
156 fits_aeff = gammalib.GFits(fname_aeff) 154 fits_aeff = gammalib.GFits(fname_aeff)
157 fits_psf = gammalib.GFits(fname_psf) 155 fits_psf = gammalib.GFits(fname_psf)
@@ -163,10 +161,10 @@ class csobs2caldb(ctools.csobservation): @@ -163,10 +161,10 @@ class csobs2caldb(ctools.csobservation):
163 ext_psf = fname_psf.extname("POINT SPREAD FUNCTION") 161 ext_psf = fname_psf.extname("POINT SPREAD FUNCTION")
164 ext_edisp = fname_edisp.extname("ENERGY DISPERSION") 162 ext_edisp = fname_edisp.extname("ENERGY DISPERSION")
165 ext_bkg = fname_bkg.extname("BACKGROUND") 163 ext_bkg = fname_bkg.extname("BACKGROUND")
166 - 164 +
167 # Create empty FITS file 165 # Create empty FITS file
168 fits = gammalib.GFits() 166 fits = gammalib.GFits()
169 - 167 +
170 # Append IRF component to FITS file 168 # Append IRF component to FITS file
171 fits.append(fits_aeff[ext_aeff]) 169 fits.append(fits_aeff[ext_aeff])
172 fits.append(fits_psf[ext_psf]) 170 fits.append(fits_psf[ext_psf])
@@ -186,7 +184,7 @@ class csobs2caldb(ctools.csobservation): @@ -186,7 +184,7 @@ class csobs2caldb(ctools.csobservation):
186 self._log("\n") 184 self._log("\n")
187 self._log(str(fits[ext_bkg].header())) 185 self._log(str(fits[ext_bkg].header()))
188 self._log("\n") 186 self._log("\n")
189 - 187 +
190 # Return fits file 188 # Return fits file
191 return fits 189 return fits
192 190
@@ -195,16 +193,14 @@ class csobs2caldb(ctools.csobservation): @@ -195,16 +193,14 @@ class csobs2caldb(ctools.csobservation):
195 Creates an IRF index FITS file 193 Creates an IRF index FITS file
196 """ 194 """
197 # Write header into logger 195 # Write header into logger
198 - if self._logTerse():  
199 - self._log('\n')  
200 - self._log.header2('Creating database index file') 196 + self._log_header2(gammalib.TERSE, 'Creating database index file')
201 197
202 # Open calibration database index 198 # Open calibration database index
203 indx_file = self._base_dir + '/caldb.indx' 199 indx_file = self._base_dir + '/caldb.indx'
204 - 200 +
205 # Open index file (or create one if it does not exist) 201 # Open index file (or create one if it does not exist)
206 cif = gammalib.GFits(indx_file, True) 202 cif = gammalib.GFits(indx_file, True)
207 - 203 +
208 # Retrieve "CIF" table 204 # Retrieve "CIF" table
209 if cif.contains('CIF'): 205 if cif.contains('CIF'):
210 table = cif.table('CIF') 206 table = cif.table('CIF')
@@ -212,7 +208,7 @@ class csobs2caldb(ctools.csobservation): @@ -212,7 +208,7 @@ class csobs2caldb(ctools.csobservation):
212 # ... or create binary table if no "CIF" table exists yet, append 208 # ... or create binary table if no "CIF" table exists yet, append
213 # binary table to CIF file and return a reference to the appended 209 # binary table to CIF file and return a reference to the appended
214 # table to work with 210 # table to work with
215 - else: 211 + else:
216 table = cif.append(calutils.create_cif_table()) 212 table = cif.append(calutils.create_cif_table())
217 213
218 # Check if output config already exist 214 # Check if output config already exist
@@ -223,9 +219,9 @@ class csobs2caldb(ctools.csobservation): @@ -223,9 +219,9 @@ class csobs2caldb(ctools.csobservation):
223 if caldir == self._cal_dir: 219 if caldir == self._cal_dir:
224 has_config = True 220 has_config = True
225 break 221 break
226 -  
227 - # Create columns if not available  
228 - if not has_config: 222 +
  223 + # Create columns if not available
  224 + if not has_config:
229 # Append 4 rows to CIF extension 225 # Append 4 rows to CIF extension
230 table.append_rows(4) 226 table.append_rows(4)
231 row_index = table.nrows() 227 row_index = table.nrows()
@@ -241,7 +237,7 @@ class csobs2caldb(ctools.csobservation): @@ -241,7 +237,7 @@ class csobs2caldb(ctools.csobservation):
241 # Set date 237 # Set date
242 now = str(datetime.datetime.now()) 238 now = str(datetime.datetime.now())
243 today, time = now.split() 239 today, time = now.split()
244 - 240 +
245 # Set element 241 # Set element
246 table['TELESCOP'][row] = self._mission 242 table['TELESCOP'][row] = self._mission
247 table['INSTRUME'][row] = self._caldb 243 table['INSTRUME'][row] = self._caldb
@@ -268,7 +264,7 @@ class csobs2caldb(ctools.csobservation): @@ -268,7 +264,7 @@ class csobs2caldb(ctools.csobservation):
268 row = row_index-3 264 row = row_index-3
269 table['CAL_CNAM'][row] = 'RPSF' 265 table['CAL_CNAM'][row] = 'RPSF'
270 table['CAL_DESC'][row] = self._caldb+' point spread function' 266 table['CAL_DESC'][row] = self._caldb+' point spread function'
271 - 267 +
272 # Add energy dispersion information 268 # Add energy dispersion information
273 row = row_index-2 269 row = row_index-2
274 table['CAL_CNAM'][row] = 'EDISP' 270 table['CAL_CNAM'][row] = 'EDISP'
@@ -276,7 +272,7 @@ class csobs2caldb(ctools.csobservation): @@ -276,7 +272,7 @@ class csobs2caldb(ctools.csobservation):
276 272
277 # Add background information 273 # Add background information
278 row = row_index-1 274 row = row_index-1
279 - table['CAL_CNAM'][row] = 'BGD' 275 + table['CAL_CNAM'][row] = 'BKG'
280 table['CAL_DESC'][row] = self._caldb+' background' 276 table['CAL_DESC'][row] = self._caldb+' background'
281 277
282 # Log resulting FITS table and header 278 # Log resulting FITS table and header
@@ -286,35 +282,33 @@ class csobs2caldb(ctools.csobservation): @@ -286,35 +282,33 @@ class csobs2caldb(ctools.csobservation):
286 if self._logExplicit(): 282 if self._logExplicit():
287 self._log(str(table.header())) 283 self._log(str(table.header()))
288 self._log('\n') 284 self._log('\n')
289 - 285 +
290 # Return CIF FITS file 286 # Return CIF FITS file
291 return cif 287 return cif
292 - 288 +
293 def _make_dirs(self): 289 def _make_dirs(self):
294 """ 290 """
295 Make CALDB directories 291 Make CALDB directories
296 """ 292 """
297 # Write header into logger 293 # Write header into logger
298 - if self._logTerse():  
299 - self._log("\n")  
300 - self._log.header2("Creating directory structure") 294 + self._log_header2(gammalib.TERSE, 'Creating directory structure')
301 295
302 # Create calibration database 296 # Create calibration database
303 - caldb = gammalib.GCaldb(self["rootdir"].string())  
304 - 297 + caldb = gammalib.GCaldb(self['rootdir'].string())
  298 +
305 # Set calibration directory 299 # Set calibration directory
306 - self._cal_dir = "data"  
307 - self._cal_dir += "/"+self._mission.lower()  
308 - self._cal_dir += "/"+self._caldb.lower()  
309 - self._cal_dir += "/bcf/"+self["irf"].string()  
310 - 300 + self._cal_dir = 'data'
  301 + self._cal_dir += '/'+self._mission.lower()
  302 + self._cal_dir += '/'+self._caldb.lower()
  303 + self._cal_dir += '/bcf/'+self['irf'].string()
  304 +
311 # Set absolute path 305 # Set absolute path
312 - self._base_dir = caldb.rootdir() +"/data"  
313 - self._base_dir += "/"+self._mission.lower()  
314 - self._base_dir += "/"+self._caldb.lower()  
315 - 306 + self._base_dir = caldb.rootdir() +'/data'
  307 + self._base_dir += '/'+self._mission.lower()
  308 + self._base_dir += '/'+self._caldb.lower()
  309 +
316 # Set directory for irf file 310 # Set directory for irf file
317 - self._rsp_dir = caldb.rootdir() + "/" + self._cal_dir 311 + self._rsp_dir = caldb.rootdir() + '/' + self._cal_dir
318 312
319 # Log resulting FITS table 313 # Log resulting FITS table
320 self._log_value(gammalib.NORMAL, 'Calibration directory', self._cal_dir) 314 self._log_value(gammalib.NORMAL, 'Calibration directory', self._cal_dir)
@@ -324,7 +318,7 @@ class csobs2caldb(ctools.csobservation): @@ -324,7 +318,7 @@ class csobs2caldb(ctools.csobservation):
324 else: 318 else:
325 name = 'IRF directory (existing)' 319 name = 'IRF directory (existing)'
326 self._log_value(gammalib.NORMAL, name, self._rsp_dir) 320 self._log_value(gammalib.NORMAL, name, self._rsp_dir)
327 - 321 +
328 # Create IRF directory is it does not yet exist 322 # Create IRF directory is it does not yet exist
329 if not os.path.isdir(self._rsp_dir): 323 if not os.path.isdir(self._rsp_dir):
330 os.makedirs(self._rsp_dir) 324 os.makedirs(self._rsp_dir)
@@ -344,21 +338,19 @@ class csobs2caldb(ctools.csobservation): @@ -344,21 +338,19 @@ class csobs2caldb(ctools.csobservation):
344 338
345 # Get parameters 339 # Get parameters
346 self._get_parameters() 340 self._get_parameters()
347 - 341 +
348 # Write input parameters and header into logger 342 # Write input parameters and header into logger
349 - if self._logTerse():  
350 - self._log('\n')  
351 - self._log.header1('Creating CALDB entry')  
352 - 343 + self._log_header1(gammalib.TERSE, 'Creating CALDB entry')
  344 +
353 # Create directory structure 345 # Create directory structure
354 self._make_dirs() 346 self._make_dirs()
355 - 347 +
356 # Create/update calibration database 348 # Create/update calibration database
357 self._caldb_inx = self._make_caldb_index() 349 self._caldb_inx = self._make_caldb_index()
358 - 350 +
359 # Create response file 351 # Create response file
360 self._irf_fits = self._make_irf_file() 352 self._irf_fits = self._make_irf_file()
361 - 353 +
362 # Return 354 # Return
363 return 355 return
364 356
@@ -371,7 +363,7 @@ class csobs2caldb(ctools.csobservation): @@ -371,7 +363,7 @@ class csobs2caldb(ctools.csobservation):
371 363
372 # Set response filename 364 # Set response filename
373 filename = self._rsp_dir + '/' + self._outfile 365 filename = self._rsp_dir + '/' + self._outfile
374 - 366 +
375 # Write filenames into logger 367 # Write filenames into logger
376 self._log_value(gammalib.NORMAL, 'CALDB index file', 368 self._log_value(gammalib.NORMAL, 'CALDB index file',
377 self._caldb_inx.filename().url()) 369 self._caldb_inx.filename().url())
@@ -382,7 +374,7 @@ class csobs2caldb(ctools.csobservation): @@ -382,7 +374,7 @@ class csobs2caldb(ctools.csobservation):
382 374
383 # Save response file 375 # Save response file
384 self._irf_fits.saveto(filename, self._clobber()) 376 self._irf_fits.saveto(filename, self._clobber())
385 - 377 +
386 # Return 378 # Return
387 return 379 return
388 380
@@ -394,6 +386,6 @@ if __name__ == &#39;__main__&#39;: @@ -394,6 +386,6 @@ if __name__ == &#39;__main__&#39;:
394 386
395 # Create instance of application 387 # Create instance of application
396 app = csobs2caldb(sys.argv) 388 app = csobs2caldb(sys.argv)
397 - 389 +
398 # Execute application 390 # Execute application
399 app.execute() 391 app.execute()
cscripts/csroot2caldb.py
@@ -130,12 +130,12 @@ class csroot2caldb(ctools.cscript): @@ -130,12 +130,12 @@ class csroot2caldb(ctools.cscript):
130 irf['EDISP_DOC'] = '???' 130 irf['EDISP_DOC'] = '???'
131 irf['EDISP_BOUNDS'] = copy.deepcopy(cal_bounds) 131 irf['EDISP_BOUNDS'] = copy.deepcopy(cal_bounds)
132 irf['EDISP_DESC'] = 'CTA energy dispersion' 132 irf['EDISP_DESC'] = 'CTA energy dispersion'
133 - irf['BGD_NAME'] = 'BKG'  
134 - irf['BGD_HDUCLAS3'] = 'FULL-ENCLOSURE'  
135 - irf['BGD_HDUCLAS4'] = '3D'  
136 - irf['BGD_DOC'] = '???'  
137 - irf['BGD_BOUNDS'] = copy.deepcopy(cal_bounds)  
138 - irf['BGD_DESC'] = 'CTA background' 133 + irf['BKG_NAME'] = 'BKG'
  134 + irf['BKG_HDUCLAS3'] = 'FULL-ENCLOSURE'
  135 + irf['BKG_HDUCLAS4'] = '3D'
  136 + irf['BKG_DOC'] = '???'
  137 + irf['BKG_BOUNDS'] = copy.deepcopy(cal_bounds)
  138 + irf['BKG_DESC'] = 'CTA background'
139 139
140 # Set parameter dependent IRF information 140 # Set parameter dependent IRF information
141 if self['psftype'].string() == 'King': 141 if self['psftype'].string() == 'King':
@@ -183,7 +183,7 @@ class csroot2caldb(ctools.cscript): @@ -183,7 +183,7 @@ class csroot2caldb(ctools.cscript):
183 ds['EA_DIR'] = obs_dir 183 ds['EA_DIR'] = obs_dir
184 ds['PSF_DIR'] = obs_dir 184 ds['PSF_DIR'] = obs_dir
185 ds['EDISP_DIR'] = obs_dir 185 ds['EDISP_DIR'] = obs_dir
186 - ds['BGD_DIR'] = obs_dir 186 + ds['BKG_DIR'] = obs_dir
187 187
188 # Set path to response components. If the "outdir" parameter is set 188 # Set path to response components. If the "outdir" parameter is set
189 # then prefix the value to the path of the response components 189 # then prefix the value to the path of the response components
@@ -193,13 +193,13 @@ class csroot2caldb(ctools.cscript): @@ -193,13 +193,13 @@ class csroot2caldb(ctools.cscript):
193 ds['EA_PATH'] = outdir+'/'+ds['EA_DIR'] 193 ds['EA_PATH'] = outdir+'/'+ds['EA_DIR']
194 ds['PSF_PATH'] = outdir+'/'+ds['PSF_DIR'] 194 ds['PSF_PATH'] = outdir+'/'+ds['PSF_DIR']
195 ds['EDISP_PATH'] = outdir+'/'+ds['EDISP_DIR'] 195 ds['EDISP_PATH'] = outdir+'/'+ds['EDISP_DIR']
196 - ds['BGD_PATH'] = outdir+'/'+ds['BGD_DIR'] 196 + ds['BKG_PATH'] = outdir+'/'+ds['BKG_DIR']
197 else: 197 else:
198 ds['BASE_PATH'] = base_dir 198 ds['BASE_PATH'] = base_dir
199 ds['EA_PATH'] = ds['EA_DIR'] 199 ds['EA_PATH'] = ds['EA_DIR']
200 ds['PSF_PATH'] = ds['PSF_DIR'] 200 ds['PSF_PATH'] = ds['PSF_DIR']
201 ds['EDISP_PATH'] = ds['EDISP_DIR'] 201 ds['EDISP_PATH'] = ds['EDISP_DIR']
202 - ds['BGD_PATH'] = ds['BGD_DIR'] 202 + ds['BKG_PATH'] = ds['BKG_DIR']
203 203
204 # Set IRF component file names. If the "split" parameter is "yes" then 204 # Set IRF component file names. If the "split" parameter is "yes" then
205 # split the IRF components over several files. 205 # split the IRF components over several files.
@@ -207,12 +207,12 @@ class csroot2caldb(ctools.cscript): @@ -207,12 +207,12 @@ class csroot2caldb(ctools.cscript):
207 ds['EA_FILE'] = 'ea_'+version+'.fits' 207 ds['EA_FILE'] = 'ea_'+version+'.fits'
208 ds['PSF_FILE'] = 'psf_'+version+'.fits' 208 ds['PSF_FILE'] = 'psf_'+version+'.fits'
209 ds['EDISP_FILE'] = 'edisp_'+version+'.fits' 209 ds['EDISP_FILE'] = 'edisp_'+version+'.fits'
210 - ds['BGD_FILE'] = 'bgd_'+version+'.fits' 210 + ds['BKG_FILE'] = 'bgd_'+version+'.fits'
211 else: 211 else:
212 ds['EA_FILE'] = 'irf_'+version+'.fits' 212 ds['EA_FILE'] = 'irf_'+version+'.fits'
213 ds['PSF_FILE'] = 'irf_'+version+'.fits' 213 ds['PSF_FILE'] = 'irf_'+version+'.fits'
214 ds['EDISP_FILE'] = 'irf_'+version+'.fits' 214 ds['EDISP_FILE'] = 'irf_'+version+'.fits'
215 - ds['BGD_FILE'] = 'irf_'+version+'.fits' 215 + ds['BKG_FILE'] = 'irf_'+version+'.fits'
216 216
217 # Create directory structure 217 # Create directory structure
218 if not os.path.isdir(ds['EA_PATH']): 218 if not os.path.isdir(ds['EA_PATH']):
@@ -221,8 +221,8 @@ class csroot2caldb(ctools.cscript): @@ -221,8 +221,8 @@ class csroot2caldb(ctools.cscript):
221 os.makedirs(ds['PSF_PATH']) 221 os.makedirs(ds['PSF_PATH'])
222 if not os.path.isdir(ds['EDISP_PATH']): 222 if not os.path.isdir(ds['EDISP_PATH']):
223 os.makedirs(ds['EDISP_PATH']) 223 os.makedirs(ds['EDISP_PATH'])
224 - if not os.path.isdir(ds['BGD_PATH']):  
225 - os.makedirs(ds['BGD_PATH']) 224 + if not os.path.isdir(ds['BKG_PATH']):
  225 + os.makedirs(ds['BKG_PATH'])
226 226
227 # Return ds 227 # Return ds
228 return ds 228 return ds
@@ -255,19 +255,19 @@ class csroot2caldb(ctools.cscript): @@ -255,19 +255,19 @@ class csroot2caldb(ctools.cscript):
255 ea_filename = ds['EA_PATH']+'/'+ds['EA_FILE'] 255 ea_filename = ds['EA_PATH']+'/'+ds['EA_FILE']
256 psf_filename = ds['PSF_PATH']+'/'+ds['PSF_FILE'] 256 psf_filename = ds['PSF_PATH']+'/'+ds['PSF_FILE']
257 edisp_filename = ds['EDISP_PATH']+'/'+ds['EDISP_FILE'] 257 edisp_filename = ds['EDISP_PATH']+'/'+ds['EDISP_FILE']
258 - bgd_filename = ds['BGD_PATH']+'/'+ds['BGD_FILE'] 258 + bgd_filename = ds['BKG_PATH']+'/'+ds['BKG_FILE']
259 259
260 # Open IRF component files 260 # Open IRF component files
261 if self['split'].boolean(): 261 if self['split'].boolean():
262 ds['EA_FITS'] = gammalib.GFits(ea_filename, True) 262 ds['EA_FITS'] = gammalib.GFits(ea_filename, True)
263 ds['PSF_FITS'] = gammalib.GFits(psf_filename, True) 263 ds['PSF_FITS'] = gammalib.GFits(psf_filename, True)
264 ds['EDISP_FITS'] = gammalib.GFits(edisp_filename, True) 264 ds['EDISP_FITS'] = gammalib.GFits(edisp_filename, True)
265 - ds['BGD_FITS'] = gammalib.GFits(bgd_filename, True) 265 + ds['BKG_FITS'] = gammalib.GFits(bgd_filename, True)
266 else: 266 else:
267 ds['EA_FITS'] = gammalib.GFits(ea_filename, True) 267 ds['EA_FITS'] = gammalib.GFits(ea_filename, True)
268 ds['PSF_FITS'] = ds['EA_FITS'] 268 ds['PSF_FITS'] = ds['EA_FITS']
269 ds['EDISP_FITS'] = ds['EA_FITS'] 269 ds['EDISP_FITS'] = ds['EA_FITS']
270 - ds['BGD_FITS'] = ds['EA_FITS'] 270 + ds['BKG_FITS'] = ds['EA_FITS']
271 271
272 # Open HDUs 272 # Open HDUs
273 ds['HDU_EA'] = self._open_hdu(ds['EA_FITS'], "EFFECTIVE AREA", 273 ds['HDU_EA'] = self._open_hdu(ds['EA_FITS'], "EFFECTIVE AREA",
@@ -282,9 +282,9 @@ class csroot2caldb(ctools.cscript): @@ -282,9 +282,9 @@ class csroot2caldb(ctools.cscript):
282 irf['EDISP_NAME'], irf['EDISP_HDUCLAS3'], 282 irf['EDISP_NAME'], irf['EDISP_HDUCLAS3'],
283 irf['EDISP_HDUCLAS4'], irf['EDISP_DOC'], 283 irf['EDISP_HDUCLAS4'], irf['EDISP_DOC'],
284 irf) 284 irf)
285 - ds['HDU_BGD'] = self._open_hdu(ds['BGD_FITS'], "BACKGROUND",  
286 - irf['BGD_NAME'], irf['BGD_HDUCLAS3'],  
287 - irf['BGD_HDUCLAS4'], irf['BGD_DOC'], 285 + ds['HDU_BKG'] = self._open_hdu(ds['BKG_FITS'], "BACKGROUND",
  286 + irf['BKG_NAME'], irf['BKG_HDUCLAS3'],
  287 + irf['BKG_HDUCLAS4'], irf['BKG_DOC'],
288 irf) 288 irf)
289 289
290 # Return 290 # Return
@@ -318,10 +318,10 @@ class csroot2caldb(ctools.cscript): @@ -318,10 +318,10 @@ class csroot2caldb(ctools.cscript):
318 if self['split'].boolean(): 318 if self['split'].boolean():
319 ds['PSF_FITS'].save(True) 319 ds['PSF_FITS'].save(True)
320 ds['EDISP_FITS'].save(True) 320 ds['EDISP_FITS'].save(True)
321 - ds['BGD_FITS'].save(True) 321 + ds['BKG_FITS'].save(True)
322 ds['PSF_FITS'].close() 322 ds['PSF_FITS'].close()
323 ds['EDISP_FITS'].close() 323 ds['EDISP_FITS'].close()
324 - ds['BGD_FITS'].close() 324 + ds['BKG_FITS'].close()
325 325
326 # Return 326 # Return
327 return 327 return
@@ -421,7 +421,7 @@ class csroot2caldb(ctools.cscript): @@ -421,7 +421,7 @@ class csroot2caldb(ctools.cscript):
421 Directory structure dictionary 421 Directory structure dictionary
422 """ 422 """
423 # Set list of IRF component names 423 # Set list of IRF component names
424 - names = ['EA', 'PSF', 'EDISP', 'BGD'] 424 + names = ['EA', 'PSF', 'EDISP', 'BKG']
425 425
426 # Initialise CIF row index 426 # Initialise CIF row index
427 row = ds['HDU_CIF'].nrows() 427 row = ds['HDU_CIF'].nrows()
@@ -1049,7 +1049,7 @@ class csroot2caldb(ctools.cscript): @@ -1049,7 +1049,7 @@ class csroot2caldb(ctools.cscript):
1049 Translate ROOT to CALDB background extension. 1049 Translate ROOT to CALDB background extension.
1050 1050
1051 The following ROOT histograms are used: 1051 The following ROOT histograms are used:
1052 - - BGRatePerSqDeg_offaxis -> BGD 1052 + - BGRatePerSqDeg_offaxis -> BKG
1053 1053
1054 Parameters 1054 Parameters
1055 ---------- 1055 ----------
@@ -1081,11 +1081,11 @@ class csroot2caldb(ctools.cscript): @@ -1081,11 +1081,11 @@ class csroot2caldb(ctools.cscript):
1081 self._renorm_onaxis(array, array_1D) 1081 self._renorm_onaxis(array, array_1D)
1082 1082
1083 # Write boundary keywords 1083 # Write boundary keywords
1084 - self._set_cif_keywords(ds['HDU_BGD'], irf['BGD_NAME'],  
1085 - irf['BGD_BOUNDS'], irf['BGD_DESC'], irf) 1084 + self._set_cif_keywords(ds['HDU_BKG'], irf['BKG_NAME'],
  1085 + irf['BKG_BOUNDS'], irf['BKG_DESC'], irf)
1086 1086
1087 - # Create "BGD" data column  
1088 - self._make_3D(array, ds['HDU_BGD'], 'BGD', '1/(MeV s sr)') 1087 + # Create "BKG" data column
  1088 + self._make_3D(array, ds['HDU_BKG'], 'BKG', '1/(MeV s sr)')
1089 1089
1090 # Return 1090 # Return
1091 return 1091 return
doc/source/admin/release_history/1.6.rst
@@ -42,6 +42,8 @@ Improvements @@ -42,6 +42,8 @@ Improvements
42 * [`2404 <https://cta-redmine.irap.omp.eu/issues/2404>`_] - 42 * [`2404 <https://cta-redmine.irap.omp.eu/issues/2404>`_] -
43 :ref:`csphagen` produces Xspec compliant data 43 :ref:`csphagen` produces Xspec compliant data
44 * Add ``show_rmf.py`` example script 44 * Add ``show_rmf.py`` example script
  45 +* [`2343 <https://cta-redmine.irap.omp.eu/issues/2343>`_] -
  46 + Change CTA 3D background ``BGD`` keywords to ``BKG``
45 * [`2313 <https://cta-redmine.irap.omp.eu/issues/2313>`_] - 47 * [`2313 <https://cta-redmine.irap.omp.eu/issues/2313>`_] -
46 Add `ras()` and `decs()` methods to :ref:`csobsinfo` 48 Add `ras()` and `decs()` methods to :ref:`csobsinfo`
47 * [`2312 <https://cta-redmine.irap.omp.eu/issues/2312>`_] - 49 * [`2312 <https://cta-redmine.irap.omp.eu/issues/2312>`_] -
test/data/iactdata/events/irf_file.fits.gz
No preview for this file type
test/data/irf_file.fits.gz
No preview for this file type
test/dev/cta_kb_root2caldb.py
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 # area (i.e. the area before applying any theta cut). This is required by 7 # area (i.e. the area before applying any theta cut). This is required by
8 # GammaLib as the maximum likelihood analysis does not imply any theta cut. 8 # GammaLib as the maximum likelihood analysis does not imply any theta cut.
9 # 9 #
10 -# Copyright (C) 2014-2016 Juergen Knoedlseder 10 +# Copyright (C) 2014-2018 Juergen Knoedlseder
11 # 11 #
12 # This program is free software: you can redistribute it and/or modify 12 # This program is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by 13 # it under the terms of the GNU General Public License as published by
@@ -23,7 +23,6 @@ @@ -23,7 +23,6 @@
23 # along with this program. If not, see <http://www.gnu.org/licenses/>. 23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 # 24 #
25 # ========================================================================== 25 # ==========================================================================
26 -#from ROOT import TFile, TH1F, TH2F  
27 from ROOT import TFile, TH1F 26 from ROOT import TFile, TH1F
28 from datetime import datetime 27 from datetime import datetime
29 import gammalib 28 import gammalib
@@ -96,7 +95,7 @@ class caldb(): @@ -96,7 +95,7 @@ class caldb():
96 self.edisp_bounds = [self.cal_name, self.cal_version, self.cal_cut, self.cal_analysis] 95 self.edisp_bounds = [self.cal_name, self.cal_version, self.cal_cut, self.cal_analysis]
97 self.edisp_desc = "CTA energy dispersion" 96 self.edisp_desc = "CTA energy dispersion"
98 # 97 #
99 - self.bgd_name = "BGD" 98 + self.bgd_name = "BKG"
100 self.bgd_doc = "???" 99 self.bgd_doc = "???"
101 self.bgd_bounds = [self.cal_name, self.cal_version, self.cal_cut, self.cal_analysis] 100 self.bgd_bounds = [self.cal_name, self.cal_version, self.cal_cut, self.cal_analysis]
102 self.bgd_desc = "CTA background" 101 self.bgd_desc = "CTA background"
test/test_csobs2caldb.py
@@ -34,7 +34,7 @@ class Test(test): @@ -34,7 +34,7 @@ class Test(test):
34 This test class makes unit tests for the csobs2caldb script by using it 34 This test class makes unit tests for the csobs2caldb script by using it
35 from the command line and from Python. 35 from the command line and from Python.
36 """ 36 """
37 - 37 +
38 # Constructor 38 # Constructor
39 def __init__(self): 39 def __init__(self):
40 """ 40 """
@@ -159,13 +159,13 @@ class Test(test): @@ -159,13 +159,13 @@ class Test(test):
159 aeff = gammalib.GFilename(db.filename('','','EFF_AREA','','',expr)) 159 aeff = gammalib.GFilename(db.filename('','','EFF_AREA','','',expr))
160 psf = gammalib.GFilename(db.filename('','','RPSF','','',expr)) 160 psf = gammalib.GFilename(db.filename('','','RPSF','','',expr))
161 edisp = gammalib.GFilename(db.filename('','','EDISP','','',expr)) 161 edisp = gammalib.GFilename(db.filename('','','EDISP','','',expr))
162 - bgd = gammalib.GFilename(db.filename('','','BGD','','',expr)) 162 + bkg = gammalib.GFilename(db.filename('','','BKG','','',expr))
163 163
164 # Check whether files exist 164 # Check whether files exist
165 self.test_assert(aeff.exists(), 'Effective area file exists') 165 self.test_assert(aeff.exists(), 'Effective area file exists')
166 self.test_assert(psf.exists(), 'Point spread function file exists') 166 self.test_assert(psf.exists(), 'Point spread function file exists')
167 self.test_assert(edisp.exists(), 'Energy dispersion file exists') 167 self.test_assert(edisp.exists(), 'Energy dispersion file exists')
168 - self.test_assert(bgd.exists(), 'Background file exists')  
169 - 168 + self.test_assert(bkg.exists(), 'Background file exists')
  169 +
170 # Return 170 # Return
171 return 171 return