Commit 7f5bbf013f64a5bad61aaf31c31b60446c1e6ed3

Authored by Jürgen Knödlseder
1 parent e371cfca

Enhance output of csroot2caldb script

ChangeLog
  1 +2017-03-07
  2 +
  3 + * Version 1.2.1 released
  4 + ========================
  5 +
  6 + Enhance logfile output of csroot2caldb script
  7 +
  8 +
1 9 2017-02-09
2 10  
3 11 * Version 1.2.0 released
... ...
README.md
1 1 ctools information
2 2 ==================
3   -* Version: 1.2.0 (12 August 2016)
  3 +* Version: 1.2.1 (12 August 2016)
4 4 * Author: Juergen Knoedlseder (jurgen.knodlseder@irap.omp.eu)
5   -* GammaLib dependency: 1.2.0
  5 +* GammaLib dependency: 1.2.1
6 6  
7 7 [![Build Status](https://cta-jenkins.irap.omp.eu/buildStatus/icon?job=ctools-integrate-os)](https://cta-jenkins.irap.omp.eu/job/ctools-integrate-os/)
8 8  
... ...
configure.ac
1 1 #############################################################################
2 2 # Configuration for ctools - tools for science analysis of CTA data #
3 3 # ------------------------------------------------------------------------- #
4   -# Copyright (C) 2011-2016 Juergen Knoedlseder #
  4 +# Copyright (C) 2011-2017 Juergen Knoedlseder #
5 5 # ------------------------------------------------------------------------- #
6 6 # #
7 7 # This program is free software: you can redistribute it and/or modify #
... ... @@ -28,7 +28,7 @@
28 28 #############################################################################
29 29 # Initialisation #
30 30 #############################################################################
31   -AC_INIT([ctools], [1.2.0], [jurgen.knodlseder@irap.omp.eu], [ctools])
  31 +AC_INIT([ctools], [1.2.1], [jurgen.knodlseder@irap.omp.eu], [ctools])
32 32 AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp])
33 33 AC_CONFIG_MACRO_DIR([m4])
34 34 #AM_INIT_AUTOMAKE([gnu no-dependencies foreign])
... ...
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 Juergen Knoedlseder
  5 +# Copyright (C) 2016-2017 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
... ... @@ -50,7 +50,7 @@ class csroot2caldb(ctools.cscript):
50 50 """
51 51 # Set name
52 52 self._name = 'csroot2caldb'
53   - self._version = '1.2.0'
  53 + self._version = '1.2.1'
54 54  
55 55 # Initialise application by calling the appropriate class constructor
56 56 self._init_cscript(argv)
... ... @@ -548,9 +548,7 @@ class csroot2caldb(ctools.cscript):
548 548 Directory structure dictionary
549 549 """
550 550 # Write header
551   - if self._logTerse():
552   - self._log('\n')
553   - self._log.header1('Generate effective area extension')
  551 + self._log_header1(gammalib.TERSE, 'Generate effective area extension')
554 552  
555 553 # Get relevant ROOT histograms
556 554 etrue = tfile.Get('EffectiveAreaEtrue_offaxis')
... ... @@ -609,11 +607,6 @@ class csroot2caldb(ctools.cscript):
609 607 ds : dict
610 608 Directory structure dictionary
611 609 """
612   - # Write header
613   - if self._logTerse():
614   - self._log('\n')
615   - self._log.header1('Generate point spread function extension')
616   -
617 610 # King profile PSF
618 611 if self['psftype'].string() == 'King':
619 612 self._root2psf_king(tfile, irf, ds)
... ... @@ -646,6 +639,10 @@ class csroot2caldb(ctools.cscript):
646 639 ds : dict
647 640 Directory structure dictionary
648 641 """
  642 + # Write header
  643 + self._log_header1(gammalib.TERSE,
  644 + 'Generate Gaussian point spread function extension')
  645 +
