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