Skip to content
Snippets Groups Projects
Commit 78123d2e authored by Wolf Widdra's avatar Wolf Widdra
Browse files

new trial to include changes by Hannes Herrmann

parent e1359625
No related branches found
No related tags found
No related merge requests found
......@@ -15,12 +15,12 @@ hhPath = os.path.dirname(__file__)
from libhreels.HREELS import HREELS, myPath
from datetime import datetime
import argparse
# import libhreels.expLogbook as lgb
import libhreels.NoExpLogbook as lgb
import libhreels.expLogbook as lgb
# import libhreels.NoExpLogbook as lgb
# fix HighRes Displays
# QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
# QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
class HREELS_Window(QtWidgets.QMainWindow):
""" fill in some initial data """
......@@ -33,12 +33,13 @@ class HREELS_Window(QtWidgets.QMainWindow):
self.offset = 0.1
self.useOffset = False
self.normalized = False
self.Areanormalized = False
self.comment = comment
self.showComment = lgb.available
if datapath and os.path.exists(datapath):
self.datapath = datapath
else:
self.datapath = "./"
self.datapath = './'
self.directory = self.datapath
if remoteDir and os.path.exists(remoteDir):
self.remoteDir = remoteDir
......@@ -78,6 +79,8 @@ class HREELS_Window(QtWidgets.QMainWindow):
# Action on user events
self.ui.checkBoxWideScans.toggled.connect(self.onWideScans)
self.ui.checkBoxNormalized.toggled.connect(self.onNormalized)
self.ui.checkBoxAreaNormalization.toggled.connect(self.onAreaNormalized)
self.ui.checkBoxOffset.toggled.connect(self.onUseOffset)
self.ui.checkBoxMarker.toggled.connect(self.onMarkerSet)
self.ui.checkBoxComment.toggled.connect(self.onCommentSet)
......@@ -143,9 +146,16 @@ class HREELS_Window(QtWidgets.QMainWindow):
def onNormalized(self):
'''Routine called by toggling "Normalized": If set, all spectra will be normalized to a maximum
count rate of unity. It will trigger a data window update.'''
self.ui.checkBoxAreaNormalization.setChecked(False)
self.normalized = self.ui.checkBoxNormalized.isChecked()
self.onFileSelection()
def onAreaNormalized(self):
'''Routine called by toggling "Area Normalized": If set, all spectra will be normalized to a sum of counts between -100 to 1000cm^-1 (or less if the dataset is shorter). It will trigger a data window update.'''
self.ui.checkBoxNormalized.setChecked(False)
self.Areanormalized = self.ui.checkBoxAreaNormalization.isChecked()
self.onFileSelection()
def onActionDir(self):
'''Routine calls Directory Selection Interface upon Menu selection. It will
create a data list from the chosen directory.'''
......@@ -290,7 +300,7 @@ class HREELS_Window(QtWidgets.QMainWindow):
self.d = HREELS(firstItem.text(),self.datapath)
if self.d.valid:
plotColor = plt.cm.gnuplot(0) # Define the color map (coolwarm; plasma; inferno; gnuplot)
self.updatePlot(xmin=self.xmin, factor=self.factor, normalized=self.normalized, color=plotColor)
self.updatePlot(xmin=self.xmin, factor=self.factor, normalized=self.normalized, Areanormalized=self.Areanormalized, color=plotColor)
try:
self.dialog.ui.textArea.setPlainText(self.d.infoText())
except:
......@@ -305,7 +315,7 @@ class HREELS_Window(QtWidgets.QMainWindow):
for item in myList: # Add here sorting according to ...
plotColor = plt.cm.gnuplot(i/iMax) # Define the color map (coolwarm; plasma; inferno; gnuplot)
self.d = HREELS(item.text(),self.datapath)
self.secondPlot(xmin=self.xmin, factor=self.factor, normalized=self.normalized, offset=i*self.offset*self.useOffset, color=plotColor)
self.secondPlot(xmin=self.xmin, factor=self.factor, normalized=self.normalized, Areanormalized=self.Areanormalized,offset=i*self.offset*self.useOffset, color=plotColor)
# print(i, item.text())
i += 1
# Reversing the sequence of labels in the legend:
......@@ -341,17 +351,17 @@ class HREELS_Window(QtWidgets.QMainWindow):
return
def updatePlot(self,xmin=70, factor=10, normalized=False, color="red"):
def updatePlot(self,xmin=70, factor=10, normalized=False, Areanormalized=False, color="red"):
'''Plotting the first of the selected spectra. '''
self.drawing_pane.axes.cla()
self.plotWidget(normalized=normalized,showComment=False)
self.plotWidget(xmin=xmin, factor=factor, color=color, label='x %3i'%factor, normalized=normalized, showComment=self.showComment)
self.plotWidget(normalized=normalized, Areanormalized=Areanormalized, showComment=False)
self.plotWidget(xmin=xmin, factor=factor, color=color, label='x %3i'%factor, normalized=normalized, Areanormalized=Areanormalized, showComment=self.showComment)
def secondPlot(self,xmin=70, factor=10, normalized=False, offset = 0., color="b-"):
def secondPlot(self,xmin=70, factor=10, normalized=False, Areanormalized=False, offset = 0., color="b-"):
'''Plotting the second and all further selected spectra. '''
self.plotWidget(xmin=xmin, factor=factor, color=color, label=self.d.fname, normalized=normalized, offset = offset)
self.plotWidget(xmin=xmin, factor=factor, color=color, label=self.d.fname, normalized=normalized, Areanormalized=Areanormalized, offset = offset)
def plotWidget(self, xmin=None, xmax=None, factor=1, label='x', normalized=False, color="black",
def plotWidget(self, xmin=None, xmax=None, factor=1, label='x', normalized=False, Areanormalized=False, color="black",
marker=True, offset = 0., showComment=False):
''' plot(self, xmin=None, xmax=None, factor=1, label='x', normalized=False, color="b-",marker=True)'''
self.d.pFactor = factor
......@@ -365,6 +375,19 @@ class HREELS_Window(QtWidgets.QMainWindow):
nend = len(self.d.xdata)
if normalized:
factor /= self.d.maxIntensity
Areanormalized = False # just in case
elif Areanormalized:
try:
areanormalize_xstart = np.argmin(abs(self.d.xdata+100.)) #seems to be oddly complicated, but is way more stable than x.index(-100.)
except:
areanormalize_xstart = 0
try:
areanormalize_xend = np.argmin(abs(self.d.xdata-1000.))
except:
areanormalize_xend = len(self.d.xdata)
factor /= self.d.ydata[areanormalize_xstart:areanormalize_xend].sum()
#print("Area normalization in x[", self.d.xdata[areanormalize_xstart],":",self.d.xdata[areanormalize_xend],"] is used.")
if label == "x":
label = self.d.fname
self.drawing_pane.axes.plot(self.d.xdata[nstart:nend], factor*self.d.ydata[nstart:nend] + offset, color=color, label=label)
......@@ -373,8 +396,11 @@ class HREELS_Window(QtWidgets.QMainWindow):
self.drawing_pane.axes.set_xlabel('Energy Loss (cm$^{-1}$)')
if normalized:
self.drawing_pane.axes.set_ylabel('Normalized Intensity')
else:
elif Areanormalized:
self.drawing_pane.axes.set_ylabel('Area Normalized Intensity')
else:
self.drawing_pane.axes.set_ylabel('Intensity (s$^{-1}$)')
if marker:
for (x,y) in self.d.marker:
self.d.setMarker(x,y*factor)
......
No preview for this file type
No preview for this file type
......@@ -179,6 +179,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxAreaNormalization">
<property name="text">
<string>Area Normalization</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxOffset">
<property name="text">
......
This diff is collapsed.
[tool.poetry]
name = "libhreels"
version = "1.2.0"
version = "1.4.0"
description = "Handling, simulating, and plotting HREELS and Auger spectroscopy data"
authors = ["Wolf Widdra <wolf.widdra@physik.uni-halle.de>"]
include = ["*./libhreels/*"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment