CalcAllFlaresThread: add source to filename

This commit is contained in:
2024-11-28 10:00:56 +01:00
parent 447c353844
commit 53fcdc541e
+8 -7
View File
@@ -36,6 +36,7 @@ def getFlareCount(filesDict):
print(f"Starting {filesDict['StarName']}, {filesDict['Sequence']}") print(f"Starting {filesDict['StarName']}, {filesDict['Sequence']}")
starName = filesDict['StarName'] starName = filesDict['StarName']
starNameR = filesDict['StarName'].replace("*", "_star_") starNameR = filesDict['StarName'].replace("*", "_star_")
source = filesDict['Source']
sequence = filesDict['Sequence'] sequence = filesDict['Sequence']
starFolder = f"{folderPath}/stars/{starNameR}/" starFolder = f"{folderPath}/stars/{starNameR}/"
mkdir_p(starFolder) mkdir_p(starFolder)
@@ -66,13 +67,13 @@ def getFlareCount(filesDict):
lc.plot() lc.plot()
plt.title(f"{starName} - normalized lightcurve") plt.title(f"{starName} - normalized lightcurve")
plt.savefig(f"{starFolder}/{starNameR}_{sequence}-lc.png") plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-lc.png")
plt.close() plt.close()
flattenedLc = lc.flatten() flattenedLc = lc.flatten()
flattenedLc.plot() flattenedLc.plot()
plt.title(f"{starName} - flattened lightcurve") plt.title(f"{starName} - flattened lightcurve")
plt.savefig(f"{starFolder}/{starNameR}_{sequence}-flattened_lc.png") plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-flattened_lc.png")
plt.close() plt.close()
pdcsapPeaks, pdcsapFits = calculateFlareFitsForLightcurve(flattenedLc, normalizedLC=lc) pdcsapPeaks, pdcsapFits = calculateFlareFitsForLightcurve(flattenedLc, normalizedLC=lc)
@@ -82,7 +83,7 @@ def getFlareCount(filesDict):
plt.plot(p["FlarePeakTime"].value, lc.flux[p["StandardIndex"]], "x", color="red") plt.plot(p["FlarePeakTime"].value, lc.flux[p["StandardIndex"]], "x", color="red")
plt.plot([], [], "x", color="red", label="Flare peaks") plt.plot([], [], "x", color="red", label="Flare peaks")
plt.legend() plt.legend()
plt.savefig(f"{starFolder}/{starNameR}_{sequence}-lc-marked_flares.png") plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-lc-marked_flares.png")
plt.close() plt.close()
flattenedLc.plot() flattenedLc.plot()
@@ -94,7 +95,7 @@ def getFlareCount(filesDict):
plt.plot(p["FlarePeakTime"].value, p["FlarePeak"], "x", color="red") plt.plot(p["FlarePeakTime"].value, p["FlarePeak"], "x", color="red")
plt.plot([], [], "x", color="red", label="Flare peaks") plt.plot([], [], "x", color="red", label="Flare peaks")
plt.legend() plt.legend()
plt.savefig(f"{starFolder}/{starNameR}_{sequence}-flattened_lc-marked_flares.png") plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-flattened_lc-marked_flares.png")
plt.close() plt.close()
pdcsapValSec, pdcsapTds = getTotalValidDataInSeconds(lc, "pdcsap_flux") pdcsapValSec, pdcsapTds = getTotalValidDataInSeconds(lc, "pdcsap_flux")
@@ -104,7 +105,7 @@ def getFlareCount(filesDict):
pdcsapPeriodogram.plot(view="period") pdcsapPeriodogram.plot(view="period")
plt.plot(pdcsapPeakPeriod, pdcsapPeriodogram.power[maxPeriodIndex], "x", color="red") plt.plot(pdcsapPeakPeriod, pdcsapPeriodogram.power[maxPeriodIndex], "x", color="red")
plt.savefig(f"{starFolder}/{starNameR}_{sequence}-periodogram-marked_max.png") plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-periodogram-marked_max.png")
plt.close() plt.close()
pdcsapEpochTime = getEpochTime(lc) pdcsapEpochTime = getEpochTime(lc)
@@ -126,7 +127,7 @@ def getFlareCount(filesDict):
pdcsapFoldedLC.flux[pdcsapFoldedLC.cycle == cycle][foldedIndex], "x", color="red") pdcsapFoldedLC.flux[pdcsapFoldedLC.cycle == cycle][foldedIndex], "x", color="red")
plt.plot([], [], "x", color="red", label="Flare peaks") plt.plot([], [], "x", color="red", label="Flare peaks")
plt.legend() plt.legend()
plt.savefig(f"{starFolder}/{starNameR}_{sequence}-foldedLC-marked_fit_flares.png") plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-foldedLC-marked_fit_flares.png")
plt.close() plt.close()
@@ -161,7 +162,7 @@ def getFlareCount(filesDict):
filesDict["pdcsapPeriodMaxima"] = pdcsapMaxima filesDict["pdcsapPeriodMaxima"] = pdcsapMaxima
filesDict["pdcsapPeriodMaximaBoundaries"] = pdcsapmaxPhasesBounds filesDict["pdcsapPeriodMaximaBoundaries"] = pdcsapmaxPhasesBounds
csvFile = open(f"{starFolder}/{starNameR}_{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']},{pdcsapFitType}") csvFile.write(f"{filesDict['StarName']},{filesDict['SpType']},{filesDict['RotVel']},{filesDict['RotVelUnit']},{filesDict['Distance']},{filesDict['DistanceUnit']},{filesDict['Source']},{filesDict['Sequence']},{filesDict['FilePath']},{filesDict['FitType']},{pdcsapFitType}")
csvFile.close() csvFile.close()