649 646 # Get relevant ROOT histograms
650 647 r68 = tfile.Get('AngRes_offaxis')
651 648  
... ... @@ -678,9 +675,6 @@ class csroot2caldb(ctools.cscript):
678 675 zero.SetBinContent(ieng+1,ioff+1,0.0)
679 676  
680 677 # Set boundaries
681   - #bounds = self._make_2D(r68, ds['HDU_PSF'], None, 'deg')
682   - #for b in bounds:
683   - # irf['PSF_BOUNDS'].append(b)
684 678 irf['PSF_BOUNDS'].append('PSF(GAUSS)')
685 679  
686 680 # Write boundary keywords
... ... @@ -725,6 +719,10 @@ class csroot2caldb(ctools.cscript):
725 719 ds : dict
726 720 Directory structure dictionary
727 721 """
  722 + # Write header
  723 + self._log_header1(gammalib.TERSE,
  724 + 'Generate King point spread function extension')
  725 +
728 726 # Get relevant ROOT histograms
729 727 r68 = tfile.Get('AngRes_offaxis')
730 728 r80 = tfile.Get('AngRes80_offaxis')
... ... @@ -802,9 +800,18 @@ class csroot2caldb(ctools.cscript):
802 800 # This takes care of pixels that are ill defined
803 801 # in the MC file.
804 802 if gamma == 0.0 and sigma == 0.0:
805   - gamma = last_gamma
806   - sigma = last_sigma
807   -
  803 + gamma = last_gamma
  804 + sigma = last_sigma
  805 + status = ' (use last)'
  806 + else:
  807 + status = ''
  808 +
  809 + # Log results
  810 + self._log_value(gammalib.EXPLICIT,
  811 + 'ieng=%d ioff=%d%s' % (ieng,ioff,status),
  812 + 'r68=%f r80=%f gamma=%f sigma=%f' %
  813 + (r_68, r_80, gamma, sigma))
  814 +
808 815 # Store surrent result as last result
809 816 last_gamma = gamma
810 817 last_sigma = sigma
... ... @@ -814,9 +821,6 @@ class csroot2caldb(ctools.cscript):
814 821 sigma2D.SetBinContent(ieng+1,ioff+1,sigma)
815 822  
816 823 # Set boundaries
817   - #bounds = self._make_2D(r68, ds['HDU_PSF'], None, 'deg')
818   - #for b in bounds:
819   - # irf['PSF_BOUNDS'].append(b)
820 824 irf['PSF_BOUNDS'].append('PSF(KING)')
821 825  
822 826 # Write boundary keywords
... ... @@ -849,18 +853,11 @@ class csroot2caldb(ctools.cscript):
849 853 Directory structure dictionary
850 854 """
851 855 # Write header
852   - if self._logTerse():
853   - self._log('\n')
854   - self._log.header1('Generate energy dispersion extension')
  856 + self._log_header1(gammalib.TERSE, 'Generate energy dispersion extension')
855 857  
856 858 # Get relevant ROOT histograms
857 859 matrix = tfile.Get('EestOverEtrue_offaxis')
858 860  
859   - # Set boundaries
860   - #bounds = self._make_3D_migra(matrix, ds['HDU_EDISP'], None, '')
861   - #for b in bounds:
862   - # irf['EDISP_BOUNDS'].append(b)
863   -
864 861 # Write boundary keywords
865 862 self._set_cif_keywords(ds['HDU_EDISP'], irf['EDISP_NAME'],
866 863 irf['EDISP_BOUNDS'], irf['EDISP_DESC'], irf)
... ... @@ -888,9 +885,7 @@ class csroot2caldb(ctools.cscript):
888 885 Directory structure dictionary
889 886 """
890 887 # Write header
891   - if self._logTerse():
892   - self._log('\n')
893   - self._log.header1('Generate 3D background extension')
  888 + self._log_header1(gammalib.TERSE, 'Generate 3D background extension')
894 889  
895 890 # Get relevant ROOT histograms
896 891 array = tfile.Get('BGRatePerSqDeg_offaxis')
... ... @@ -909,11 +904,6 @@ class csroot2caldb(ctools.cscript):
909 904 array_1D = tfile.Get('BGRatePerSqDeg')
910 905 self._renorm_onaxis(array, array_1D)
911 906  
912   - # Set boundaries
913   - #bounds = self._make_3D(array, ds['HDU_BGD'], None, 'deg')
914   - #for b in bounds:
915   - # irf['BGD_BOUNDS'].append(b)
916   -
917 907 # Write boundary keywords
918 908 self._set_cif_keywords(ds['HDU_BGD'], irf['BGD_NAME'],
919 909 irf['BGD_BOUNDS'], irf['BGD_DESC'], irf)
... ... @@ -944,6 +934,9 @@ class csroot2caldb(ctools.cscript):
944 934 # Continue only if columns does not yet exist
945 935 if not hdu.contains(name):
946 936  
  937 + # Write header
  938 + self._log_header3(gammalib.TERSE, 'Append axis column "%s"' % name)
  939 +
947 940 # Get number of axis bins
948 941 nbins = axis.GetNbins()
949 942  
... ... @@ -967,6 +960,10 @@ class csroot2caldb(ctools.cscript):
967 960 value = pow(10.0, value)
968 961 hdu[name][0,i] = value
969 962  
  963 + # Log values
  964 + self._log_value(gammalib.NORMAL, 'Number of axis bins', nbins)
  965 + self._log_value(gammalib.NORMAL, 'Unit', unit)
  966 +
970 967 # Return
971 968 return
972 969  
... ... @@ -988,6 +985,9 @@ class csroot2caldb(ctools.cscript):
988 985 # Continue only if columns does not yet exist
989 986 if not hdu.contains(name):
990 987  
  988 + # Write header
  989 + self._log_header3(gammalib.TERSE, 'Append value column "%s"' % name)
  990 +
991 991 # Get number of values
992 992 nbins = len(values)
993 993  
... ... @@ -999,6 +999,10 @@ class csroot2caldb(ctools.cscript):
999 999 for i in range(nbins):
1000 1000 hdu[name][0,i] = values[i]
1001 1001  
  1002 + # Log values
  1003 + self._log_value(gammalib.NORMAL, 'Number of values', nbins)
  1004 + self._log_value(gammalib.NORMAL, 'Unit', unit)
  1005 +
1002 1006 # Return
1003 1007 return
1004 1008  
... ... @@ -1023,19 +1027,18 @@ class csroot2caldb(ctools.cscript):
1023 1027 # Continue only if the 1D and 2D histograms have the same number
1024 1028 # of energy bins
1025 1029 if neng != hist1D.GetXaxis().GetNbins():
1026   - # Write header
1027   - if self._logTerse():
1028   - self._log(gammalib.parformat('On-axis normalisation'))
1029   - self._log('Impossible since energy binning of 1D histogram '
1030   - '"%s" does not match that of 2D histogram "%s".\n' %
1031   - (hist1D.GetName(), hist2D.GetName()))
  1030 +
  1031 + # Log if energy binning differs
  1032 + self._log_value(gammalib.TERSE, 'On-axis normalisation',
  1033 + 'Impossible since energy binning of 1D histogram '
  1034 + '"%s" does not match that of 2D histogram "%s".' %
  1035 + (hist1D.GetName(), hist2D.GetName()))
1032 1036 else:
1033   - # Write header
1034   - if self._logTerse():
1035   - self._log(gammalib.parformat('On-axis normalisation'))
1036   - self._log('On-axis values of 1D histogram "%s" imposed on '
1037   - '2D histogram "%s".\n' %
1038   - (hist1D.GetName(), hist2D.GetName()))
  1037 + # Log on-axis normalisation
  1038 + self._log_value(gammalib.TERSE, 'On-axis normalisation',
  1039 + 'On-axis values of 1D histogram "%s" imposed on '
  1040 + '2D histogram "%s".' %
  1041 + (hist1D.GetName(), hist2D.GetName()))
1039 1042  
1040 1043 # Get a copy of 2D histogram
1041 1044 hist2D_copy = hist2D.Clone()
... ... @@ -1142,11 +1145,13 @@ class csroot2caldb(ctools.cscript):
1142 1145 if energy > ethres:
1143 1146 value = self._plaw_value(coeff, energy)
1144 1147 hist2D.SetBinContent(ieng+1,ioff+1,value)
1145   - if self._logTerse():
1146   - self._log(gammalib.parformat('Power law replacement'))
1147   - self._log('%e cts/s/deg2 (E=%8.4f TeV (%d) '
1148   - 'Off=%.2f deg (%d)\n' %
1149   - (value,engs[ieng],ieng,offset,ioff))
  1148 +
  1149 + # Log power law replacement
  1150 + self._log_value(gammalib.NORMAL,
  1151 + 'Power law replacement',
  1152 + '%e cts/s/deg2 (E=%8.4f TeV (%d) '
  1153 + 'Off=%.2f deg (%d)' %
  1154 + (value,engs[ieng],ieng,offset,ioff))
1150 1155  
1151 1156 # Return
1152 1157 return
... ... @@ -1292,11 +1297,14 @@ class csroot2caldb(ctools.cscript):
1292 1297 for ieng in range(i_start, i_stop+1):
1293 1298 if hist2D.GetBinContent(ieng+1,ioff+1) == 0.0:
1294 1299 hist2D.SetBinContent(ieng+1,ioff+1,value)
1295   - if self._logTerse():
1296   - self._log(gammalib.parformat('Background infill'))
1297   - self._log('%e cts/s/deg2 (E=%8.4f TeV (%d) '
1298   - 'Off=%.2f deg (%d)\n' %
1299   - (value,engs[ieng],ieng,offset,ioff))
  1300 +
  1301 + # Log background infill
  1302 + self._log_value(gammalib.NORMAL,
  1303 + 'Background infill',
  1304 + '%e cts/s/deg2 (E=%8.4f TeV (%d) '
  1305 + 'Off=%.2f deg (%d)' %
  1306 + (value,engs[ieng],ieng,offset,ioff))
  1307 +
1300 1308 else:
1301 1309 value = hist2D.GetBinContent(ieng+1,ioff+1)
1302 1310  
... ... @@ -1324,12 +1332,19 @@ class csroot2caldb(ctools.cscript):
1324 1332 scale : float, optional
1325 1333 Scaling factor for histogram values
1326 1334 """
  1335 + # Write header
  1336 + self._log_header3(gammalib.TERSE, 'Make 2D data column "%s"' % name)
  1337 +
