Commit 5c4c99da authored by Ben Farr's avatar Ben Farr
Browse files

Catch Value and Index errors

parent e3e0fb54
......@@ -78,32 +78,32 @@ def sample_to_waveform_params(sample, flow=None):
try:
amp_order = int(sample['lal_amporder'])
except IndexError:
except (ValueError, IndexError):
amp_order = -1
params['amp_order'] = amp_order
try:
phase_order = int(sample['lal_pnorder'])
except IndexError:
except (ValueError, IndexError):
phase_order = -1
params['phase_order'] = phase_order
try:
approx = int(sample['lal_approximant'])
except IndexError:
except (ValueError, IndexError):
approx = ls.IMRPhenomPv2
params['approx'] = approx
if flow is None:
try:
flow = sample['flow']
except IndexError:
except (ValueError, IndexError):
flow = 30.
params['flow'] = flow
try:
fref = sample['f_ref']
except IndexError:
except (ValueError, IndexError):
fref = 30.
params['fref'] = fref
......@@ -111,7 +111,7 @@ def sample_to_waveform_params(sample, flow=None):
try:
dist = sample['distance']
except IndexError:
except (ValueError, IndexError):
dist = np.exp(sample['logdistance'])
dist *= 1E6 * ls.lal.PC_SI
......@@ -138,7 +138,7 @@ def sample_to_waveform_params(sample, flow=None):
try:
tilt1 = sample['tilt1']
tilt2 = sample['tilt2']
except IndexError:
except (ValueError, IndexError):
tilt1 = np.arccos(sample['costilt1'])
tilt2 = np.arccos(sample['costilt2'])
phi12 = sample['phi12']
......@@ -150,31 +150,31 @@ def sample_to_waveform_params(sample, flow=None):
phi12, a1, a2, m1, m2, fref)
# try the new (post-processing) convention for spin-aligned models
except ValueError:
except (ValueError, IndexError):
try:
s1z = sample['a1z']
s2z = sample['a2z']
# Maybe it's raw chain file where a1 is the a1z checked for above
except ValueError:
except (ValueError, IndexError):
try:
s1z = sample['a1']
s2z = sample['a2']
# It must be non-spinning
except ValueError:
except (ValueError, IndexError):
pass
try:
phase = sample['phi_orb']
except ValueError:
except (ValueError, IndexError):
phase = sample['phase_maxl']
print('WARNING: Samples already marginalized over phase.')
print(' Begrudgingly using max loglikelihood estimates.')
try:
time = sample['time']
except ValueError:
except (ValueError, IndexError):
time = sample['time_maxl']
print('WARNING: Samples already marginalized over time.')
print(' Begrudgingly using max loglikelihood estimates.')
......@@ -182,7 +182,7 @@ def sample_to_waveform_params(sample, flow=None):
# Check for spline calibration model
try:
spcal_active = sample['spcal_active']
except ValueError:
except (ValueError, IndexError):
spcal_active = False
spcal_params = ['spcal_active']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment