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