1327 1338 # Extract energy and offset angle vectors
1328 1339 energies = array.GetXaxis()
1329 1340 offsets = array.GetYaxis()
1330 1341 neng = energies.GetNbins()
1331 1342 noffset = offsets.GetNbins()
1332 1343  
  1344 + # Log parameters
  1345 + self._log_value(gammalib.NORMAL, 'Number of energies', neng)
  1346 + self._log_value(gammalib.NORMAL, 'Number of offsets', noffset)
  1347 +
1333 1348 # Append axis columns to HDU
1334 1349 self._append_column_axis(hdu, 'ENERG_LO', 'TeV', energies, log=True)
1335 1350 self._append_column_axis(hdu, 'ENERG_HI', 'TeV', energies, log=True)
... ... @@ -1379,6 +1394,9 @@ class csroot2caldb(ctools.cscript):
1379 1394 unit : str
1380 1395 Data unit
1381 1396 """
  1397 + # Write header
  1398 + self._log_header3(gammalib.TERSE, 'Make 3D data column "%s"' % name)
  1399 +
1382 1400 # Get User parameters
1383 1401 scale = self['bgdscale'].real()
1384 1402 oversample = self['bgdoversample'].integer()
... ... @@ -1397,6 +1415,13 @@ class csroot2caldb(ctools.cscript):
1397 1415 ewidth.append(pow(10.0, energies.GetBinUpEdge(ieng+1) +6.0) -
1398 1416 pow(10.0, energies.GetBinLowEdge(ieng+1)+6.0))
1399 1417  
  1418 + # Log parameters
  1419 + self._log_value(gammalib.NORMAL, 'Scale', scale)
  1420 + self._log_value(gammalib.NORMAL, 'Oversample', oversample)
  1421 + self._log_value(gammalib.NORMAL, 'Number of energies', neng)
  1422 + self._log_value(gammalib.NORMAL, 'Number of offsets', noffset)
  1423 + self._log_value(gammalib.NORMAL, 'Maximum offset', theta_max)
  1424 +
1400 1425 # Build DETX and DETY axes
1401 1426 ndet = array.GetYaxis().GetNbins()
1402 1427 ndets = 2*ndet*oversample
... ... @@ -1413,6 +1438,11 @@ class csroot2caldb(ctools.cscript):
1413 1438 dets_hi.append(det_hi)
1414 1439 dets2.append(det_val*det_val)
1415 1440  
  1441 + # Log parameters
  1442 + self._log_value(gammalib.NORMAL, 'Number of DETXY bins', ndets)
  1443 + self._log_value(gammalib.NORMAL, 'Maximum DETXY', det_max)
  1444 + self._log_value(gammalib.NORMAL, 'DETXY binsize', det_bin)
  1445 +
1416 1446 # Append DETX_LO, DETX_HI, DETY_LO and DETY_HI columns
1417 1447 self._append_column_values(hdu, 'DETX_LO', 'deg', dets_lo)
1418 1448 self._append_column_values(hdu, 'DETX_HI', 'deg', dets_hi)
... ... @@ -1471,6 +1501,10 @@ class csroot2caldb(ctools.cscript):
1471 1501 scale : float, optional
1472 1502 Scaling factor for histogram values
1473 1503 """
  1504 + # Write header
  1505 + self._log_header3(gammalib.TERSE,
  1506 + 'Make 3D migration matrix data column "%s"' % name)
  1507 +
