Merge lp:~maddm/maddm/no_numpy_scipy into lp:~maddm/maddm/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
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.

To post a comment you must log in.
lp:~maddm/maddm/no_numpy_scipy updated
18. By olivier-mattelaer

some issue created by the change

19. By olivier-mattelaer

additional fix

20. By Federico Ambrogi <email address hidden>

Formatted string as as python 2.6

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote :

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…”

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
21. By olivier-mattelaer

change according to federico review

22. By olivier-mattelaer

remove some printout

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '__init__.py'
--- __init__.py 2018-03-30 22:19:49 +0000
+++ __init__.py 2018-05-16 14:22:05 +0000
@@ -16,6 +16,6 @@
16new_reweight = {'indirect': MGoutput.Indirect_Reweight}16new_reweight = {'indirect': MGoutput.Indirect_Reweight}
1717
18## The test/code have been validated up to this version18## The test/code have been validated up to this version
19latest_validated_version = (2,6,2)19latest_validated_version = (2,6,3)
20minimal_mg5amcnlo_version = (2,6,2)20minimal_mg5amcnlo_version = (2,6,2)
21maximal_mg5amcnlo_version = (1000,1000,1000)21maximal_mg5amcnlo_version = (1000,1000,1000)
2222
=== modified file 'maddm_interface.py'
--- maddm_interface.py 2018-04-29 20:55:19 +0000
+++ maddm_interface.py 2018-05-16 14:22:05 +0000
@@ -115,6 +115,11 @@
115 def post_install_PPPC4DMID(self):115 def post_install_PPPC4DMID(self):
116 if os.path.exists(pjoin(MG5DIR, 'PPPC4DMID')):116 if os.path.exists(pjoin(MG5DIR, 'PPPC4DMID')):
117 self.options['pppc4dmid_path'] = pjoin(MG5DIR, 'PPPC4DMID')117 self.options['pppc4dmid_path'] = pjoin(MG5DIR, 'PPPC4DMID')
118
119 if not maddm_run_interface.HAS_SCIPY:
120 logger.critical("Fermi-LAT limit calculation for indirect detection requires numpy and scipy. Please install the missing modules.")
121 logger.info("you can try to use \"pip install scipy\"")
122
118 return123 return
119 124
120 def set_configuration(self, config_path=None, final=True, **opts):125 def set_configuration(self, config_path=None, final=True, **opts):
@@ -980,7 +985,7 @@
980 has_diagram = True985 has_diagram = True
981 return has_diagram986 return has_diagram
982987
983 def generate_indirect(self, argument):988 def generate_indirect(self, argument, user=True):
984 """User level function which performs indirect detection functions989 """User level function which performs indirect detection functions
985 Generates the DM DM > X where X is anything user specified.990 Generates the DM DM > X where X is anything user specified.
986 Also works for loop induced processes as well as NLO-QCD.991 Also works for loop induced processes as well as NLO-QCD.
@@ -988,6 +993,13 @@
988 related to syntax: generate indirect a g / n3993 related to syntax: generate indirect a g / n3
989 """994 """
990 995
996 if not maddm_run_interface.HAS_NUMPY and user:
997 logger.warning("numpy module not detected on your machine. \n"+
998 "Running indirect detection will not be possible as long as numpy is not installed (try 'pip install numpy')"
999 )
1000 ans = self.ask("Do you want to generate the diagrams anyway?", 'n', ['y','n'])
1001 if ans == 'n':
1002 return
991 1003
992 self.install_indirect()1004 self.install_indirect()
9931005
@@ -1042,7 +1054,7 @@
10421054
1043 for final_state in final_states:1055 for final_state in final_states:
1044 try: 1056 try:
1045 self.exec_cmd('add indirect %s --noloop' % final_state,postcmd=False)1057 self.generate_indirect([final_state, '--noloop'], user=False)
1046 except diagram_generation.NoDiagramException:1058 except diagram_generation.NoDiagramException:
1047 continue1059 continue
1048 logger.info('no diagram for %s' % final_state)1060 logger.info('no diagram for %s' % final_state)
10491061
=== modified file 'maddm_run_interface.py'
--- maddm_run_interface.py 2018-04-29 20:53:38 +0000
+++ maddm_run_interface.py 2018-05-16 14:22:05 +0000
@@ -10,12 +10,7 @@
10import stat10import stat
11import shutil11import shutil
1212
13from scipy.interpolate import interp1d13
14from scipy.integrate import quad
15from scipy.optimize import minimize_scalar
16from scipy.optimize import brute
17from scipy.optimize import fmin
18from scipy.special import gammainc
1914
20import MGoutput15import MGoutput
21from madgraph import MadGraph5Error16from madgraph import MadGraph5Error
@@ -34,18 +29,37 @@
34 29
35#import darkmatter as darkmatter30#import darkmatter as darkmatter
3631
37import numpy as np32logger = logging.getLogger('madgraph.plugin.maddm')
3833
39try:34try:
40 import pymultinest35 import pymultinest
41except:36except ImportError:
42 print('WARNING: Multinest module not found! All multinest parameter scanning features will be disabled.')37 pass
4338
4439try:
45#import types40 from scipy.interpolate import interp1d
41 from scipy.integrate import quad
42 from scipy.optimize import brute, fmin, minimize_scalar
43 from scipy.special import gammainc
44except ImportError, error:
45 print error
46 logger.warning('scipy module not found! Some Indirect detection features will be disabled.')
47 HAS_SCIPY = False
48else:
49 HAS_SCIPY = True
50
51try:
52 import numpy as np
53except ImportError:
54 logger.warning('numpy module not found! Indirect detection features will be disabled.')
55 HAS_NUMPY = False
56else:
57 HAS_NUMPY = True
58
59class ModuleMissing(Exception): pass
4660
47pjoin = os.path.join61pjoin = os.path.join
48logger = logging.getLogger('madgraph.plugin.maddm')62
49logger_tuto = logging.getLogger('tutorial_plugin')63logger_tuto = logging.getLogger('tutorial_plugin')
50#logger.setLevel(10) #level 20 = INFO64#logger.setLevel(10) #level 20 = INFO
5165
@@ -111,14 +125,18 @@
111 self._sigma_ID[item] = -1.0125 self._sigma_ID[item] = -1.0
112 self._sigma_ID_width[item] = -1.0126 self._sigma_ID_width[item] = -1.0
113127
114 self.load_constraints()128 if HAS_NUMPY:
129 self.load_constraints()
130
115131
116 logger.info('Loaded experimental constraints. To change, use the set command')132 logger.info('Loaded experimental constraints. To change, use the set command')
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))
118 logger.info('Spin Independent cross section: %s' % self._dd_si_limit_file)134 if HAS_NUMPY:
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)
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)
121137 logger.info('Spin Dependent cross section (n): %s' % self._dd_sd_neutron_limit_file)
138 else:
139 logger.info('Spin (in)dependent not available due to the missing python module: numpy')
122# for chan in self._allowed_final_states:140# for chan in self._allowed_final_states:
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'\
124# % (chan, self._id_limit_vel[chan] ,self._id_limit_file[chan]))142# % (chan, self._id_limit_vel[chan] ,self._id_limit_file[chan]))
@@ -146,6 +164,10 @@
146164
147 #Returns a value in cm^2165 #Returns a value in cm^2
148 def SI_max(self, mdm):166 def SI_max(self, mdm):
167 if not HAS_NUMPY:
168 logger.warning("missing numpy module for SI limit")
169 return __infty__
170
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)):
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')
151 return __infty__173 return __infty__
@@ -154,6 +176,10 @@
154176
155 #Returns a value in cm^2177 #Returns a value in cm^2
156 def SD_max(self,mdm, nucleon):178 def SD_max(self,mdm, nucleon):
179 if not HAS_NUMPY:
180 logger.warning("missing numpy module for SD limit")
181 return __infty__
182
157 if nucleon not in ['n','p']:183 if nucleon not in ['n','p']:
158 logger.error('nucleon can only be p or n')184 logger.error('nucleon can only be p or n')
159 return __infty__185 return __infty__
@@ -173,6 +199,9 @@
173199
174 #Returns a value in cm^3/s200 #Returns a value in cm^3/s
175 def ID_max(self,mdm, channel):201 def ID_max(self,mdm, channel):
202 if not HAS_NUMPY:
203 logger.warning("missing numpy module for ID limit")
204 return __infty__
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 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 return __infty__207 return __infty__
@@ -267,6 +296,10 @@
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
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.
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'):
299
300 if not HAS_SCIPY:
301 raise ModuleMissing('scipy module is required for this functionality.')
302
270 M = sp_dic['Masses']303 M = sp_dic['Masses']
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
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
@@ -306,7 +339,8 @@
306 self.dSph_ll_files_path = pjoin(MDMDIR, 'Fermi_Data', 'likelihoods')339 self.dSph_ll_files_path = pjoin(MDMDIR, 'Fermi_Data', 'likelihoods')
307 self.dwarves_list = ['coma_berenices', 'draco', 'segue_1', 'ursa_major_II', 'ursa_minor', 'reticulum_II' ] # dSphs with the 6 highest Jfactors340 self.dwarves_list = ['coma_berenices', 'draco', 'segue_1', 'ursa_major_II', 'ursa_minor', 'reticulum_II' ] # dSphs with the 6 highest Jfactors
308 self.dwarveslist_all = self.extract_dwarveslist() 341 self.dwarveslist_all = self.extract_dwarveslist()
309 self.dw_in = self.dw_dic()342 if HAS_NUMPY and HAS_SCIPY:
343 self.dw_in = self.dw_dic()
310 self.ll_tot = ''344 self.ll_tot = ''
311345
312 # This function reads the list of dwarves from the Jfactor.dat file346 # This function reads the list of dwarves from the Jfactor.dat file
@@ -363,6 +397,10 @@
363 def eflux(self,spectrum, emin=1e2, emax=1e5, quiet=False):397 def eflux(self,spectrum, emin=1e2, emax=1e5, quiet=False):
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.
365 """399 """
400
401 if not HAS_SCIPY:
402 raise ModuleMissing('scipy module is required for this functionality.')
403
366 espectrum = lambda e: spectrum(e)*e404 espectrum = lambda e: spectrum(e)*e
367 tol = min(espectrum(emin),espectrum(emax))*1e-10405 tol = min(espectrum(emin),espectrum(emax))*1e-10
368 try:406 try:
@@ -373,6 +411,9 @@
373411
374 def marg_like_dw(self,dw_in_i,pred,marginalize):412 def marg_like_dw(self,dw_in_i,pred,marginalize):
375 413
414 if not HAS_SCIPY:
415 raise ModuleMissing('scipy module is required for this functionality.')
416
376 j0, nBin = self.j0 , self.nBin417 j0, nBin = self.j0 , self.nBin
377418
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']
@@ -403,6 +444,9 @@
403444
404 def res_tot_dw(self,pred,marginalize):445 def res_tot_dw(self,pred,marginalize):
405446
447 if not HAS_SCIPY:
448 raise ModuleMissing('scipy module is required for this functionality.')
449
406 dw_in = self.dw_in450 dw_in = self.dw_in
407 ll_tot = 0.0451 ll_tot = 0.0
408 ll_null = 0.0452 ll_null = 0.0
@@ -436,7 +480,20 @@
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
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='', \
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):
439483 stop = False
484 if not HAS_NUMPY:
485 logger.warning("Fermi limit ignored due to missing numpy module")
486 stop = True
487 if not HAS_SCIPY:
488 logger.warning("Fermi limit ignored due to missing scipy module")
489 stop = True
490
491 if stop:
492 if sigmav_th:
493 return -1, -1
494 else:
495 return -1
496
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...
441 j0 , nBin = self.j0 , self.nBin498 j0 , nBin = self.j0 , self.nBin
442 499
@@ -1226,8 +1283,8 @@
1226 sp_name = sp + '_spectrum_pythia8.dat'1283 sp_name = sp + '_spectrum_pythia8.dat'
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 )
1228 if sp == 'gammas': # x values are the same for all the spectra1285 if sp == 'gammas': # x values are the same for all the spectra
1229 x = np.loadtxt(out_dir , unpack = True )[0]1286 x = np.loadtxt(out_dir , unpack = True )[0]
1230 self.Spectra.spectra['x'] = [ np.power(10,num) for num in x] # from log[10,x] to x1287 self.Spectra.spectra['x'] = [ np.power(10,num) for num in x] # from log[10,x] to x
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()
1232 1289
12331290
@@ -1239,6 +1296,10 @@
1239 logger.error('PPPC4DMID not installed. Please install by typing "install PPPC4DMID".')1296 logger.error('PPPC4DMID not installed. Please install by typing "install PPPC4DMID".')
1240 return1297 return
12411298
1299 if not HAS_SCIPY:
1300 logger.error('using PPPC4DMID requires scipy module. Please install it (for example with "pip install scipy")')
1301 return
1302
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']:
1243 if self.Spectra.check_mass(mdm):1304 if self.Spectra.check_mass(mdm):
1244 if '_ew' in self.maddm_card['indirect_flux_source_method']:1305 if '_ew' in self.maddm_card['indirect_flux_source_method']:
@@ -1627,8 +1688,8 @@
16271688
1628 if self.mode['relic']:1689 if self.mode['relic']:
1629 logger.info("\n***** Relic Density")1690 logger.info("\n***** Relic Density")
16301691 print 'OMEGA IS ', omega
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 )
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 ) ) )
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 ) ) )
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 ) ) )
@@ -1916,11 +1977,11 @@
1916 th_mess = self.det_message_screen(sig_th , ul)1977 th_mess = self.det_message_screen(sig_th , ul)
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)
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)
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)
19201981
1921 else: 1982 else:
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)
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)
19241985
1925 elif not direc and no_lim:1986 elif not direc and no_lim:
19261987
@@ -1941,11 +2002,11 @@
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') )
1942 2003
1943 def form_s(stringa):2004 def form_s(stringa):
1944 formatted = '{:22}'.format(stringa)2005 formatted = '{0:22}'.format(stringa)
1945 return formatted2006 return formatted
1946 2007
1947 def form_n(num):2008 def form_n(num):
1948 formatted = '{:3.2e}'.format(num)2009 formatted = '{0:3.2e}'.format(num)
1949 return formatted2010 return formatted
19502011
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')
@@ -2063,10 +2124,10 @@
2063 elif n1 <= 0 : return 'No Theory Prediction' 2124 elif n1 <= 0 : return 'No Theory Prediction'
2064 2125
2065 def form_s(self,stringa):2126 def form_s(self,stringa):
2066 formatted = '{:20}'.format(stringa)2127 formatted = '{0:20}'.format(stringa)
2067 return formatted2128 return formatted
2068 def form_n(self,num):2129 def form_n(self,num):
2069 formatted = '{:3.2e}'.format(num)2130 formatted = '{0:3.2e}'.format(num)
2070 return formatted2131 return formatted
2071 2132
2072 def ask_run_configuration(self, mode=None, force=False):2133 def ask_run_configuration(self, mode=None, force=False):
@@ -2356,11 +2417,23 @@
2356 def set_default_indirect(self):2417 def set_default_indirect(self):
2357 """set the default value for relic="""2418 """set the default value for relic="""
2358 2419
2359 if self.availmode['has_indirect_detection']:2420 if not HAS_NUMPY:
2421 self.switch['indirect'] = 'Not Avail. (numpy missing)'
2422 elif self.availmode['has_indirect_detection']:
2360 self.switch['indirect'] = 'sigmav' 2423 self.switch['indirect'] = 'sigmav'
2361 else:2424 else:
2362 self.switch['indirect'] = 'Not Avail.'2425 self.switch['indirect'] = 'Not Avail.'
23632426
2427 def print_options_indirect(self):
2428 """print statement for the options"""
2429
2430 if not self.availmode['has_indirect_detection']:
2431 return "Please install module"
2432 elif not HAS_NUMPY:
2433 return "numpy not available"
2434 else:
2435 return self.print_options('indirect', keep_default=True)
2436
2364 def get_allowed_indirect(self):2437 def get_allowed_indirect(self):
2365 """Specify which parameter are allowed for relic="""2438 """Specify which parameter are allowed for relic="""
2366 2439
@@ -2368,10 +2441,13 @@
2368 if hasattr(self, 'allowed_indirect'):2441 if hasattr(self, 'allowed_indirect'):
2369 return getattr(self, 'allowed_indirect')2442 return getattr(self, 'allowed_indirect')
23702443
2371 if self.availmode['has_indirect_detection']:2444 if not HAS_NUMPY:
2445 self.allowed_indirect = ['OFF']
2446 elif self.availmode['has_indirect_detection']:
2372 self.allowed_indirect = ['OFF', 'sigmav', 'flux_source', 'flux_earth']2447 self.allowed_indirect = ['OFF', 'sigmav', 'flux_source', 'flux_earth']
2373 else:2448 else:
2374 return []2449 self.allowed_indirect = []
2450 return self.allowed_indirect
23752451
2376 2452
2377 def check_value_indirect(self, value):2453 def check_value_indirect(self, value):
@@ -2599,7 +2675,7 @@
2599 2675
2600 try:2676 try:
2601 return cmd.ControlSwitch.default(self, line, raise_error=True)2677 return cmd.ControlSwitch.default(self, line, raise_error=True)
2602 except cmd.NotValidInput:2678 except cmd.NotValidInput, error:
2603 return common_run.AskforEditCard.default(self, line) 2679 return common_run.AskforEditCard.default(self, line)
2604 2680
2605 def trigger_7(self, line):2681 def trigger_7(self, line):

Subscribers

People subscribed via source and target branches

to all changes: