Skip to content

Commit

Permalink
Added more host fractions.
Browse files Browse the repository at this point in the history
Fixed bug in calculating rlap if flux array is zero.
  • Loading branch information
daniel-muthukrishna committed May 19, 2018
1 parent 58f8dea commit 3cc9c7d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dash/create_and_save_all_data_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


if __name__ == '__main__':
modelName = 'zeroZ_trainOnAll'
modelName = 'zeroZ_trainOnAll_morehostfracs'
trainWithHost = True
classifyHost = False
minZ = 0.
Expand Down
2 changes: 1 addition & 1 deletion dash/create_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def combined_sn_gal_arrays_multiprocessing(self, snTemplateLocation, snTempFileL
snFractions = [1.0]
else:
galTempList = temp_list(galTempFileList)
snFractions = [0.99, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1]
snFractions = [0.99, 0.98, 0.95, 0.93, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1]

snTempList = temp_list(snTempFileList)
galAndSnTemps = list(itertools.product(galTempList, snTempList))
Expand Down
15 changes: 10 additions & 5 deletions dash/false_positive_rejection.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,17 @@ def _cross_correlation(self, templateFlux, templateMinMaxIndex):
# plt.plot(self.zAxis, np.correlate(templateFlux, templateFlux, mode='Full')[::-1][512-shift:1536-shift]/max(np.correlate(templateFlux, templateFlux, mode='Full')))

crossCorr = np.correlate(self.inputFlux, templateFlux, mode='Full')[::-1][int(self.nw/2):int(self.nw + self.nw/2)]/max(np.correlate(self.inputFlux, templateFlux, mode='Full'))
deltapeak, h = self._get_peaks(crossCorr)[0]
shift = int(deltapeak - self.nw / 2)
autoCorr = np.correlate(templateFlux, templateFlux, mode='Full')[::-1][int(self.nw/2)-shift:int(self.nw + self.nw/2)-shift]/max(np.correlate(templateFlux, templateFlux, mode='Full'))

aRandomFunction = crossCorr - autoCorr
rmsA = np.std(aRandomFunction)
try:
deltapeak, h = self._get_peaks(crossCorr)[0]
shift = int(deltapeak - self.nw / 2)
autoCorr = np.correlate(templateFlux, templateFlux, mode='Full')[::-1][int(self.nw/2)-shift:int(self.nw + self.nw/2)-shift]/max(np.correlate(templateFlux, templateFlux, mode='Full'))

aRandomFunction = crossCorr - autoCorr
rmsA = np.std(aRandomFunction)
except IndexError as err:
print("Error: Cross-correlation is zero, probably caused by empty spectrum.", err)
rmsA = 1

return xCorr, rmsInput, rmsTemp, xCorrNorm, rmsXCorr, xCorrNormRearranged, rmsA

Expand Down

0 comments on commit 3cc9c7d

Please sign in to comment.