From b6c194cb6e8e5105385fc27484055fc49c58b945 Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Sat, 31 May 2025 16:54:26 +0200 Subject: [PATCH] CalcAllFlaresThread: set proper plot description sizes --- main/astrodatagui/CalcAllFlaresThread.py | 26 +++++++++++++++------ main/astrodatagui/ui/FlaredetectorWidget.py | 4 ++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/main/astrodatagui/CalcAllFlaresThread.py b/main/astrodatagui/CalcAllFlaresThread.py index a29f4ae..d309693 100644 --- a/main/astrodatagui/CalcAllFlaresThread.py +++ b/main/astrodatagui/CalcAllFlaresThread.py @@ -15,6 +15,18 @@ from errno import EEXIST from os import makedirs, path from datetime import datetime +SMALL_SIZE = 16 +MEDIUM_SIZE = 18 +BIGGER_SIZE = 20 + +plt.rc('font', size=SMALL_SIZE) # controls default text sizes +plt.rc('axes', titlesize=MEDIUM_SIZE) # fontsize of the axes title +plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels +plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels +plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels +plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize +plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title + def mkdir_p(mypath): '''Creates a directory. equivalent to using mkdir -p on the command line''' @@ -48,13 +60,13 @@ def getFlareCount(filesDict): lc.plot() plt.title(f"{starName} - normalized lightcurve") - plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-lc.png") + plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-lc.png", bbox_inches="tight") plt.close() flattenedLc = lc.flatten() flattenedLc.plot() plt.title(f"{starName} - flattened lightcurve") - plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-flattened_lc.png") + plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-flattened_lc.png", bbox_inches="tight") plt.close() pdcsapPeaks, pdcsapFits = calculateFlareFitsForLightcurve(flattenedLc, normalizedLC=lc) @@ -64,7 +76,7 @@ def getFlareCount(filesDict): plt.plot(p["FlarePeakTime"].value, lc.flux[p["StandardIndex"]], "x", color="red") plt.plot([], [], "x", color="red", label="Flare peaks") plt.legend() - plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-lc-marked_flares.png") + plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-lc-marked_flares.png", bbox_inches="tight") plt.close() flattenedLc.plot() @@ -76,7 +88,7 @@ def getFlareCount(filesDict): plt.plot(p["FlarePeakTime"].value, p["FlarePeak"], "x", color="red") plt.plot([], [], "x", color="red", label="Flare peaks") plt.legend() - plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-flattened_lc-marked_flares.png") + plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-flattened_lc-marked_flares.png", bbox_inches="tight") plt.close() pdcsapValSec, pdcsapTds = getTotalValidDataInSeconds(lc, "pdcsap_flux") @@ -86,7 +98,7 @@ def getFlareCount(filesDict): pdcsapPeriodogram.plot(view="period") plt.plot(pdcsapPeakPeriod, pdcsapPeriodogram.power[maxPeriodIndex], "x", color="red") - plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-periodogram-marked_max.png") + plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-periodogram-marked_max.png", bbox_inches="tight") plt.close() #pdcsapEpochTime = getEpochTime(lc) @@ -108,7 +120,7 @@ def getFlareCount(filesDict): optimizedFit["foldedLC"].flux[optimizedFit["foldedLC"].cycle == cycle][foldedIndex], "x", color="red") plt.plot([], [], "x", color="red", label="Flare peaks") plt.legend() - plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-foldedLC-marked_fit_flares.png") + plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-foldedLC-marked_fit_flares.png", bbox_inches="tight") plt.close() if(optimizedFit["periodFoldedLC"] is not None): @@ -123,7 +135,7 @@ def getFlareCount(filesDict): optimizedFit["periodFoldedLC"].flux[optimizedFit["periodFoldedLC"].cycle == cycle][foldedIndex], "x", color="red") plt.plot([], [], "x", color="red", label="Flare peaks") plt.legend() - plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-periodFoldedLC-marked_fit_flares.png") + plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-periodFoldedLC-marked_fit_flares.png", bbox_inches="tight") plt.close() filesDict["pdcsapPeaks"] = pdcsapPeaks diff --git a/main/astrodatagui/ui/FlaredetectorWidget.py b/main/astrodatagui/ui/FlaredetectorWidget.py index 13a248a..59b4e3e 100644 --- a/main/astrodatagui/ui/FlaredetectorWidget.py +++ b/main/astrodatagui/ui/FlaredetectorWidget.py @@ -301,8 +301,8 @@ class FlaredetectorWidget(QtWidgets.QWidget): phase, sineFit, _ = getFoldedBestFit(lc, fitType=self.foldedFitType) self.figureAxis.plot(phase, sineFit, color="red") print(phase, sineFit) - minPhasesBoundsIndices, maxPhasesBoundsIndices = getPhaseRangesNearPeak(getFoldedFitPeakValley(sineFit), phase) - plotPhaseRangesNearPeak((minPhasesBoundsIndices, maxPhasesBoundsIndices), phase, ax=self.figureAxis) + #minPhasesBoundsIndices, maxPhasesBoundsIndices = getPhaseRangesNearPeak(getFoldedFitPeakValley(sineFit), phase) + #plotPhaseRangesNearPeak((minPhasesBoundsIndices, maxPhasesBoundsIndices), phase, ax=self.figureAxis) except Exception as e: print("Failed to get fit") print(e)