Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
QUANTITY.VALUE: ''
}])[0][QUANTITY.VALUE] == 'Ia'):
source = sncosmo.get_source('salt2', version='2.4')
model = sncosmo.Model(source=source)
mredchisq = np.inf
fm = None
for zmin in np.linspace(0.0, 1.0, 19):
zmax = zmin + 0.1 # Overlapping intervals
try:
resl, fml = sncosmo.fit_lc(
table,
model, ['z', 't0', 'x0', 'x1', 'c'],
bounds={'z': (zmin, zmax)})
except RuntimeError:
continue
except sncosmo.fitting.DataQualityError:
break
if resl.ndof < 15:
continue
redchiq = resl.chisq / resl.ndof
if (redchiq < mredchisq and redchiq < 2.0 and not np.isclose(
zmin, fml.get('z'), rtol=1.0e-3) and not np.isclose(
zmax, fml.get('z'), rtol=1.e-3)):
mredchisq = resl.chisq
res, fm = resl, fml
if fm:
print(event, res.chisq / res.ndof,
fm.get('z'),
catalog.entries[event][SUPERNOVA.REDSHIFT][0]['value']
if SUPERNOVA.REDSHIFT in catalog.entries[event] else
'no redshift')