diff --git a/ChangeLog b/ChangeLog index 88f949c..e55d862 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2016-09-26 +2016-10-04 * Version 1.2.0 released ======================== + Add zenith and azimuth angle information to IRF caldb (#1853) Fix ctbin segfault bug for varying energy thresholds (#1850) Make csresmap enumbins parameter hidden (#1844) Rename ctskymap::map() to ctskymap::skymap() (#1828) diff --git a/NEWS b/NEWS index 9d252e2..badab38 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in ctools 1.2.0 -26 September 2016 +4 October 2016 Introduction @@ -188,9 +188,12 @@ The class now derives from ctlikelihood (#1828). cscripts -------- -Added the support modules "modutils" and "ioutils" to the cscripts module -and removed the obsolete functions fit(), cterror(), cntmap() and modmap() -from the "obsutils" module (#1830). +Added the support modules "modutils" and "ioutils" to the cscripts module and +removed the obsolete functions fit(), cterror(), cntmap() and modmap() from the +"obsutils" module (#1830). + +The csroot2caldb script now takes the zenith and azimuth angles as parameters +and writes them into the calibration database. Examples diff --git a/cscripts/csroot2caldb.par b/cscripts/csroot2caldb.par index 6a168fb..06696fd 100644 --- a/cscripts/csroot2caldb.par +++ b/cscripts/csroot2caldb.par @@ -23,6 +23,8 @@ inst, s, a, prod3,,, "Instrument name" id, s, a, South_50h,,, "Instrument Response Function identifier" version, s, a, prod3,,, "Instrument Response Function version" analysis, s, a, DESY,,, "Instrument Response Function analysis" +zenith, r, a, 20.0,0.0,90.0, "Zenith Angle (deg)" +azimuth, r, a, 0.0,0.0,360.0, "Azimuth Angle (deg)" psftype, s, h, Gauss,Gauss|King,, "Point spread function type" split, b, h, no,,, "Split IRF components into different files" norm1d, b, h, no,,, "Normalize on 1D histograms" diff --git a/cscripts/csroot2caldb.py b/cscripts/csroot2caldb.py index f864390..a2b15ba 100755 --- a/cscripts/csroot2caldb.py +++ b/cscripts/csroot2caldb.py @@ -21,6 +21,7 @@ import os import sys import math +import copy from datetime import datetime import gammalib import ctools @@ -69,6 +70,8 @@ class csroot2caldb(ctools.cscript): self['inst'].string() self['id'].string() self['analysis'].string() + self['zenith'].real() + self['azimuth'].real() self['version'].string() self['psftype'].string() self['split'].boolean() @@ -102,6 +105,10 @@ class csroot2caldb(ctools.cscript): cal_version = 'VERSION('+self['version'].string()+')' cal_cut = 'CLASS(BEST)' cal_analysis = 'ANALYSIS('+self['analysis'].string()+')' + cal_zenith = 'ZENITH(%.3f)deg' % self['zenith'].real() + cal_azimuth = 'AZIMUTH(%.3f)deg' % self['azimuth'].real() + cal_bounds = [cal_name, cal_version, cal_cut, cal_analysis, \ + cal_zenith, cal_azimuth] # Set IRF information irf['CAL_TEL'] = 'CTA' @@ -118,19 +125,19 @@ class csroot2caldb(ctools.cscript): irf['REF_TIME'] = 51544.0 irf['EA_NAME'] = 'EFF_AREA' irf['EA_DOC'] = 'CAL/GEN/92-019' - irf['EA_BOUNDS'] = [cal_name, cal_version, cal_cut, cal_analysis] + irf['EA_BOUNDS'] = copy.deepcopy(cal_bounds) irf['EA_DESC'] = 'CTA effective area' irf['PSF_NAME'] = 'RPSF' irf['PSF_DOC'] = 'CAL/GEN/92-020' - irf['PSF_BOUNDS'] = [cal_name, cal_version, cal_cut, cal_analysis] + irf['PSF_BOUNDS'] = copy.deepcopy(cal_bounds) irf['PSF_DESC'] = 'CTA point spread function' irf['EDISP_NAME'] = 'EDISP' irf['EDISP_DOC'] = '???' - irf['EDISP_BOUNDS'] = [cal_name, cal_version, cal_cut, cal_analysis] + irf['EDISP_BOUNDS'] = copy.deepcopy(cal_bounds) irf['EDISP_DESC'] = 'CTA energy dispersion' irf['BGD_NAME'] = 'BGD' irf['BGD_DOC'] = '???' - irf['BGD_BOUNDS'] = [cal_name, cal_version, cal_cut, cal_analysis] + irf['BGD_BOUNDS'] = copy.deepcopy(cal_bounds) irf['BGD_DESC'] = 'CTA background' # Return metadata @@ -590,9 +597,9 @@ class csroot2caldb(ctools.cscript): ereco.SetBinContent(ieng+1,ioff+1,value) # Set boundaries (use Ereco boundaries) - bounds = self._make_2D(ereco, ds['HDU_EA'], None, 'm2') - for b in bounds: - irf['EA_BOUNDS'].append(b) + #bounds = self._make_2D(ereco, ds['HDU_EA'], None, 'm2') + #for b in bounds: + # irf['EA_BOUNDS'].append(b) # Write boundary keywords self._set_cif_keywords(ds['HDU_EA'], irf['EA_NAME'], @@ -689,9 +696,9 @@ class csroot2caldb(ctools.cscript): zero.SetBinContent(ieng+1,ioff+1,0.0) # Set boundaries - bounds = self._make_2D(r68, ds['HDU_PSF'], None, 'deg') - for b in bounds: - irf['PSF_BOUNDS'].append(b) + #bounds = self._make_2D(r68, ds['HDU_PSF'], None, 'deg') + #for b in bounds: + # irf['PSF_BOUNDS'].append(b) irf['PSF_BOUNDS'].append('PSF(GAUSS)') # Write boundary keywords @@ -825,9 +832,9 @@ class csroot2caldb(ctools.cscript): sigma2D.SetBinContent(ieng+1,ioff+1,sigma) # Set boundaries - bounds = self._make_2D(r68, ds['HDU_PSF'], None, 'deg') - for b in bounds: - irf['PSF_BOUNDS'].append(b) + #bounds = self._make_2D(r68, ds['HDU_PSF'], None, 'deg') + #for b in bounds: + # irf['PSF_BOUNDS'].append(b) irf['PSF_BOUNDS'].append('PSF(KING)') # Write boundary keywords @@ -868,9 +875,9 @@ class csroot2caldb(ctools.cscript): matrix = tfile.Get('EestOverEtrue_offaxis') # Set boundaries - bounds = self._make_3D_migra(matrix, ds['HDU_EDISP'], None, '') - for b in bounds: - irf['EDISP_BOUNDS'].append(b) + #bounds = self._make_3D_migra(matrix, ds['HDU_EDISP'], None, '') + #for b in bounds: + # irf['EDISP_BOUNDS'].append(b) # Write boundary keywords self._set_cif_keywords(ds['HDU_EDISP'], irf['EDISP_NAME'], @@ -921,9 +928,9 @@ class csroot2caldb(ctools.cscript): self._renorm_onaxis(array, array_1D) # Set boundaries - bounds = self._make_3D(array, ds['HDU_BGD'], None, 'deg') - for b in bounds: - irf['BGD_BOUNDS'].append(b) + #bounds = self._make_3D(array, ds['HDU_BGD'], None, 'deg') + #for b in bounds: + # irf['BGD_BOUNDS'].append(b) # Write boundary keywords self._set_cif_keywords(ds['HDU_BGD'], irf['BGD_NAME'], @@ -1013,7 +1020,6 @@ class csroot2caldb(ctools.cscript): # Return return - def _renorm_onaxis(self, hist2D, hist1D): """ Renormalise 2D histogram (energy,offset) on 1D histogram (energy)