Commit 8ff7acc8eedc6a39e8ec0b2d2ea9c036c7c7c39e

Authored by Jürgen Knödlseder
1 parent 617da5ee

Integrate code

ChangeLog
1   -2015-06-19 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
  1 +2015-07-03 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
2 2  
3 3 * Version 0.10.0 released
4 4 =========================
5 5  
  6 + Add csinfo script (#1489)
6 7 Add cterror tool
7 8 Check existence of ROI in ctbin (#1476)
8 9 Allocate optimizer in ctlike upon construction (#1471)
... ...
... ... @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 0.10.0
2 2  
3 3 Author(s) : Juergen Knoedlseder
4 4  
5   -19 June 2015
  5 +3 July 2015
6 6  
7 7  
8 8 1. Introduction
... ... @@ -109,7 +109,8 @@ None
109 109  
110 110 20. Scripts
111 111 -----------
112   -None
  112 +Added csinfo script to provide some information about the GammaLib and ctools
  113 +installation. To be run in case of problems to help diagnostics.
113 114  
114 115  
115 116 21. caldb
... ...
scripts/Makefile.am
... ... @@ -5,14 +5,15 @@ binscripts = cta_kb_bkgrates.py cta_root2irf.py cta_make_nodes.py \
5 5 tsmerge.py
6 6  
7 7 # Scripts to be distributed in pythondir
8   -pythonscripts = cspull.py cssens.py cstsdist.py cscaldb.py csresmap.py cshessobs.py \
9   - csobsdef.py csspec.py cslightcrv.py \
  8 +pythonscripts = cspull.py cssens.py cstsdist.py cscaldb.py csresmap.py \
  9 + cshessobs.py csobsdef.py csspec.py cslightcrv.py \
  10 + csinfo.py \
10 11 lsmodel.py
11 12  
12 13 # Scripts for which symbolic links will be created in bindir
13 14 linkscripts = cspull cssens cstsdist cscaldb csresmap \
14   - csobsdef csspec cshessobs cslightcrv \
15   - lsmodel csinfo
  15 + cshessobs csobsdef csspec cslightcrv \
  16 + csinfo lsmodel
16 17  
17 18 # Distribute scripts
18 19 EXTRA_DIST = $(binscripts) $(pythonscripts)
... ...
scripts/csinfo.py
... ... @@ -20,7 +20,7 @@
20 20 # ==========================================================================
21 21 import sys
22 22 import os
23   -import subprocess
  23 +import commands
24 24  
25 25 # Copied and edited a bit from the `doc/source/reference_manual/index.rst` file
26 26 # The list there and here needs to be manually updated and kept in sync.
... ... @@ -39,8 +39,10 @@ CTOOL_LIST = &quot;&quot;&quot;
39 39 cttsmap Generates Test Statistics map
40 40 ctulimit Calculates upper limit
41 41 cterror Calculates likelihood profile errors
42   -
  42 +"""
  43 +CSCRIPT_LIST = """
43 44 cscaldb Lists available instrument response functions
  45 + csinfo Checks ctools and GammaLib installations
44 46 csobsdef Generates observation definition file
45 47 cslightcrv Computes lightcurve
46 48 cspull Generates pull distribution
... ... @@ -59,17 +61,23 @@ def log(text, end=&#39;\n&#39;):
59 61 sys.stdout.write(text + end)
60 62  
61 63  
62   -def print_ctools_list():
  64 +def csinfo_list_tools():
63 65 """Print available ctools with one-line description to the console.
64 66 """
65 67 print('\nAvailable ctools:')
66 68 print(CTOOL_LIST)
  69 + print('Available cscripts:')
  70 + print(CSCRIPT_LIST)
67 71  
68 72  
69 73 def csinfo_setup_check():
70   - print('\nGammalib / ctools setup info:\n')
  74 + print('\nGammalib / ctools setup check:\n')
71 75  
72   - all_ok = True
  76 + all_ok = True
  77 + gammalib_environ = False
  78 + ctools_environ = False
  79 + gammalib_python = False
  80 + ctools_python = False
73 81  
74 82 log(' GAMMALIB environment variable ... ', end='')
75 83 try:
... ... @@ -77,7 +85,8 @@ def csinfo_setup_check():
77 85 print('ok')
78 86 except KeyError:
79 87 print('NOT OK')
80   - all_ok = False
  88 + all_ok = False
  89 + gammalib_environ = True
81 90  
82 91 log(' CTOOLS environment variable ... ', end='')
83 92 try:
... ... @@ -85,7 +94,8 @@ def csinfo_setup_check():
85 94 print('ok')
86 95 except KeyError:
87 96 print('NOT_OK')
88   - all_ok = False
  97 + all_ok = False
  98 + ctools_environ = True
89 99  
90 100 log(' gammalib Python import .......... ', end='')
91 101 try:
... ... @@ -93,7 +103,8 @@ def csinfo_setup_check():
93 103 print('ok')
94 104 except:
95 105 print('NOT OK')
96   - all_ok = False
  106 + all_ok = False
  107 + gammalib_python = True
97 108  
98 109 log(' ctools Python import .......... ', end='')
99 110 try:
... ... @@ -101,19 +112,26 @@ def csinfo_setup_check():
101 112 print('ok')
102 113 except:
103 114 print('NOT OK')
104   - all_ok = False
  115 + all_ok = False
  116 + ctools_python = True
105 117  
106 118 if all_ok:
107   - print('\n Your Gammalib / ctools setup is OK.\n')
  119 + print('\n Your Gammalib / ctools setup is OK.')
108 120 else:
109 121 print('\n WARNING: Your Gammalib / ctools setup is NOT OK!\n')
110   - print(' - Did you source gammalib-init.sh ?')
111   - print(' - Did you source gammalib-ctools.sh ?')
112   - print(' - Are you using the correct Python ?')
  122 + if gammalib_environ:
  123 + print(' - Have you set the GAMMALIB environment variable?')
  124 + print(' - Did you source gammalib-init.sh?')
  125 + if ctools_environ:
  126 + print(' - Have you set the CTOOLS environment variable?')
  127 + print(' - Did you source ctools-init.sh ?')
  128 + if gammalib_python or ctools_python:
  129 + print(' - Are you using the correct Python ?')
113 130  
114   - print()
  131 + print('')
115 132  
116 133 def csinfo_setup_info():
  134 + print('\nGammalib / ctools setup info:\n')
117 135  
118 136 log(' CTOOLS environment variable ... ', end='')
119 137 try:
... ... @@ -138,12 +156,12 @@ def csinfo_setup_info():
138 156 print(' GAMMALIB CFLAGS: {0}'.format(get_pkg_config_info('cflags', 'gammalib')))
139 157 print(' CTOOLS CFLAGS: {0}'.format(get_pkg_config_info('cflags', 'ctools')))
140 158  
141   - print()
  159 + print('')
142 160  
143 161  
144 162 def get_pkg_config_info(info, library):
145 163 cmd = 'pkg-config --{0} {1}'.format(info, library)
146   - out = subprocess.getoutput(cmd)
  164 + out = commands.getoutput(cmd)
147 165 if 'was not found' in out:
148 166 return 'Not available'
149 167 else:
... ... @@ -153,10 +171,10 @@ def get_pkg_config_info(info, library):
153 171 def csinfo_print_help():
154 172 print('\nPrint info about Gammalib and ctools to the console.\n')
155 173 print('Available commands:')
156   - print(' csinfo tools List available ctools')
157   - print(' csinfo setup-check Check Gammalib / ctools setup')
158   - print(' csinfo setup-info Print Gammalib / ctools setup info')
159   - print()
  174 + print(' csinfo list List available ctools and cscripts')
  175 + print(' csinfo check Check Gammalib / ctools setup')
  176 + print(' csinfo info Print Gammalib / ctools setup info')
  177 + print('')
160 178  
161 179  
162 180 def csinfo(argv):
... ... @@ -167,11 +185,11 @@ def csinfo(argv):
167 185 sys.exit(0)
168 186  
169 187 cmd = argv[1]
170   - if cmd == 'list-tools':
  188 + if cmd == 'list':
171 189 csinfo_list_tools()
172   - elif cmd == 'setup-check':
  190 + elif cmd == 'check':
173 191 csinfo_setup_check()
174   - elif cmd == 'setup-info':
  192 + elif cmd == 'info':
175 193 csinfo_setup_info()
176 194 else:
177 195 print('\nERROR: invalid command: `{0}`'.format(cmd))
... ...