From c7bd1e2836c94503874a9c80616d4e30ff29232f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Sch=C3=A4fer?= Date: Mon, 21 Feb 2022 09:51:33 +0100 Subject: [PATCH] Update to Version 19.0.1 --- CITATION.cff | 2 +- setup.py | 2 +- topasgraphsim/src/classes/dose_figure_handler.py | 15 +++++++++++++-- topasgraphsim/src/classes/main_viewer.py | 12 ++++++------ topasgraphsim/src/classes/nameandstyle.py | 1 + topasgraphsim/src/classes/recent_files.py | 7 ++----- topasgraphsim/src/classes/update.py | 2 +- topasgraphsim/src/functions/dp.py | 11 +++++++---- topasgraphsim/src/resources/info.py | 2 +- topasgraphsim/src/resources/language.py | 2 +- 10 files changed, 34 insertions(+), 22 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index b0a3bf9..db5efbd 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -21,5 +21,5 @@ keywords: - GUI - Python license: MIT -version: 19.0.0 +version: 19.0.1 date-released: '2022-02-20' diff --git a/setup.py b/setup.py index 7fb2a7a..3bb13ac 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="topasgraphsim", - version="19.0.0", + version="19.0.1", author="Sebastian Schäfer", author_email="sebastian.schaefer@student.uni-halle.de", description="GUI to plot the results of a topas simulation", diff --git a/topasgraphsim/src/classes/dose_figure_handler.py b/topasgraphsim/src/classes/dose_figure_handler.py index 27c1329..5eb7432 100644 --- a/topasgraphsim/src/classes/dose_figure_handler.py +++ b/topasgraphsim/src/classes/dose_figure_handler.py @@ -155,12 +155,23 @@ def add_plot_data(self, datanames): if self.plots[0].direction == "Z": self.half = False + print(self.normvalue) + for plotdata in self.plots: if self.norm == True: if self.normvalue == "max": plotdata.normpoint = max(plotdata.dose[self.half]) - elif self.normvalue == "flank": - plotdata.normpoint = max(plotdata.dose[self.half]) * 0.5 + elif self.normvalue == "plateau": + plotdata.normpoint = np.average( + [ + plotdata.dose[self.half][ + len(plotdata.dose[self.half]) // 2 + - 5 : len(plotdata.dose[self.half]) // 2 + + 5 + ] + ] + ) + else: plotdata.normpoint = plotdata.dose[self.half][ len(plotdata.dose) // 2 diff --git a/topasgraphsim/src/classes/main_viewer.py b/topasgraphsim/src/classes/main_viewer.py index 4e3bf42..3901bec 100644 --- a/topasgraphsim/src/classes/main_viewer.py +++ b/topasgraphsim/src/classes/main_viewer.py @@ -348,9 +348,9 @@ def __init__(self, parent): command=self.change_normalization, ) self.normalize_cascade.add_radiobutton( - label=self.text.flank[self.lang], + label=self.text.plateau[self.lang], variable=self.normvaluemenu, - value="flank", + value="plateau", command=self.change_normalization, ) self.normalize_cascade.add_radiobutton( @@ -922,8 +922,8 @@ def change_normalization(self): if self.normvaluemenu.get() == "max": self.DoseFigureHandler.normvalue = "max" - elif self.normvaluemenu.get() == "flank": - self.DoseFigureHandler.normvalue = "flank" + elif self.normvaluemenu.get() == "plateau": + self.DoseFigureHandler.normvalue = "plateau" else: self.DoseFigureHandler.normvalue = "center" @@ -1080,10 +1080,10 @@ def show_preview(self): self.parent.bind("", lambda boolean: self.change_order(False)) if len(self.DoseFigureHandler.plots) >= 2: - self.normmenu.entryconfig(14, state=tk.DISABLED) + self.normmenu.entryconfig(13, state=tk.DISABLED) if len(self.DoseFigureHandler.plots) == 2: - self.normmenu.entryconfig(14, state=tk.NORMAL) + self.normmenu.entryconfig(13, state=tk.NORMAL) if len(self.DoseFigureHandler.plots) > 5: self.parammenu.entryconfig(0, state=tk.DISABLED) diff --git a/topasgraphsim/src/classes/nameandstyle.py b/topasgraphsim/src/classes/nameandstyle.py index bd746d3..4628589 100644 --- a/topasgraphsim/src/classes/nameandstyle.py +++ b/topasgraphsim/src/classes/nameandstyle.py @@ -29,6 +29,7 @@ def __init__(self, parent, index) -> None: self.top.overrideredirect(1) self.top.bind("", self.submit) + self.top.bind("", self.top.destroy) self.enterlabel = ttk.Label( self.top, text=Text().changefilename[self.parent.lang] ) diff --git a/topasgraphsim/src/classes/recent_files.py b/topasgraphsim/src/classes/recent_files.py index 8ed8e8e..2ae1a56 100644 --- a/topasgraphsim/src/classes/recent_files.py +++ b/topasgraphsim/src/classes/recent_files.py @@ -17,13 +17,10 @@ def __init__(self, parent): pop = [] for i, x in enumerate([file[0] for file in self.recent_files]): - if os.path.exists(x) != True: + if os.path.exists(x) == True: pop.append(i) - for index, i in enumerate(pop): - self.recent_files.pop(i) - if index < len(pop) - 1: - pop[index + 1] -= 1 + self.recent_files = [self.recent_files[i] for i in pop] self.lambdas = [ lambda: self.add_recent_file_to_data(0), diff --git a/topasgraphsim/src/classes/update.py b/topasgraphsim/src/classes/update.py index bc9fd86..60870de 100644 --- a/topasgraphsim/src/classes/update.py +++ b/topasgraphsim/src/classes/update.py @@ -9,7 +9,7 @@ class CheckForUpdates: def __init__(self): - currentVersion = "19.0.0" + currentVersion = "19.0.1" try: newestVersion = requests.get( "https://api.github.com/repos/sebasj13/topasgraphsim/releases/latest" diff --git a/topasgraphsim/src/functions/dp.py b/topasgraphsim/src/functions/dp.py index f081ad5..15d3729 100644 --- a/topasgraphsim/src/functions/dp.py +++ b/topasgraphsim/src/functions/dp.py @@ -14,8 +14,6 @@ def calculate_parameters(axis, dose, cax=False): akima_dose_interpolator = interpolate.Akima1DInterpolator(axis, dose) interpolated_dose = np.flip(akima_dose_interpolator.__call__(interpolated_axis)) - Dose80 = [value for value in dose if value >= 0.8 * max(dose)] - D0 = ( interpolated_dose[int(len(interpolated_dose) / 2)] + interpolated_dose[int(len(interpolated_dose) / 2) - 1] @@ -74,6 +72,11 @@ def calculate_parameters(axis, dose, cax=False): HWB = round(abs(XR50 - XL50), 3) CAXdev = round(XL50 + 0.5 * HWB, 3) + + dose = [value + CAXdev for value in dose] + + Dose80 = [value for value in dose if value >= 0.8 * max(dose)] + if cax == True: return CAXdev @@ -97,8 +100,8 @@ def calculate_parameters(axis, dose, cax=False): 3, ) - Lpenumbra = round(abs(XL80 - XL20), 3) - Rpenumbra = round(abs(XR80 - XR20), 3) + Lpenumbra = round(abs(XL80 - XL20 + CAXdev), 3) + Rpenumbra = round(abs(XR80 - XR20 + CAXdev), 3) XL20index = np.where(interpolated_axis == XL20)[0][0] XL80index = np.where(interpolated_axis == XL80)[0][0] diff --git a/topasgraphsim/src/resources/info.py b/topasgraphsim/src/resources/info.py index 3b13f16..d5a9ddb 100644 --- a/topasgraphsim/src/resources/info.py +++ b/topasgraphsim/src/resources/info.py @@ -15,7 +15,7 @@ def __init__(self, parent, lang, mode): "de": "TopasGraphSim\n\nAutor: Sebastian Schäfer", "en": "TopasGraphSim\n\nAuthor: Sebastian Schäfer", } - version = {"de": "Version: 19.0.0\n ", "en": "Version: 19.0.0\n "} + version = {"de": "Version: 19.0.1\n ", "en": "Version: 19.0.1\n "} if mode == True: pic = "light" diff --git a/topasgraphsim/src/resources/language.py b/topasgraphsim/src/resources/language.py index d365289..1d4567a 100644 --- a/topasgraphsim/src/resources/language.py +++ b/topasgraphsim/src/resources/language.py @@ -61,7 +61,7 @@ def __init__(self): self.errorbars = {"de": "Fehlerbalken anzeigen", "en": "Show error bars"} self.errlimmenu = {"de": "Fehlergrenze einstellen", "en": "Change error limits"} self.file = {"de": "Datei", "en": "File"} - self.flank = {"de": "Flanke", "en": "Flank"} + self.plateau = {"de": "Plateau", "en": "Plateau"} self.fullscreen = {"de": "Vollbild", "en": "Fullscreen"} self.fwhm = {"de": "HWB", "en": "FWHM"} self.german = {"de": "Deutsch", "en": "German"}