Fixing the log plot options (Fixes #7)
Build Debian Packages / build (bookworm, debian12) (push) Successful in 9m1s
Build Debian Packages / build (bullseye, debian11) (push) Successful in 7m14s
Build Debian Packages / build (trixie, debian13) (push) Successful in 8m33s

This commit is contained in:
2026-03-19 10:48:27 +01:00
parent 3d1d233658
commit 685a6ff8bd
2 changed files with 44 additions and 14 deletions
+21
View File
@@ -2,6 +2,9 @@
import threading
import numpy as np
#############################################################################
# #
# Name: Class Drawable #
@@ -136,6 +139,11 @@ class Drawable:
"Returns minimun of x"
return self.x.min()
def get_xminpos(self):
"Returns smallest positive value of x"
mask = self.x > 0
return self.x[mask].min()
def set_xmin(self, xmin):
"Sets minimum of x"
self.xmin = xmin
@@ -155,6 +163,19 @@ class Drawable:
else:
return self.y.min()
def get_yminpos(self):
"Returns smallest positive value of y"
if type(self.y) == type([]):
ymins = []
for ys in self.y:
mask = ys > 0
ymins.append(ys[mask].min())
ymin = min(ymins)
else:
mask = self.y > 0
ymin = y[mask].min()
return ymin
def set_ymin(self, ymin):
"Sets minimum of y"
self.ymin = ymin
+23 -14
View File
@@ -5,11 +5,9 @@ import math
import sys
import platform
import io
import codecs
import os.path
import traceback
import tables
import types
import xml.parsers.expat
import threading
import webbrowser
@@ -23,7 +21,8 @@ gi.require_version('GtkSource', '3.0')
# import 3rd party modules
# gui graphics
from gi.repository import GObject as gobject
import sqlite3,uuid
import sqlite3
import uuid
from gi.repository import Gtk as gtk
@@ -37,7 +36,6 @@ from gi.repository import GtkSource as gtksourceview2
gobject.type_register(gtksourceview2.View)
from gi.repository import Pango as pango
import cairo
# array math
import numpy
@@ -756,7 +754,7 @@ class DamarisGUI:
# create new dump file name
try:
self.dump_filename = actual_config.get( "data_pool_name" ) % extensions_dict
except ValueError as e:
except ValueError:
print("invalid formating character in '" + actual_config.get( "data_pool_name" ) + "'")
self.dump_filename = "DAMARIS_data_pool.h5"
print("reseting dumpfile to " + self.dump_filename)
@@ -1352,7 +1350,7 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
return 0
current_page = self.main_notebook.get_current_page( )
if not current_page in [ 0, 1 ]:
if current_page not in [ 0, 1 ]:
return 0
script = self.get_scripts( )[ current_page ]
try:
@@ -2441,7 +2439,7 @@ class MonitorWidgets:
register a listener and save reference to data
assume to be in gtk/gdk lock
"""
if not self.data_pool is None:
if self.data_pool is not None:
# maybe some extra cleanup needed
print("ToDo: cleanup widgets")
if self.displayed_data[ 1 ] is not None and hasattr( self.displayed_data[ 1 ], "unregister_listener" ):
@@ -2588,7 +2586,7 @@ class MonitorWidgets:
elif event.what == DataPool.Event.deleted_key:
# update combo-box by removing and rely on consistent information
gdk.threads_enter( )
if (not self.displayed_data[ 0 ] is None and
if (self.displayed_data[ 0 ] is not None and
self.displayed_data[ 0 ] == event.subject):
self.displayed_data = [ None, None ]
none_iter = self.source_list_find( [ 'None' ] )
@@ -2875,13 +2873,20 @@ class MonitorWidgets:
self.display_y_scaling_combobox.set_sensitive( True )
x_scale = self.display_x_scaling_combobox.get_active_text()
y_scale = self.display_y_scaling_combobox.get_active_text()
if x_scale == "lin":
self.matplot_axes.set_xscale("linear")
elif x_scale == "log10":
self.matplot_axes.set_xscale("log", basex=10, nonposx="mask")
self.matplot_axes.set_xscale("log", base=10, nonpositive="mask")
elif x_scale == "ppm":
self.matplot_axes.set_xscale("linear")
self.matplot_axes.invert_xaxis()
if y_scale == "lin":
self.matplot_axes.set_yscale("linear")
elif y_scale == "log10":
self.matplot_axes.set_yscale("log", base=10, nonpositive="mask")
if not hasattr( self, "__rescale" ):
self.__rescale = True
@@ -2930,8 +2935,11 @@ class MonitorWidgets:
if isinstance( in_result, Accumulation ) or isinstance( in_result, ADC_Result ):
xmin = in_result.get_xmin( )
xminpos = in_result.get_xminpos( )
xmax = in_result.get_xmax( )
ymin = in_result.get_ymin( )
yminpos = in_result.get_yminpos()
ymax = in_result.get_ymax( )
# # Check for log-scale
@@ -2955,20 +2963,21 @@ class MonitorWidgets:
self.matplot_axes.set_xscale( "linear" )
self.matplot_axes.set_xlim(xmin, xmax)
elif x_scale == "log10":
self.matplot_axes.set_xscale("log", basex=10, nonposx="mask")
self.matplot_axes.set_xlim(xmin, xmax)
self.matplot_axes.set_xscale("log", base=10, nonpositive="mask")
self.matplot_axes.set_xlim(xminpos, xmax)
elif x_scale == "ppm":
self.matplot_axes.set_xscale("linear")
self.matplot_axes.set_xlabel("PPM")
#self.display_autoscaling_checkbutton.set_active(True) #partial fix T141
self.matplot_axes.set_xlim(xmax, xmin)
#self.matplot_axes.invert_xaxis()
if y_scale == "lin":
self.matplot_axes.set_yscale( "linear" )
self.matplot_axes.set_ylim(ymin, ymax)
elif y_scale == "log10":
self.matplot_axes.set_yscale("log", basex=10, nonposy="mask")
#self.matplot_axes.set_xlim( xmin, xmax )
self.matplot_axes.set_ylim( ymin, ymax )
self.matplot_axes.set_yscale("log", base=10, nonpositive="mask")
self.matplot_axes.set_ylim( yminpos, ymax )
self.__rescale = False
# Autoscaling activated?