1474 1508 # Extract Etrue, Eobs/Etrue and offset angle vectors
1475 1509 etrue = array.GetXaxis()
1476 1510 netrue = etrue.GetNbins()
... ... @@ -1483,6 +1517,11 @@ class csroot2caldb(ctools.cscript):
1483 1517 ewidth.append(pow(10.0, etrue.GetBinUpEdge(ieng+1) +6.0) - \
1484 1518 pow(10.0, etrue.GetBinLowEdge(ieng+1)+6.0))
1485 1519  
  1520 + # Log parameters
  1521 + self._log_value(gammalib.NORMAL, 'Number of energies', netrue)
  1522 + self._log_value(gammalib.NORMAL, 'Number of migrations', nmigra)
  1523 + self._log_value(gammalib.NORMAL, 'Number of offsets', noffset)
  1524 +
1486 1525 # Append axis columns to HDU
1487 1526 self._append_column_axis(hdu, 'ETRUE_LO', 'TeV', etrue, log=True)
1488 1527 self._append_column_axis(hdu, 'ETRUE_HI', 'TeV', etrue, log=True)
... ...
ctools.pc.in
... ... @@ -6,9 +6,9 @@ includedir=${prefix}/include
6 6 Name: ctools
7 7 Description: CTA science analysis tools
8 8 URL: http://cta.irap.omp.eu/ctools
9   -Version: 1.2.0
  9 +Version: 1.2.1
10 10 Requires:
11   -Requires.private: gammalib >= 1.2.0
  11 +Requires.private: gammalib >= 1.2.1
12 12 Conflicts:
13 13 Cflags: -I${includedir}/ctools @OPENMP_CXXFLAGS@
14 14 Libs: -L${libdir} -lctools
... ...
doc/Doxyfile
... ... @@ -32,7 +32,7 @@ PROJECT_NAME = ctools
32 32 # This could be handy for archiving the generated documentation or
33 33 # if some version control system is used.
34 34  
35   -PROJECT_NUMBER = 1.2.0
  35 +PROJECT_NUMBER = 1.2.1
36 36  
37 37 # Using the PROJECT_BRIEF tag one can provide an optional one line description
38 38 # for a project that appears at the top of each page and should give viewer
... ...
doc/source/conf.py
... ... @@ -69,7 +69,7 @@ copyright = u'2014-2016, ctools developers'
69 69 version = '1.2'
70 70  
71 71 # The full version, including alpha/beta/rc tags.
72   -release = '1.2.0'
  72 +release = '1.2.1'
73 73  
74 74 # The language for content autogenerated by Sphinx. Refer to documentation
75 75 # for a list of supported languages.
... ...
sonar-project.properties
1 1 # Required metadata
2 2 sonar.projectKey=ctools
3 3 sonar.projectName=ctools
4   -sonar.projectVersion=1.2.0
  4 +sonar.projectVersion=1.2.1
5 5  
6 6 # Description
7 7 sonar.projectDescription="Cherenkov Telescope Array Science Analysis Software"
... ...