def inferParams(snid, snmodel, paramsDF, lcsDF, infer_method=sncosmo.fit_lc, minsnr=0.): """ infer the parameters for the ith supernova in the simulation """ pdict, ra, dec = paramDict(snid, paramsDF) snmodel.setCoords(ra, dec) snmodel.mwEBVfromMaps() snmodel.set(**pdict) truth = copy(snmodel.equivalentSNCosmoModel()) #.copy() #print(model) #z = params.ix[snid, 'z'] lcinstance = LightCurve(lcsDF.query('snid==@snid')) fig = None try: print('trying fit') resfit = infer_method(lcinstance.snCosmoLC(), snmodel.equivalentSNCosmoModel(), vparam_names=['t0', 'x0', 'x1', 'c'], modelcov=False, minsnr=minsnr) #, bounds=dict(z=(0.0001, 1.6))) reschar = ResChar.fromSNCosmoRes(resfit) print('fit passed') except: reschar = 'failure' print('failed for SNID {0} with {1} points'.format( snid, len(lcinstance.snCosmoLC()))) #if reschar != 'failure': # pass # fig = None#sncosmo.plot_lc(lcinstance.snCosmoLC(), model=(truth, reschar.sncosmoModel)) return snid, lcinstance, reschar, truth, fig
def inferParams3(snanaSims3, model3, infer_method3, i, minsnr=3.): """ infer the parameters for the ith supernova in the simulation """ snid3 = snanaSims3.headData.index.values[i] z3 = snanaSims3.headData.ix[snid3, 'REDSHIFT_FINAL'] lcinstance = snanaSims3.get_SNANA_photometry(snid=snid3) model3.set(z=z3) print(z3) resfit3 = infer_method3(lcinstance.snCosmoLC(), model3, vparam_names=['t0', 'x0', 'x1', 'c'], modelcov=True, minsnr=minsnr) reschar3 = ResChar.fromSNCosmoRes(resfit3) return snid3, reschar3
def inferParams2(snanaSims2, model2, infer_method2, i, minsnr=3.): """ infer the parameters for the ith supernova in the simulation """ snid2 = snanaSims2.headData.index.values[i] z2 = snanaSims2.headData.ix[snid2, 'REDSHIFT_FINAL'] lcinstance = snanaSims2.get_SNANA_photometry(snid=snid2) model2.set(z=z2) print(z2) resfit2 = infer_method2(lcinstance.snCosmoLC(), model2, vparam_names=['t0', 'x0', 'x1', 'c'], modelcov=True, minsnr=minsnr) reschar2 = ResChar.fromSNCosmoRes(resfit2) return snid2, reschar2
def inferParams1(snanaSims1, model1, infer_method1, i, minsnr=3.): """ infer the parameters for the ith supernova in the simulation """ snid1 = snanaSims1.headData.index.values[i] z1 = snanaSims1.headData.ix[snid1, 'REDSHIFT_FINAL'] lcinstance = snanaSims1.get_SNANA_photometry(snid=snid1) model1.set(z=z1) print(z1) resfit1 = infer_method1(lcinstance.snCosmoLC(), model1, vparam_names=['t0', 'x0', 'x1', 'c'], modelcov=True, minsnr=minsnr) reschar1 = ResChar.fromSNCosmoRes(resfit1) return snid1, reschar1
def inferParams(snanaSims, model, infer_method, i, minsnr=3.): """ infer the parameters for the ith supernova in the simulation """ snid = snanaSims.headData.index.values[i] z = snanaSims.headData.ix[snid, 'REDSHIFT_FINAL'] lcinstance = snanaSims.get_SNANA_photometry(snid=snid) model.set(z=z) print(z) resfit = infer_method(lcinstance.snCosmoLC(), model, vparam_names=['t0', 'x0', 'x1', 'c'], modelcov=True, minsnr=minsnr) reschar = ResChar.fromSNCosmoRes(resfit) return snid, reschar