Merge lp:~maddm/maddm/no_numpy_scipy into lp:~maddm/maddm/3.0.1
- no_numpy_scipy
- Merge into 3.0.1
Proposed by
Olivier Mattelaer
Status: | Merged |
---|---|
Merged at revision: | 15 |
Proposed branch: | lp:~maddm/maddm/no_numpy_scipy |
Merge into: | lp:~maddm/maddm/3.0.1 |
Diff against target: |
376 lines (+125/-37) 3 files modified
__init__.py (+1/-1) maddm_interface.py (+14/-2) maddm_run_interface.py (+110/-34) |
To merge this branch: | bzr merge lp:~maddm/maddm/no_numpy_scipy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Olivier Mattelaer | Approve | ||
Federico Ambrogi | Pending | ||
Review via email: mp+345141@code.launchpad.net |
Commit message
Avoid direct crash if numpy/scipy are not present on the system.
-> forbids indirect detection but allows relic density computation and direct detection.
This allows to have maddm v2 options still working in version 3 even if numpy/scipy are not available.
Description of the change
To post a comment you must log in.
lp:~maddm/maddm/no_numpy_scipy
updated
Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote : | # |
review:
Needs Fixing
Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote : | # |
Hi,
Thanks for the review:
1) Done.
2) I add a warning and a question asking if he wants to generate the diagram anyway (with default to stop)
3) Ok a warning will be displayed but this is not possible in 2.6.2 and will need to wait 2.6.3 but the code is ready for 2.6.3 already.
Thanks,
Olivier
If nobody object, I will release this code this afternoon.
review:
Approve
lp:~maddm/maddm/no_numpy_scipy
updated
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '__init__.py' | |||
2 | --- __init__.py 2018-03-30 22:19:49 +0000 | |||
3 | +++ __init__.py 2018-05-16 14:22:05 +0000 | |||
4 | @@ -16,6 +16,6 @@ | |||
5 | 16 | new_reweight = {'indirect': MGoutput.Indirect_Reweight} | 16 | new_reweight = {'indirect': MGoutput.Indirect_Reweight} |
6 | 17 | 17 | ||
7 | 18 | ## The test/code have been validated up to this version | 18 | ## The test/code have been validated up to this version |
9 | 19 | latest_validated_version = (2,6,2) | 19 | latest_validated_version = (2,6,3) |
10 | 20 | minimal_mg5amcnlo_version = (2,6,2) | 20 | minimal_mg5amcnlo_version = (2,6,2) |
11 | 21 | maximal_mg5amcnlo_version = (1000,1000,1000) | 21 | maximal_mg5amcnlo_version = (1000,1000,1000) |
12 | 22 | 22 | ||
13 | === modified file 'maddm_interface.py' | |||
14 | --- maddm_interface.py 2018-04-29 20:55:19 +0000 | |||
15 | +++ maddm_interface.py 2018-05-16 14:22:05 +0000 | |||
16 | @@ -115,6 +115,11 @@ | |||
17 | 115 | def post_install_PPPC4DMID(self): | 115 | def post_install_PPPC4DMID(self): |
18 | 116 | if os.path.exists(pjoin(MG5DIR, 'PPPC4DMID')): | 116 | if os.path.exists(pjoin(MG5DIR, 'PPPC4DMID')): |
19 | 117 | self.options['pppc4dmid_path'] = pjoin(MG5DIR, 'PPPC4DMID') | 117 | self.options['pppc4dmid_path'] = pjoin(MG5DIR, 'PPPC4DMID') |
20 | 118 | |||
21 | 119 | if not maddm_run_interface.HAS_SCIPY: | ||
22 | 120 | logger.critical("Fermi-LAT limit calculation for indirect detection requires numpy and scipy. Please install the missing modules.") | ||
23 | 121 | logger.info("you can try to use \"pip install scipy\"") | ||
24 | 122 | |||
25 | 118 | return | 123 | return |
26 | 119 | 124 | ||
27 | 120 | def set_configuration(self, config_path=None, final=True, **opts): | 125 | def set_configuration(self, config_path=None, final=True, **opts): |
28 | @@ -980,7 +985,7 @@ | |||
29 | 980 | has_diagram = True | 985 | has_diagram = True |
30 | 981 | return has_diagram | 986 | return has_diagram |
31 | 982 | 987 | ||
33 | 983 | def generate_indirect(self, argument): | 988 | def generate_indirect(self, argument, user=True): |
34 | 984 | """User level function which performs indirect detection functions | 989 | """User level function which performs indirect detection functions |
35 | 985 | Generates the DM DM > X where X is anything user specified. | 990 | Generates the DM DM > X where X is anything user specified. |
36 | 986 | Also works for loop induced processes as well as NLO-QCD. | 991 | Also works for loop induced processes as well as NLO-QCD. |
37 | @@ -988,6 +993,13 @@ | |||
38 | 988 | related to syntax: generate indirect a g / n3 | 993 | related to syntax: generate indirect a g / n3 |
39 | 989 | """ | 994 | """ |
40 | 990 | 995 | ||
41 | 996 | if not maddm_run_interface.HAS_NUMPY and user: | ||
42 | 997 | logger.warning("numpy module not detected on your machine. \n"+ | ||
43 | 998 | "Running indirect detection will not be possible as long as numpy is not installed (try 'pip install numpy')" | ||
44 | 999 | ) | ||
45 | 1000 | ans = self.ask("Do you want to generate the diagrams anyway?", 'n', ['y','n']) | ||
46 | 1001 | if ans == 'n': | ||
47 | 1002 | return | ||
48 | 991 | 1003 | ||
49 | 992 | self.install_indirect() | 1004 | self.install_indirect() |
50 | 993 | 1005 | ||
51 | @@ -1042,7 +1054,7 @@ | |||
52 | 1042 | 1054 | ||
53 | 1043 | for final_state in final_states: | 1055 | for final_state in final_states: |
54 | 1044 | try: | 1056 | try: |
56 | 1045 | self.exec_cmd('add indirect %s --noloop' % final_state,postcmd=False) | 1057 | self.generate_indirect([final_state, '--noloop'], user=False) |
57 | 1046 | except diagram_generation.NoDiagramException: | 1058 | except diagram_generation.NoDiagramException: |
58 | 1047 | continue | 1059 | continue |
59 | 1048 | logger.info('no diagram for %s' % final_state) | 1060 | logger.info('no diagram for %s' % final_state) |
60 | 1049 | 1061 | ||
61 | === modified file 'maddm_run_interface.py' | |||
62 | --- maddm_run_interface.py 2018-04-29 20:53:38 +0000 | |||
63 | +++ maddm_run_interface.py 2018-05-16 14:22:05 +0000 | |||
64 | @@ -10,12 +10,7 @@ | |||
65 | 10 | import stat | 10 | import stat |
66 | 11 | import shutil | 11 | import shutil |
67 | 12 | 12 | ||
74 | 13 | from scipy.interpolate import interp1d | 13 | |
69 | 14 | from scipy.integrate import quad | ||
70 | 15 | from scipy.optimize import minimize_scalar | ||
71 | 16 | from scipy.optimize import brute | ||
72 | 17 | from scipy.optimize import fmin | ||
73 | 18 | from scipy.special import gammainc | ||
75 | 19 | 14 | ||
76 | 20 | import MGoutput | 15 | import MGoutput |
77 | 21 | from madgraph import MadGraph5Error | 16 | from madgraph import MadGraph5Error |
78 | @@ -34,18 +29,37 @@ | |||
79 | 34 | 29 | ||
80 | 35 | #import darkmatter as darkmatter | 30 | #import darkmatter as darkmatter |
81 | 36 | 31 | ||
83 | 37 | import numpy as np | 32 | logger = logging.getLogger('madgraph.plugin.maddm') |
84 | 38 | 33 | ||
85 | 39 | try: | 34 | try: |
86 | 40 | import pymultinest | 35 | import pymultinest |
92 | 41 | except: | 36 | except ImportError: |
93 | 42 | print('WARNING: Multinest module not found! All multinest parameter scanning features will be disabled.') | 37 | pass |
94 | 43 | 38 | ||
95 | 44 | 39 | try: | |
96 | 45 | #import types | 40 | from scipy.interpolate import interp1d |
97 | 41 | from scipy.integrate import quad | ||
98 | 42 | from scipy.optimize import brute, fmin, minimize_scalar | ||
99 | 43 | from scipy.special import gammainc | ||
100 | 44 | except ImportError, error: | ||
101 | 45 | print error | ||
102 | 46 | logger.warning('scipy module not found! Some Indirect detection features will be disabled.') | ||
103 | 47 | HAS_SCIPY = False | ||
104 | 48 | else: | ||
105 | 49 | HAS_SCIPY = True | ||
106 | 50 | |||
107 | 51 | try: | ||
108 | 52 | import numpy as np | ||
109 | 53 | except ImportError: | ||
110 | 54 | logger.warning('numpy module not found! Indirect detection features will be disabled.') | ||
111 | 55 | HAS_NUMPY = False | ||
112 | 56 | else: | ||
113 | 57 | HAS_NUMPY = True | ||
114 | 58 | |||
115 | 59 | class ModuleMissing(Exception): pass | ||
116 | 46 | 60 | ||
117 | 47 | pjoin = os.path.join | 61 | pjoin = os.path.join |
119 | 48 | logger = logging.getLogger('madgraph.plugin.maddm') | 62 | |
120 | 49 | logger_tuto = logging.getLogger('tutorial_plugin') | 63 | logger_tuto = logging.getLogger('tutorial_plugin') |
121 | 50 | #logger.setLevel(10) #level 20 = INFO | 64 | #logger.setLevel(10) #level 20 = INFO |
122 | 51 | 65 | ||
123 | @@ -111,14 +125,18 @@ | |||
124 | 111 | self._sigma_ID[item] = -1.0 | 125 | self._sigma_ID[item] = -1.0 |
125 | 112 | self._sigma_ID_width[item] = -1.0 | 126 | self._sigma_ID_width[item] = -1.0 |
126 | 113 | 127 | ||
128 | 114 | self.load_constraints() | 128 | if HAS_NUMPY: |
129 | 129 | self.load_constraints() | ||
130 | 130 | |||
131 | 115 | 131 | ||
132 | 116 | logger.info('Loaded experimental constraints. To change, use the set command') | 132 | logger.info('Loaded experimental constraints. To change, use the set command') |
133 | 117 | logger.info('Omega h^2 = %.4e +- %.4e' %(self._oh2_planck, self._oh2_planck_width)) | 133 | logger.info('Omega h^2 = %.4e +- %.4e' %(self._oh2_planck, self._oh2_planck_width)) |
138 | 118 | logger.info('Spin Independent cross section: %s' % self._dd_si_limit_file) | 134 | if HAS_NUMPY: |
139 | 119 | logger.info('Spin Dependent cross section (p): %s' % self._dd_sd_proton_limit_file) | 135 | logger.info('Spin Independent cross section: %s' % self._dd_si_limit_file) |
140 | 120 | logger.info('Spin Dependent cross section (n): %s' % self._dd_sd_neutron_limit_file) | 136 | logger.info('Spin Dependent cross section (p): %s' % self._dd_sd_proton_limit_file) |
141 | 121 | 137 | logger.info('Spin Dependent cross section (n): %s' % self._dd_sd_neutron_limit_file) | |
142 | 138 | else: | ||
143 | 139 | logger.info('Spin (in)dependent not available due to the missing python module: numpy') | ||
144 | 122 | # for chan in self._allowed_final_states: | 140 | # for chan in self._allowed_final_states: |
145 | 123 | # logger.info('Indirect Detection cross section for final state %s at velocity %.2e: %s'\ | 141 | # logger.info('Indirect Detection cross section for final state %s at velocity %.2e: %s'\ |
146 | 124 | # % (chan, self._id_limit_vel[chan] ,self._id_limit_file[chan])) | 142 | # % (chan, self._id_limit_vel[chan] ,self._id_limit_file[chan])) |
147 | @@ -146,6 +164,10 @@ | |||
148 | 146 | 164 | ||
149 | 147 | #Returns a value in cm^2 | 165 | #Returns a value in cm^2 |
150 | 148 | def SI_max(self, mdm): | 166 | def SI_max(self, mdm): |
151 | 167 | if not HAS_NUMPY: | ||
152 | 168 | logger.warning("missing numpy module for SI limit") | ||
153 | 169 | return __infty__ | ||
154 | 170 | |||
155 | 149 | if (mdm < np.min(self._dd_si_limit_mDM) or mdm > np.max(self._dd_si_limit_mDM)): | 171 | if (mdm < np.min(self._dd_si_limit_mDM) or mdm > np.max(self._dd_si_limit_mDM)): |
156 | 150 | logger.warning('Dark matter mass value '+str(mdm)+' is outside the range of SI limit') | 172 | logger.warning('Dark matter mass value '+str(mdm)+' is outside the range of SI limit') |
157 | 151 | return __infty__ | 173 | return __infty__ |
158 | @@ -154,6 +176,10 @@ | |||
159 | 154 | 176 | ||
160 | 155 | #Returns a value in cm^2 | 177 | #Returns a value in cm^2 |
161 | 156 | def SD_max(self,mdm, nucleon): | 178 | def SD_max(self,mdm, nucleon): |
162 | 179 | if not HAS_NUMPY: | ||
163 | 180 | logger.warning("missing numpy module for SD limit") | ||
164 | 181 | return __infty__ | ||
165 | 182 | |||
166 | 157 | if nucleon not in ['n','p']: | 183 | if nucleon not in ['n','p']: |
167 | 158 | logger.error('nucleon can only be p or n') | 184 | logger.error('nucleon can only be p or n') |
168 | 159 | return __infty__ | 185 | return __infty__ |
169 | @@ -173,6 +199,9 @@ | |||
170 | 173 | 199 | ||
171 | 174 | #Returns a value in cm^3/s | 200 | #Returns a value in cm^3/s |
172 | 175 | def ID_max(self,mdm, channel): | 201 | def ID_max(self,mdm, channel): |
173 | 202 | if not HAS_NUMPY: | ||
174 | 203 | logger.warning("missing numpy module for ID limit") | ||
175 | 204 | return __infty__ | ||
176 | 176 | if (mdm < np.min(self._id_limit_mdm[channel]) or mdm > np.max(self._id_limit_mdm[channel])): | 205 | if (mdm < np.min(self._id_limit_mdm[channel]) or mdm > np.max(self._id_limit_mdm[channel])): |
177 | 177 | logger.warning('Dark matter mass value %.2e for channel %s is outside the range of ID limit' % (mdm, channel)) | 206 | logger.warning('Dark matter mass value %.2e for channel %s is outside the range of ID limit' % (mdm, channel)) |
178 | 178 | return __infty__ | 207 | return __infty__ |
179 | @@ -267,6 +296,10 @@ | |||
180 | 267 | # this function extracts the values of the spectra interpolated linearly between two values mdm_1 and mdm_2 | 296 | # this function extracts the values of the spectra interpolated linearly between two values mdm_1 and mdm_2 |
181 | 268 | # mdm is the DM candidate mass, spectrum is gammas, positron etc, channel is the SM annihilation e.g. bbar, hh etc. | 297 | # mdm is the DM candidate mass, spectrum is gammas, positron etc, channel is the SM annihilation e.g. bbar, hh etc. |
182 | 269 | def interpolate_spectra(self, sp_dic, mdm = '', spectrum = '' , channel = '' , earth = False , prof = 'Ein' , prop = 'MED' , halo_func = 'MF1'): | 298 | def interpolate_spectra(self, sp_dic, mdm = '', spectrum = '' , channel = '' , earth = False , prof = 'Ein' , prop = 'MED' , halo_func = 'MF1'): |
183 | 299 | |||
184 | 300 | if not HAS_SCIPY: | ||
185 | 301 | raise ModuleMissing('scipy module is required for this functionality.') | ||
186 | 302 | |||
187 | 270 | M = sp_dic['Masses'] | 303 | M = sp_dic['Masses'] |
188 | 271 | dm_min = max([m for m in M if m <= mdm]) # extracting lower mass limit to interpolate from | 304 | dm_min = max([m for m in M if m <= mdm]) # extracting lower mass limit to interpolate from |
189 | 272 | dm_max = min([m for m in M if m >= mdm]) # extracting upper mass limit to interpolate from | 305 | dm_max = min([m for m in M if m >= mdm]) # extracting upper mass limit to interpolate from |
190 | @@ -306,7 +339,8 @@ | |||
191 | 306 | self.dSph_ll_files_path = pjoin(MDMDIR, 'Fermi_Data', 'likelihoods') | 339 | self.dSph_ll_files_path = pjoin(MDMDIR, 'Fermi_Data', 'likelihoods') |
192 | 307 | self.dwarves_list = ['coma_berenices', 'draco', 'segue_1', 'ursa_major_II', 'ursa_minor', 'reticulum_II' ] # dSphs with the 6 highest Jfactors | 340 | self.dwarves_list = ['coma_berenices', 'draco', 'segue_1', 'ursa_major_II', 'ursa_minor', 'reticulum_II' ] # dSphs with the 6 highest Jfactors |
193 | 308 | self.dwarveslist_all = self.extract_dwarveslist() | 341 | self.dwarveslist_all = self.extract_dwarveslist() |
195 | 309 | self.dw_in = self.dw_dic() | 342 | if HAS_NUMPY and HAS_SCIPY: |
196 | 343 | self.dw_in = self.dw_dic() | ||
197 | 310 | self.ll_tot = '' | 344 | self.ll_tot = '' |
198 | 311 | 345 | ||
199 | 312 | # This function reads the list of dwarves from the Jfactor.dat file | 346 | # This function reads the list of dwarves from the Jfactor.dat file |
200 | @@ -363,6 +397,10 @@ | |||
201 | 363 | def eflux(self,spectrum, emin=1e2, emax=1e5, quiet=False): | 397 | def eflux(self,spectrum, emin=1e2, emax=1e5, quiet=False): |
202 | 364 | """ Integrate a generic spectrum, multiplied by E, to get the energy flux. | 398 | """ Integrate a generic spectrum, multiplied by E, to get the energy flux. |
203 | 365 | """ | 399 | """ |
204 | 400 | |||
205 | 401 | if not HAS_SCIPY: | ||
206 | 402 | raise ModuleMissing('scipy module is required for this functionality.') | ||
207 | 403 | |||
208 | 366 | espectrum = lambda e: spectrum(e)*e | 404 | espectrum = lambda e: spectrum(e)*e |
209 | 367 | tol = min(espectrum(emin),espectrum(emax))*1e-10 | 405 | tol = min(espectrum(emin),espectrum(emax))*1e-10 |
210 | 368 | try: | 406 | try: |
211 | @@ -373,6 +411,9 @@ | |||
212 | 373 | 411 | ||
213 | 374 | def marg_like_dw(self,dw_in_i,pred,marginalize): | 412 | def marg_like_dw(self,dw_in_i,pred,marginalize): |
214 | 375 | 413 | ||
215 | 414 | if not HAS_SCIPY: | ||
216 | 415 | raise ModuleMissing('scipy module is required for this functionality.') | ||
217 | 416 | |||
218 | 376 | j0, nBin = self.j0 , self.nBin | 417 | j0, nBin = self.j0 , self.nBin |
219 | 377 | 418 | ||
220 | 378 | j,jerr,like_inter = dw_in_i['Jfac'], dw_in_i['Jfac_err'], dw_in_i['likelihood'] | 419 | j,jerr,like_inter = dw_in_i['Jfac'], dw_in_i['Jfac_err'], dw_in_i['likelihood'] |
221 | @@ -403,6 +444,9 @@ | |||
222 | 403 | 444 | ||
223 | 404 | def res_tot_dw(self,pred,marginalize): | 445 | def res_tot_dw(self,pred,marginalize): |
224 | 405 | 446 | ||
225 | 447 | if not HAS_SCIPY: | ||
226 | 448 | raise ModuleMissing('scipy module is required for this functionality.') | ||
227 | 449 | |||
228 | 406 | dw_in = self.dw_in | 450 | dw_in = self.dw_in |
229 | 407 | ll_tot = 0.0 | 451 | ll_tot = 0.0 |
230 | 408 | ll_null = 0.0 | 452 | ll_null = 0.0 |
231 | @@ -436,7 +480,20 @@ | |||
232 | 436 | # otherwise it calculates the likelihood and p-value for the given point | 480 | # otherwise it calculates the likelihood and p-value for the given point |
233 | 437 | def Fermi_sigmav_lim(self, mDM, x = '' , dndlogx = '' , marginalize = True, sigmav_th = False , maj_dirac='', \ | 481 | def Fermi_sigmav_lim(self, mDM, x = '' , dndlogx = '' , marginalize = True, sigmav_th = False , maj_dirac='', \ |
234 | 438 | sigmavmin=1e-35, sigmavmax=1e-15, step_size_scaling=1.0, cl_val = 0.95): | 482 | sigmavmin=1e-35, sigmavmax=1e-15, step_size_scaling=1.0, cl_val = 0.95): |
236 | 439 | 483 | stop = False | |
237 | 484 | if not HAS_NUMPY: | ||
238 | 485 | logger.warning("Fermi limit ignored due to missing numpy module") | ||
239 | 486 | stop = True | ||
240 | 487 | if not HAS_SCIPY: | ||
241 | 488 | logger.warning("Fermi limit ignored due to missing scipy module") | ||
242 | 489 | stop = True | ||
243 | 490 | |||
244 | 491 | if stop: | ||
245 | 492 | if sigmav_th: | ||
246 | 493 | return -1, -1 | ||
247 | 494 | else: | ||
248 | 495 | return -1 | ||
249 | 496 | |||
250 | 440 | np.seterr(divide='ignore', invalid='ignore') # Keep numpy from complaining about dN/dE = 0... | 497 | np.seterr(divide='ignore', invalid='ignore') # Keep numpy from complaining about dN/dE = 0... |
251 | 441 | j0 , nBin = self.j0 , self.nBin | 498 | j0 , nBin = self.j0 , self.nBin |
252 | 442 | 499 | ||
253 | @@ -1226,8 +1283,8 @@ | |||
254 | 1226 | sp_name = sp + '_spectrum_pythia8.dat' | 1283 | sp_name = sp + '_spectrum_pythia8.dat' |
255 | 1227 | out_dir = pjoin(self.dir_path,'Indirect', 'Events', run_name, sp_name ) | 1284 | out_dir = pjoin(self.dir_path,'Indirect', 'Events', run_name, sp_name ) |
256 | 1228 | if sp == 'gammas': # x values are the same for all the spectra | 1285 | if sp == 'gammas': # x values are the same for all the spectra |
259 | 1229 | x = np.loadtxt(out_dir , unpack = True )[0] | 1286 | x = np.loadtxt(out_dir , unpack = True )[0] |
260 | 1230 | self.Spectra.spectra['x'] = [ np.power(10,num) for num in x] # from log[10,x] to x | 1287 | self.Spectra.spectra['x'] = [ np.power(10,num) for num in x] # from log[10,x] to x |
261 | 1231 | self.Spectra.spectra[sp] = np.loadtxt(out_dir , unpack = True )[1].tolist() | 1288 | self.Spectra.spectra[sp] = np.loadtxt(out_dir , unpack = True )[1].tolist() |
262 | 1232 | 1289 | ||
263 | 1233 | 1290 | ||
264 | @@ -1239,6 +1296,10 @@ | |||
265 | 1239 | logger.error('PPPC4DMID not installed. Please install by typing "install PPPC4DMID".') | 1296 | logger.error('PPPC4DMID not installed. Please install by typing "install PPPC4DMID".') |
266 | 1240 | return | 1297 | return |
267 | 1241 | 1298 | ||
268 | 1299 | if not HAS_SCIPY: | ||
269 | 1300 | logger.error('using PPPC4DMID requires scipy module. Please install it (for example with "pip install scipy")') | ||
270 | 1301 | return | ||
271 | 1302 | |||
272 | 1242 | if 'PPPC4DMID' in self.maddm_card['indirect_flux_source_method'] or 'inclusive' in self.maddm_card['sigmav_method']: | 1303 | if 'PPPC4DMID' in self.maddm_card['indirect_flux_source_method'] or 'inclusive' in self.maddm_card['sigmav_method']: |
273 | 1243 | if self.Spectra.check_mass(mdm): | 1304 | if self.Spectra.check_mass(mdm): |
274 | 1244 | if '_ew' in self.maddm_card['indirect_flux_source_method']: | 1305 | if '_ew' in self.maddm_card['indirect_flux_source_method']: |
275 | @@ -1627,8 +1688,8 @@ | |||
276 | 1627 | 1688 | ||
277 | 1628 | if self.mode['relic']: | 1689 | if self.mode['relic']: |
278 | 1629 | logger.info("\n***** Relic Density") | 1690 | logger.info("\n***** Relic Density") |
281 | 1630 | 1691 | print 'OMEGA IS ', omega | |
282 | 1631 | logger.info( self.form_s('Relic Density') + '= ' + self.form_n(omega ) + ' ' + pass_relic ) | 1692 | logger.info( self.form_s('Relic Density') + '= ' + self.form_n(omega) + ' ' + pass_relic ) |
283 | 1632 | logger.info( self.form_s('x_f' ) + '= ' + self.form_s(self.form_n(x_f ) ) ) | 1693 | logger.info( self.form_s('x_f' ) + '= ' + self.form_s(self.form_n(x_f ) ) ) |
284 | 1633 | logger.info( self.form_s('sigmav(xf)' ) + '= ' + self.form_s(self.form_n(sigma_xf ) ) ) | 1694 | logger.info( self.form_s('sigmav(xf)' ) + '= ' + self.form_s(self.form_n(sigma_xf ) ) ) |
285 | 1634 | logger.info( self.form_s('xsi' ) + '= ' + self.form_s(self.form_n(xsi ) ) ) | 1695 | logger.info( self.form_s('xsi' ) + '= ' + self.form_s(self.form_n(xsi ) ) ) |
286 | @@ -1916,11 +1977,11 @@ | |||
287 | 1916 | th_mess = self.det_message_screen(sig_th , ul) | 1977 | th_mess = self.det_message_screen(sig_th , ul) |
288 | 1917 | line = self.form_s(what) + self.form_s('Thermal = '+ self.form_n(sig_th)) + ' ' + self.form_s(th_mess) | 1978 | line = self.form_s(what) + self.form_s('Thermal = '+ self.form_n(sig_th)) + ' ' + self.form_s(th_mess) |
289 | 1918 | line = line + '\t' + self.form_s('All DM = ' + self.form_n(sig_alldm) ) + ' ' + self.form_s(alldm_mess) | 1979 | line = line + '\t' + self.form_s('All DM = ' + self.form_n(sig_alldm) ) + ' ' + self.form_s(alldm_mess) |
291 | 1919 | line = line + '\t' + '{:16}'.format(exp+' ul') + ' = ' + self.form_n(ul) | 1980 | line = line + '\t' + '{0:16}'.format(exp+' ul') + ' = ' + self.form_n(ul) |
292 | 1920 | 1981 | ||
293 | 1921 | else: | 1982 | else: |
294 | 1922 | line = self.form_s(what) + self.form_s('All DM = ' + self.form_n(sig_alldm) ) + ' ' + self.form_s(alldm_mess) | 1983 | line = self.form_s(what) + self.form_s('All DM = ' + self.form_n(sig_alldm) ) + ' ' + self.form_s(alldm_mess) |
296 | 1923 | line = line + '\t' + '{:16}'.format(exp+' ul') + ' = ' + self.form_n(ul) | 1984 | line = line + '\t' + '{0:16}'.format(exp+' ul') + ' = ' + self.form_n(ul) |
297 | 1924 | 1985 | ||
298 | 1925 | elif not direc and no_lim: | 1986 | elif not direc and no_lim: |
299 | 1926 | 1987 | ||
300 | @@ -1941,11 +2002,11 @@ | |||
301 | 1941 | # os.symlink(pjoin(self.dir_path,'Indirect','Events'), pjoin(self.dir_path, 'output' , 'Output_Indirect') ) | 2002 | # os.symlink(pjoin(self.dir_path,'Indirect','Events'), pjoin(self.dir_path, 'output' , 'Output_Indirect') ) |
302 | 1942 | 2003 | ||
303 | 1943 | def form_s(stringa): | 2004 | def form_s(stringa): |
305 | 1944 | formatted = '{:22}'.format(stringa) | 2005 | formatted = '{0:22}'.format(stringa) |
306 | 1945 | return formatted | 2006 | return formatted |
307 | 1946 | 2007 | ||
308 | 1947 | def form_n(num): | 2008 | def form_n(num): |
310 | 1948 | formatted = '{:3.2e}'.format(num) | 2009 | formatted = '{0:3.2e}'.format(num) |
311 | 1949 | return formatted | 2010 | return formatted |
312 | 1950 | 2011 | ||
313 | 1951 | out = open(pjoin(self.dir_path, 'output', point, 'MadDM_results.txt'),'w') | 2012 | out = open(pjoin(self.dir_path, 'output', point, 'MadDM_results.txt'),'w') |
314 | @@ -2063,10 +2124,10 @@ | |||
315 | 2063 | elif n1 <= 0 : return 'No Theory Prediction' | 2124 | elif n1 <= 0 : return 'No Theory Prediction' |
316 | 2064 | 2125 | ||
317 | 2065 | def form_s(self,stringa): | 2126 | def form_s(self,stringa): |
319 | 2066 | formatted = '{:20}'.format(stringa) | 2127 | formatted = '{0:20}'.format(stringa) |
320 | 2067 | return formatted | 2128 | return formatted |
321 | 2068 | def form_n(self,num): | 2129 | def form_n(self,num): |
323 | 2069 | formatted = '{:3.2e}'.format(num) | 2130 | formatted = '{0:3.2e}'.format(num) |
324 | 2070 | return formatted | 2131 | return formatted |
325 | 2071 | 2132 | ||
326 | 2072 | def ask_run_configuration(self, mode=None, force=False): | 2133 | def ask_run_configuration(self, mode=None, force=False): |
327 | @@ -2356,11 +2417,23 @@ | |||
328 | 2356 | def set_default_indirect(self): | 2417 | def set_default_indirect(self): |
329 | 2357 | """set the default value for relic=""" | 2418 | """set the default value for relic=""" |
330 | 2358 | 2419 | ||
332 | 2359 | if self.availmode['has_indirect_detection']: | 2420 | if not HAS_NUMPY: |
333 | 2421 | self.switch['indirect'] = 'Not Avail. (numpy missing)' | ||
334 | 2422 | elif self.availmode['has_indirect_detection']: | ||
335 | 2360 | self.switch['indirect'] = 'sigmav' | 2423 | self.switch['indirect'] = 'sigmav' |
336 | 2361 | else: | 2424 | else: |
337 | 2362 | self.switch['indirect'] = 'Not Avail.' | 2425 | self.switch['indirect'] = 'Not Avail.' |
338 | 2363 | 2426 | ||
339 | 2427 | def print_options_indirect(self): | ||
340 | 2428 | """print statement for the options""" | ||
341 | 2429 | |||
342 | 2430 | if not self.availmode['has_indirect_detection']: | ||
343 | 2431 | return "Please install module" | ||
344 | 2432 | elif not HAS_NUMPY: | ||
345 | 2433 | return "numpy not available" | ||
346 | 2434 | else: | ||
347 | 2435 | return self.print_options('indirect', keep_default=True) | ||
348 | 2436 | |||
349 | 2364 | def get_allowed_indirect(self): | 2437 | def get_allowed_indirect(self): |
350 | 2365 | """Specify which parameter are allowed for relic=""" | 2438 | """Specify which parameter are allowed for relic=""" |
351 | 2366 | 2439 | ||
352 | @@ -2368,10 +2441,13 @@ | |||
353 | 2368 | if hasattr(self, 'allowed_indirect'): | 2441 | if hasattr(self, 'allowed_indirect'): |
354 | 2369 | return getattr(self, 'allowed_indirect') | 2442 | return getattr(self, 'allowed_indirect') |
355 | 2370 | 2443 | ||
357 | 2371 | if self.availmode['has_indirect_detection']: | 2444 | if not HAS_NUMPY: |
358 | 2445 | self.allowed_indirect = ['OFF'] | ||
359 | 2446 | elif self.availmode['has_indirect_detection']: | ||
360 | 2372 | self.allowed_indirect = ['OFF', 'sigmav', 'flux_source', 'flux_earth'] | 2447 | self.allowed_indirect = ['OFF', 'sigmav', 'flux_source', 'flux_earth'] |
361 | 2373 | else: | 2448 | else: |
363 | 2374 | return [] | 2449 | self.allowed_indirect = [] |
364 | 2450 | return self.allowed_indirect | ||
365 | 2375 | 2451 | ||
366 | 2376 | 2452 | ||
367 | 2377 | def check_value_indirect(self, value): | 2453 | def check_value_indirect(self, value): |
368 | @@ -2599,7 +2675,7 @@ | |||
369 | 2599 | 2675 | ||
370 | 2600 | try: | 2676 | try: |
371 | 2601 | return cmd.ControlSwitch.default(self, line, raise_error=True) | 2677 | return cmd.ControlSwitch.default(self, line, raise_error=True) |
373 | 2602 | except cmd.NotValidInput: | 2678 | except cmd.NotValidInput, error: |
374 | 2603 | return common_run.AskforEditCard.default(self, line) | 2679 | return common_run.AskforEditCard.default(self, line) |
375 | 2604 | 2680 | ||
376 | 2605 | def trigger_7(self, line): | 2681 | def trigger_7(self, line): |
mail from federico:
Hi Olivier,
I dowloaded the branch and replaced it inside the PLUGIN directory, so I don’t know how to test what is the behaviour when you try to install maddm without it numpy,scipy.
But it works i.e. I can run maddm without numpy and scipy. Here my comments:
1) If I look at your modified script I read:
"PPC4DMID module requires scipy to be working. Please install those python module. (they are not present)")
but it should be something like:
“Fermi-LAT limit calculation for indirect detection requires numpy and scipy. Please install the missing modules…)
I.e. it is not related to PPPC but in general to Fermi limits.
2) If I don’t have numpy and scipy, why does it compute the diagrams for indirect detection if ask for "add indirect_detection” ?
If the indirect detection module must be switched off, should the whole module be disabled?
I think a warning message should appear when the user tries to add the indirect detection calculation, and then maddm should not calculate anything.
3)
Then I noticed that when I try to switch on the indirect detection, it does not happen of course as we want, but maddm does not print anything on screen,
i.e. if I keen on typing 3 to select the option for indirect detection, on the screen nothing happens.
It should warn that “Indirect detection not available since numpy and scipy are missing…”