Compare commits

..

4 Commits

4 changed files with 106 additions and 85 deletions
BIN
View File
Binary file not shown.
+15 -12
View File
@@ -27,7 +27,7 @@ def mkdir_p(mypath):
pass pass
else: raise else: raise
fileName = "datav5.cff" fileName = "datav5.1.cff"
data = pd.read_pickle(fileName) data = pd.read_pickle(fileName)
binList = [10, 20, 30] binList = [10, 20, 30]
@@ -51,13 +51,13 @@ if(useTESS):
current = datetime.now() current = datetime.now()
date = f"{current.year}-{current.month}-{current.day}" date = f"{current.year}-{current.month}-{current.day}"
time = f"{current.hour}-{current.minute}-{current.second}" time = f"{current.hour}-{current.minute}-{current.second}"
folderPath = f"../{date}/" folderPath = f"../{date}-sine-poly/"
#folderPath = f"G:/Meine Ablage/Masterthesis/{date}/" #folderPath = f"G:/Meine Ablage/Masterthesis/{date}/"
mkdir_p(folderPath) mkdir_p(folderPath)
# remove any data that has no period # remove any data that has no period
#data = data[(data["FitType"] == "sine") | (data["FitType"] == "poly")] #data = data[(data["FitType"] == "sine") | (data["FitType"] == "poly")]
data = data[(data["FitType"] == "sine")] data = data[((data["FitType"] == "sine") | (data["FitType"] == "poly")) & (data["isValidFold"])]
validStarPeriodMap = [] validStarPeriodMap = []
starList = set(list(data["StarName"])) starList = set(list(data["StarName"]))
@@ -155,18 +155,19 @@ def plotFlarePeaks(plotdata, filters, labels, colors, maxY, title, filename):
if(isinstance(labels, list) and isinstance(colors, list)): if(isinstance(labels, list) and isinstance(colors, list)):
_, ((axFlarePeaks)) = plt.subplots(nrows=1, ncols=1) _, ((axFlarePeaks)) = plt.subplots(nrows=1, ncols=1)
for f, l, c in zip(filters, labels, colors): for f, l, c in zip(filters, labels, colors):
axFlarePeaks.scatter(plotdata[f]["PDCSAPNormPhase"], axFlarePeaks.scatter(plotdata[f]["PDCSAPNormPhase"] if "PDCSAPNormPhase" in plotdata[f].columns else plotdata[f]["PDCSAPNormPhasePeriod"],
plotdata[f]["Peak"], plotdata[f]["Peak"] if "Peak" in plotdata[f].columns else plotdata[f]["PeakPeriod"],
label=l, color=c) label=l, color=c)
elif(isinstance(labels, str) and isinstance(colors, str)): elif(isinstance(labels, str) and isinstance(colors, str)):
_, ((axFlarePeaks)) = plt.subplots(nrows=1, ncols=1) _, ((axFlarePeaks)) = plt.subplots(nrows=1, ncols=1)
if(filters is None): if(filters is None):
axFlarePeaks.scatter(plotdata[:]["PDCSAPNormPhase"], axFlarePeaks.scatter(plotdata[:]["PDCSAPNormPhase"] if "PDCSAPNormPhase" in plotdata[:].columns else plotdata[:]["PDCSAPNormPhasePeriod"],
plotdata[:]["Peak"],
plotdata[:]["Peak"] if "Peak" in plotdata[:].columns else plotdata[:]["PeakPeriod"],
label=labels, color=colors) label=labels, color=colors)
else: else:
axFlarePeaks.scatter(plotdata[filters]["PDCSAPNormPhase"], axFlarePeaks.scatter(plotdata[filters]["PDCSAPNormPhase"] if "PDCSAPNormPhase" in plotdata[filters].columns else plotdata[filters]["PDCSAPNormPhasePeriod"],
plotdata[filters]["Peak"], plotdata[filters]["Peak"] if "Peak" in plotdata[filters].columns else plotdata[filters]["PeakPeriod"],
label=labels, color=colors) label=labels, color=colors)
else: else:
return return
@@ -313,8 +314,8 @@ for starName in starDB.getAllStars():
else: else:
color = "gray" color = "gray"
PDCSAPdataList2dhistPhase.append(pdcsapbinningDataSpotModDiffPeriod[:]["PDCSAPNormPhase"]) PDCSAPdataList2dhistPhase.append(pdcsapbinningDataSpotModDiffPeriod[:]["PDCSAPNormPhasePeriod"])
PDCSAPdataList2dhistPeak.append(pdcsapbinningDataSpotModDiffPeriod[:]["Peak"]) PDCSAPdataList2dhistPeak.append(pdcsapbinningDataSpotModDiffPeriod[:]["PeakPeriod"])
xData, yData, PDCSAPdataList = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, PDCSAPdataList) xData, yData, PDCSAPdataList = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, PDCSAPdataList)
@@ -525,6 +526,7 @@ for comboLength in range(1, len(spType) + 1):
print(row["StarName"], "has over 100 peak") print(row["StarName"], "has over 100 peak")
csvFile.close() csvFile.close()
if(len(pdcsapbinningData) > 0):
pdcsapbinningData = pd.DataFrame(pdcsapbinningData) pdcsapbinningData = pd.DataFrame(pdcsapbinningData)
PDCSAPdataList = [] PDCSAPdataList = []
PDCSAPlabelList = [] PDCSAPlabelList = []
@@ -576,7 +578,7 @@ for comboLength in range(1, len(spType) + 1):
if(comboLength == 1): if(comboLength == 1):
mainSpType = combo[0] mainSpType = combo[0]
spTypes = [f"{mainSpType}0", f"{mainSpType}1", f"{mainSpType}2", f"{mainSpType}3", f"{mainSpType}4", f"{mainSpType}5", f"{mainSpType}6", f"{mainSpType}7", f"{mainSpType}8" f"{mainSpType}9"] spTypes = [f"{mainSpType}0", f"{mainSpType}1", f"{mainSpType}2", f"{mainSpType}3", f"{mainSpType}4", f"{mainSpType}5", f"{mainSpType}6", f"{mainSpType}7", f"{mainSpType}8", f"{mainSpType}9"]
match mainSpType: match mainSpType:
case "M": case "M":
color = "red" color = "red"
@@ -616,6 +618,7 @@ for comboLength in range(1, len(spType) + 1):
if(peak["FlarePeak"] > 100): if(peak["FlarePeak"] > 100):
print(row["StarName"], "has over 100 peak") print(row["StarName"], "has over 100 peak")
csvFile.close() csvFile.close()
if(len(pdcsapbinningData) > 0):
pdcsapbinningData = pd.DataFrame(pdcsapbinningData) pdcsapbinningData = pd.DataFrame(pdcsapbinningData)
PDCSAPdataList = [] PDCSAPdataList = []
PDCSAPlabelList = [] PDCSAPlabelList = []
+2
View File
@@ -150,6 +150,8 @@ def getFlareCount(filesDict):
filesDict["pdcsapPeriodFoldedPeaksPhasePair"] = pdcsapPeriodFoldedPeaksPhasePair filesDict["pdcsapPeriodFoldedPeaksPhasePair"] = pdcsapPeriodFoldedPeaksPhasePair
filesDict['periodFitType'] = optimizedFit["periodFitType"] filesDict['periodFitType'] = optimizedFit["periodFitType"]
filesDict["isValidFold"] = optimizedFit["isValid"]
csvFile = open(f"{starFolder}/{starNameR}_{source}-{sequence}.csv", "a") csvFile = open(f"{starFolder}/{starNameR}_{source}-{sequence}.csv", "a")
csvFile.write("StarName,Spectral Type,Rotational Velocity,Rotenional Velocity Unit,Distance,Distance Unit,Source,Sequence,File Path,Initial folded Fit Type,Used folded Fit Type") csvFile.write("StarName,Spectral Type,Rotational Velocity,Rotenional Velocity Unit,Distance,Distance Unit,Source,Sequence,File Path,Initial folded Fit Type,Used folded Fit Type")
csvFile.write(f"{filesDict['StarName']},{filesDict['SpType']},{filesDict['RotVel']},{filesDict['RotVelUnit']},{filesDict['Distance']},{filesDict['DistanceUnit']},{filesDict['Source']},{filesDict['Sequence']},{filesDict['FilePath']},{filesDict['FitType']},{optimizedFit['fitType']}") csvFile.write(f"{filesDict['StarName']},{filesDict['SpType']},{filesDict['RotVel']},{filesDict['RotVelUnit']},{filesDict['Distance']},{filesDict['DistanceUnit']},{filesDict['Source']},{filesDict['Sequence']},{filesDict['FilePath']},{filesDict['FitType']},{optimizedFit['fitType']}")
+18 -2
View File
@@ -429,7 +429,9 @@ def getOptimizedFold(normalizedLC, preferedFoldedFitType):
spotModulationBefore = spotModulation spotModulationBefore = spotModulation
if(len(fitMaximaArgs) > 1): if(len(fitMaximaArgs) > 1):
print("fitMaximaArgs > 1: ", fitMaximaArgs) print("fitMaximaArgs > 1: ", fitMaximaArgs)
if(len(fitMaximaArgs) == 2 and fitMaximaArgs[0] > len(phase)*0.1 and fitMaximaArgs[1] < len(phase)*0.1): print(fitMaximaArgs[0], len(phase)*0.1, fitMaximaArgs[1], len(phase)*0.9)
print(fitMaximaArgs[0] > len(phase)*0.1, fitMaximaArgs[1] < len(phase)*0.9)
if(len(fitMaximaArgs) == 2 and fitMaximaArgs[0] > len(phase)*0.1 and fitMaximaArgs[1] < len(phase)*0.9):
halfPeriod = period/2 halfPeriod = period/2
for lsP, blsP in zip(lsPeriods, blsPeriods): for lsP, blsP in zip(lsPeriods, blsPeriods):
if(abs(lsP.value - halfPeriod) < period*0.05): if(abs(lsP.value - halfPeriod) < period*0.05):
@@ -454,9 +456,23 @@ def getOptimizedFold(normalizedLC, preferedFoldedFitType):
fitMinimaArgs = argrelextrema(np.asarray(fit), np.less)[0] fitMinimaArgs = argrelextrema(np.asarray(fit), np.less)[0]
fitMinima = phase[0] fitMinima = phase[0]
fitMinimaArg = 0
newFitMinimaArgs = []
for args in fitMinimaArgs: for args in fitMinimaArgs:
if(abs(phase[args]) < abs(fitMinima)): print("Phases: ", fit[0], fit[len(phase)-1], fit[args])
if(fit[0] < fit[args] and fit[len(fit)-1] < fit[args]):
print("Found new minima")
newFitMinimaArgs.append(0)
newFitMinimaArgs.append(args)
newFitMinimaArgs = set(newFitMinimaArgs)
print(newFitMinimaArgs)
for args in newFitMinimaArgs:
if(abs(phase[args]) < abs(fitMinima) and fit[args] < fit[fitMinimaArg]):
fitMinima = phase[args] fitMinima = phase[args]
fitMinimaArg = args
if(abs(fitMinima) < phaseLength*0.01): if(abs(fitMinima) < phaseLength*0.01):
isValid = True isValid = True