def rlap_warning_label(self, bestType, inputImage, inputMinMaxIndex): host, name, age = classification_split(bestType) snInfos, snNames, hostInfos, hostNames = get_templates( name, age, host, self.snTemplates, self.galTemplates, self.nw) if snInfos != []: if self.rlapScores: templateImages = snInfos[:, 1] templateMinMaxIndexes = list(zip(snInfos[:, 2], snInfos[:, 3])) rlapCalc = RlapCalc(inputImage, templateImages, snNames, self.wave, inputMinMaxIndex, templateMinMaxIndexes) rlap, rlapWarningBool = rlapCalc.rlap_label() if rlapWarningBool: rlapLabel = "Low rlap: {0}".format(rlap) else: rlapLabel = "Good rlap: {0}".format(rlap) else: rlapLabel = "No rlap" rlapWarningBool = "None" else: rlapLabel = "(NO_TEMPLATES)" rlapWarningBool = "None" # import matplotlib # matplotlib.use('TkAgg') # import matplotlib.pyplot as plt # plt.plot(inputImage) # plt.plot(templateImage) # plt.show() return rlapLabel, rlapWarningBool
def calc_redshift(self, inputFlux, snName, snAge, inputMinMaxIndex): host = "No Host" snInfos, snNames, hostInfos, hostNames = get_templates( snName, snAge, host, self.snTemplates, self.galTemplates, self.nw) numOfSubTemplates = len(snNames) templateNames = snNames templateFluxes = [] templateMinMaxIndexes = [] for i in range(numOfSubTemplates): templateFluxes.append(snInfos[i][1]) templateMinMaxIndexes.append((snInfos[i][2], snInfos[i][3])) redshift, crossCorr, medianName = get_median_redshift( inputFlux, templateFluxes, self.nw, self.dwlog, inputMinMaxIndex, templateMinMaxIndexes, templateNames, outerVal=0.5) print(redshift) if redshift is None: return 0, np.zeros(1024) return round(redshift, 4), crossCorr
def get_sn_and_host_templates(self, snName, snAge, hostName): snInfos, snNames, hostInfos, hostNames = get_templates( snName, snAge, hostName, self.snTemplates, self.galTemplates, self.nw) return snInfos, snNames, hostInfos, hostNames