diff --git a/Python code/libhreels/HREELS.py b/Python code/HREELS.py similarity index 100% rename from Python code/libhreels/HREELS.py rename to Python code/HREELS.py diff --git a/Python code/libhreels/__init__.py b/Python code/__init__.py similarity index 100% rename from Python code/libhreels/__init__.py rename to Python code/__init__.py diff --git a/Python code/libhreels/calcHREELS.py b/Python code/calcHREELS.py similarity index 100% rename from Python code/libhreels/calcHREELS.py rename to Python code/calcHREELS.py diff --git a/Python code/libhreels/calcHREELS3.png b/Python code/calcHREELS3.png similarity index 100% rename from Python code/libhreels/calcHREELS3.png rename to Python code/calcHREELS3.png diff --git a/Python code/libhreels/calcHREELS4.png b/Python code/calcHREELS4.png similarity index 100% rename from Python code/libhreels/calcHREELS4.png rename to Python code/calcHREELS4.png diff --git a/Python code/libhreels/dielectrics.py b/Python code/dielectrics.py similarity index 100% rename from Python code/libhreels/dielectrics.py rename to Python code/dielectrics.py diff --git a/Python code/dist/libhreels-2.1.1-py3-none-any.whl b/Python code/dist/libhreels-2.1.1-py3-none-any.whl deleted file mode 100644 index f2a0fbacd237ab9d758ec240d13d233245339106..0000000000000000000000000000000000000000 Binary files a/Python code/dist/libhreels-2.1.1-py3-none-any.whl and /dev/null differ diff --git a/Python code/dist/libhreels-2.1.1.tar.gz b/Python code/dist/libhreels-2.1.1.tar.gz deleted file mode 100644 index 57db58bf7cf5cc78dcc6d24c48a58cad65533858..0000000000000000000000000000000000000000 Binary files a/Python code/dist/libhreels-2.1.1.tar.gz and /dev/null differ diff --git a/Python code/libhreels Wolf b/Python code/libhreels Wolf deleted file mode 100644 index f2b17a60ab7a2674f14c968cac94314b2b2a2944..0000000000000000000000000000000000000000 Binary files a/Python code/libhreels Wolf and /dev/null differ diff --git a/Python code/libhreels/Auger.py b/Python code/libhreels/Auger.py deleted file mode 100755 index 5af1393dd2a706c3511587025bfa63a09b4299b8..0000000000000000000000000000000000000000 --- a/Python code/libhreels/Auger.py +++ /dev/null @@ -1,184 +0,0 @@ -#!/usr/bin/python -# Auger library Version 0.1 (December 2018 @ WFW) -# -import numpy as np -import re -import matplotlib.pyplot as plt -from scipy import optimize, interpolate -from datetime import datetime -from datetime import timedelta -from matplotlib.transforms import offset_copy -# from pylab import figure -from matplotlib.pyplot import figure -import os - -def offset(ax, x, y): - return offset_copy(ax.transData, x=x, y=y, units='dots') - -def Auger_elog_Dictionary(file, path): - spec = Auger(file,datapath=path) - dic = {'Category':'Auger', 'Type':'Auger', 'Substrate':'as before', - 'Summary':'%5.0f'% spec.xmin +'-'+'%-5.0f'% spec.xmax, - 'Temperature':'', 'File':str(file), - 'Scan_Range':'%5.0f'% spec.xmin +','+'%5.0f'% spec.xmax, - 'N_channels':'%4d'%spec.totalTime, 'MDate':spec.startTimeEpoch, - 'Author':'Python Script'} - return dic - -class Auger: - """This class handles Auger data and their plotting.""" - path = "./" - def __init__(self, _filename, datapath=path): - self.datapath = datapath - self.readDataFile(_filename) - self.Auger = interpolate.interp1d(self.xdata, self.ydata, kind='linear') - # self.Auger = interp1d(self.xdata, self.ydata, kind='nearest') - - def readDataFile(self, _filename): - # if _filename.find(".") == -1: - # _filename +=".aes" - self.filename = _filename - # self.fname = self.filename[0:self.filename.find(".")] - self.fname = _filename - xdata = [] - ydata = [] - import glob - f = glob.glob(self.datapath+"**/"+self.filename, recursive=True) - if len(f) == 0: - print('Error: No files found!') - print('Not found:',self.filename) - return - f = glob.glob(self.datapath+"**/"+self.filename, recursive=True)[0] - self.datapath = os.path.dirname(f) - self.startTime = datetime.fromtimestamp(os.path.getmtime(f)) # Only the file saving time - self.startTimeEpoch = os.path.getmtime(f) - with open(f, 'r') as f: - for line in f: - str_x, str_d, str_y = line.split() - # print(str_x, str_y) - try: - xdata.append(float(str_x)) - ydata.append(float(str_y)) - except: - xdata.append(float(str_x.replace(",","."))) - ydata.append(float(str_y.replace(",","."))) - self.xdata = np.array(xdata) - self.ydata = np.array(ydata) - self.xmin = self.xdata[0] - self.xmax = self.xdata[-1] - self.deltay = max(ydata)-min(ydata) - self.ymax = max(ydata) - self.totalTime = 1.0 * len(self.xdata) - self.marker = [] - self.valid = True - - - def __str__(self): - return self.datapath+self.filename - - def info(self): - print("filename: \t\t",self.filename) - print("datapath: \t\t",self.datapath) - print("startTime: \t\t",self.startTime) - print("xmin: \t\t\t","%6.1f"%self.xmin,"eV") - print("xmax: \t\t\t","%6.1f"%self.xmax,"eV") - if len(self.marker)>0: - print("marker: \t\t") - for each in self.marker: - print("\t\t%6.1f\t %8.1f"%each) - print('--------') - - def infoText(self): - langtext = "filename: \t\t"+self.filename+'\n' - langtext +="datapath: \t\t"+self.datapath+'\n' - langtext +="startTime: \t\t"+str(self.startTime)+'\n' - langtext +="xmin: \t\t\t"+"%6.1f"%self.xmin+" eV"+'\n' - langtext +="xmax: \t\t\t"+"%6.1f"%self.xmax+" eV"+'\n' - if len(self.marker)>0: - langtext +="marker: \t\t"+'\n' - for each in self.marker: - langtext +="\t\t%6.1f\t %8.1f"%each+'\n' - langtext +='--------' - return langtext - - - def findIndex(self, kinEnergy): - for i in range(len(self.xdata)): - if self.xdata[i] > kinEnergy: - return i - print('Auger.findIndex: kinEnergy', kinEnergy, 'not found in xdata') - return len(self.xdata)-1 - - def plot(self, xmin=None, xmax=None, label='x', color="b-",marker=True, offset=0.): - ''' plot(self, xmin=None, xmax=None, label='x', normalized=False, color="b-",marker=True,offset=0.)''' - if xmin: - nstart = self.findIndex(xmin) - else: - nstart = 0 - if xmax: - nend = self.findIndex(xmax) - else: - nend = len(self.xdata) - if label == "x": - label = self.filename - plt.plot(self.xdata[nstart:nend], self.ydata[nstart:nend]+offset, color, label=label) - plt.xlabel('Kinetic Energy (eV)') - plt.ylabel('dN/dE (arb. u.)') - plt.legend() - if marker: - for (x,y) in self.marker: - self.setMarker(x,y) - return - - def pickMarker(self): - def onclick(event): - # print('%s click: button=%d, x=%d, y=%d, xdata=%f, ydata=%f' % - # ('double' if event.dblclick else 'single', event.button, - # event.x, event.y, event.xdata, event.ydata)) - if event.button ==1: - self.marker.append((event.xdata, event.ydata)) - self.setMarker(event.xdata, event.ydata) - self.fig.canvas.draw() - else: - self.marker = [] - print("All marker deleted!") - self.fig.canvas.draw() - self.fig.canvas.mpl_connect('button_press_event', onclick) - self.ax.set_title('Pick marker with left mouse button ... (right:erase all)') - - def figure(self): - self.fig=figure() - self.ax=self.fig.add_subplot(111) - - def show(self): - plt.show() - - def selectData(self,x1, x2=None): - """Returns the data as (x,y) list between - x1 and x2. If x2 is omitted the full range is used.""" - if not x2: - x2 = self.xmax - a = self.findIndex(x1) - b = self.findIndex(x2)+1 - return self.data[a:b] - - def setMarker(self, x, y, ymin=0, size=None): - trans = offset(self.ax, 0, 10) - plt.plot([x,x],[y,self.ymax-0.2*self.deltay], lw=1, c='b', ls='dashed') - x = round(x*10)/10. - plt.text(x,self.ymax-0.2*self.deltay,'%5.1f' % x, rotation=90, - verticalalignment='bottom', horizontalalignment='center', transform=trans) - return - - -if __name__ == '__main__': - path = 'D:\Data\Python\Auger\data' - d1 = Auger("181207_A_01",datapath=path) - d2 = Auger("190207_A_02",datapath=path) - dy=0. - d2.info();d2.plot(color='m-');dy-=0.5 - d1.info();d1.plot(offset=dy);dy-=0.5 - d2.show() - - import code - code.interact(local=locals()) diff --git a/Python code/libhreels/LEED.py b/Python code/libhreels/LEED.py deleted file mode 100755 index 196238c32148e7f2a0344366acf2a772a6b97a2d..0000000000000000000000000000000000000000 --- a/Python code/libhreels/LEED.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/python -# LEED library Version 0.1 (July 2019 @ WFW) -# -import numpy as np -import re -import matplotlib.pyplot as plt -from scipy import optimize, interpolate -from datetime import datetime -from datetime import timedelta -from matplotlib.transforms import offset_copy -# from pylab import figure -from matplotlib.pyplot import figure -import cv2 -import os - -def offset(ax, x, y): - return offset_copy(ax.transData, x=x, y=y, units='dots') - -def LEED_elog_Dictionary(file, path): - spec = LEED(file,datapath=path) - dic = {'Category':'LEED', 'Type':'LEED', 'Substrate':'as before', - 'Summary':spec.energy+' eV', - 'Temperature':'', 'File':str(file), - 'Scan_Range':'', 'Energy':spec.energy, - 'N_channels':'', 'MDate':spec.startTimeEpoch, - 'Author':'Python Script'} - return dic - -class LEED: - """This class handles LEED data and their plotting.""" - path = "./" - def __init__(self, _filename, datapath=path): - self.datapath = datapath - self.readDataFile(_filename) - - def readDataFile(self, _filename): - # if _filename.find(".") == -1: - # _filename +=".aes" - self.filename = _filename - self.fname = self.filename[0:self.filename.find(".")] - import glob - f = glob.glob(self.datapath+"**/"+self.filename, recursive=True) - if len(f) == 0: - print('Error: No files found!') - print('Not found:',self.filename) - return - f = glob.glob(self.datapath+"**/"+self.filename, recursive=True)[0] - self.datapath = os.path.dirname(f) - self.startTime = datetime.fromtimestamp(os.path.getmtime(f)) # Only the file saving time - self.startTimeEpoch = os.path.getmtime(f) - match = re.search(r"\_(\d*)eV",self.fname) - self.energy = match.group(1) - self.picture = cv2.imread(f) - - def __str__(self): - return self.datapath+self.filename - - def info(self): - print("filename: \t\t",self.filename) - print("datapath: \t\t",self.datapath) - print("startTime: \t\t",self.startTime) - print("energy: \t\t",self.energy) - print('--------') - - def plot(self): - new_pic = self.picture - # Pmin = min(new_pic.all()) - # Pmax = max(new_pic.any()) - # new_pic = (new_pic-Pmin)/(Pmax-Pmin)*255 - cv2.imshow('LEED'+self.fname,new_pic) - cv2.waitKey(0) - cv2.destroyAllWindows() - -if __name__ == '__main__': - path = 'D:\Data\Python\LEED' - d1 = LEED("190122_L_01_42eV.tif",datapath=path) - - d1.info() - d1.plot() - - import code - code.interact(local=locals()) diff --git a/Python code/libhreels/NoExpLogbook.py b/Python code/libhreels/NoExpLogbook.py deleted file mode 100755 index 5eff614bdb0e57f92c1051faed13a3b79c7565c7..0000000000000000000000000000000000000000 --- a/Python code/libhreels/NoExpLogbook.py +++ /dev/null @@ -1,2 +0,0 @@ -available = False - diff --git a/Python code/libhreels/ViewAuger.py b/Python code/libhreels/ViewAuger.py deleted file mode 100755 index 7e02fa08d99e954d02ab31c4fa4e0addcff5ceaf..0000000000000000000000000000000000000000 --- a/Python code/libhreels/ViewAuger.py +++ /dev/null @@ -1,406 +0,0 @@ -#!/usr/bin/env python3 -import os -import re -import sys - -import matplotlib.pyplot as plt -import numpy as np -from datetime import datetime -import argparse -from matplotlib.backends.backend_qt5agg import \ - FigureCanvasQTAgg as FigureCanvas -from matplotlib.backends.backend_qt5agg import \ - NavigationToolbar2QT as NavigationToolbar -from PyQt5 import QtCore, QtGui, QtWidgets, uic -import libhreels as hh -hhPath = hh.__path__[0] -from libhreels.Auger import Auger - -# fix HighRes Displays -# QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) -# QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) - - -class Auger_Window(QtWidgets.QMainWindow): - """ fill in some initial data """ - - def __init__(self,datapath= None, remoteDir=None, startWithFile=None): - super(Auger_Window, self).__init__() - f = os.path.join(hhPath,"viewauger.ui") - self.ui = self.ui = uic.loadUi(f, self) - self.xmin = 10. - self.factor = 1. - self.offset = 0.5 - self.useOffset = False - self.normalized = False - if datapath and os.path.exists(datapath): - self.datapath = datapath - else: - self.datapath = "\\\\141.48.167.189\\BackUp02\\0_experiments\\EELS-PC4\\AES" - if remoteDir and os.path.exists(remoteDir): - self.remoteDir = remoteDir - else: - self.remoteDir = '\\\\141.48.167.189\\BackUp02\\0_experiments\\EELS-PC4\\Auger' - self.wideScan = True - self.marker = [] - # self.markerSet = False - - # initialize the widget "drawWidget" and attach it into the ui - self.drawing_figure = plt.figure(frameon=False,figsize=(5, 4), dpi=150, tight_layout = True) - self.drawing_pane = FigureCanvas(self.drawing_figure) - self.drawing_figure.canvas.setFocusPolicy(QtCore.Qt.ClickFocus) - self.drawing_figure.canvas.setFocus() - # self.drawing_figure.canvas.mpl_connect('button_press_event', self.onMouse) - self.drawing_pane.axes = self.drawing_pane.figure.add_subplot(111) - self.ui.drawWidget.layout().addWidget(self.drawing_pane) - # Add toolbar - self.xToolbar = NavigationToolbar(self.drawing_pane, self) - self.ui.drawWidget.layout().addWidget(self.xToolbar) - self.xToolbar.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)) - - self.ui.lineEdit_directory.setText(self.datapath) - self.ui.lineEdit_factor.setText('%4.1f'%(self.factor)) - self.ui.lineEdit_offset.setText('%4.1f'%(self.offset)) - - # Action on user events - self.ui.checkBoxOffset.toggled.connect(self.onUseOffset) - self.ui.checkBoxMarker.toggled.connect(self.onMarkerSet) - self.ui.pushButton_details.pressed.connect(self.onPushButton_details3) - self.ui.lineEdit_factor.editingFinished.connect(self.onFactor) - self.ui.lineEdit_offset.editingFinished.connect(self.onOffset) - self.ui.lineEdit_directory.editingFinished.connect(self.onNewDirectory) - - # Create list of all datafiles in the directory - self.createFileList() - self.ui.listWidget.itemSelectionChanged.connect(self.onFileSelection) - self.dataDir = QtWidgets.QFileDialog(self) - if os.name == 'nt': - self.dataDir.setDirectory("D:\\Data\\Python\\HREELS\\expHREELS\\data") - else: - self.dataDir.setDirectory("/mnt/d/Data/Python/HREELS/expHREELS/data") - - # Action on user menu events: - self.action_directory.triggered.connect(self.onActionDir) - self.action_test.triggered.connect(self.onActionTest) - self.action_help.triggered.connect(self.onActionHelp) - - #Add a cursor: - self.cursor = Cursor(self.drawing_pane, self.drawing_pane.axes) - # self.cursorId = self.drawing_figure.canvas.mpl_connect('motion_notify_event', self.cursor.mouse_move) - if startWithFile: - self.selectFile(startWithFile) - - - - def onFactor(self): - try: - val = float(self.ui.lineEdit_factor.text()) - self.factor = val - except ValueError: - self.ui.lineEdit_factor.setText('%4.1f'%(self.factor)) - self.onFileSelection() - - def onUseOffset(self): - self.useOffset = self.ui.checkBoxOffset.isChecked() - self.onOffset() - - def onOffset(self): - try: - val = float(self.ui.lineEdit_offset.text()) - self.offset = val - except ValueError: - self.ui.lineEdit_offset.setText('%4.1f'%(self.offset)) - self.onFileSelection() - - def onNormalized(self): - self.normalized = self.ui.checkBoxNormalized.isChecked() - self.onFileSelection() - - def onActionDir(self): - # self.dataDir.setDirectory("D:\\Data\\Python\\expHREELS\\data") - directory = self.openDirectoryDialog() - if directory: - self.ui.lineEdit_directory.setText(directory) - self.directory = directory - self.ui.listWidget.clear() - self.datapath = directory - self.createFileList() - - def onNewDirectory(self): - dirText = self.ui.lineEdit_directory.text() - if os.path.exists(dirText): - self.directory = self.ui.lineEdit_directory.text() - self.ui.listWidget.clear() - self.datapath = self.directory - self.createFileList() - else: - self.ui.lineEdit_directory.setText('') - - - def onActionTest(self): - self.dataDir.setDirectory(self.remoteDir) - directory = self.openDirectoryDialog() - if directory: - self.ui.lineEdit_directory.setText(directory) - self.directory = directory - self.ui.listWidget.clear() - self.datapath = directory - self.createFileList() - - def onActionHelp(self): - pass - msg = QtWidgets.QMessageBox() - msg.setText(''' - This is the Auger data browser of the Martin-Luther University Halle-Wittenberg - (Version 0.5) designed for fast data screening and plotting. - Copyright @ wolf.widdra@physik.uni-halle.de. - ''') - msg.setWindowTitle("Auger data browser help") - # msg.setStandardButtons(QtWidgets.QMessageBox.Ok) - layout = msg.layout() - widget = QtWidgets.QWidget() - widget.setFixedSize(650, 1) - layout.addWidget(widget, 3, 0, 1, 3) - msg.buttonClicked.connect(self.onOK) - msg.exec_() - - def onPushButton_details(self): - try: - details = self.d.infoText() - except: - return - msg = QtWidgets.QMessageBox() - msg.setText(details) - msg.setWindowTitle("Dataset details") - msg.setStandardButtons(QtWidgets.QMessageBox.Ok) - layout = msg.layout() - widget = QtWidgets.QWidget() - widget.setFixedSize(650, 1) - layout.addWidget(widget, 3, 0, 1, 3) - msg.buttonClicked.connect(self.onOK) - msg.exec_() - - def onPushButton_details3(self): - """Shows a dialog containing data details""" - self.dialog = QtWidgets.QDialog(self) - f = os.path.join(hhPath, "viewhreels_dialog.ui") - self.dialog.ui = uic.loadUi(f, self.dialog) - self.dialog.ui.setWindowTitle('Dataset details') - self.dialog.ui.textArea.setPlainText(self.d.infoText()) - self.dialog.show() - - def onMarkerSet(self): - b = self.ui.checkBoxMarker.isChecked() - self.markerSet = b - if not b: - # Disconnect all mouse events from canvas: - self.drawing_figure.canvas.mpl_disconnect(self.cursorId) - self.drawing_figure.canvas.mpl_disconnect(self.canvasId) - else: - # Connect all mouse events from canvas to routines: - self.cursorId = self.drawing_figure.canvas.mpl_connect('motion_notify_event', self.cursor.mouse_move) - self.canvasId = self.drawing_figure.canvas.mpl_connect('button_press_event', self.onMouse) - print('mouse enabled') - - def onOK(self, button): - print("Button pressed is:",button.text()) - - - def selectFile(self, file): - '''Select the file within the QListWidget by then program, e.g. as start parameter. - Make sure before that it exists. The file extension is dropped by re.split. ''' - itm = self.ui.listWidget.findItems(re.split('\.',file)[0], QtCore.Qt.MatchExactly) - self.ui.listWidget.setCurrentItem(itm[0]) - return - - - def onFileSelection(self): - iMax = len(self.ui.listWidget.selectedItems()) - if iMax == 0: - return - firstItem = self.ui.listWidget.selectedItems()[0] - self.d = Auger(firstItem.text(),self.datapath) - if iMax > 1: # Remember the last plot size if there are already plots - # Read xmin, xmax for current window and set these values for added spectra: - self.xdmin, self.xdmax = self.drawing_pane.axes.get_xlim() - 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.ydmin, _ = self.drawing_pane.axes.get_ylim() - - try: - self.dialog.ui.textArea.setPlainText(self.d.infoText()) - except: - pass - - if iMax > 1: - i = 1. - for item in self.ui.listWidget.selectedItems()[1:]: - plotColor = plt.cm.gnuplot(i/iMax) # Define the color map (coolwarm; plasma; inferno; gnuplot) - self.d = Auger(item.text(),self.datapath) - self.secondPlot(xmin=self.xmin, factor=self.factor, normalized=self.normalized, offset=i*self.offset*self.useOffset, color=plotColor) - # print(i, item.text()) - i += 1 - # Reversing the sequence of labels in the legend: - handles, labels = self.drawing_pane.axes.get_legend_handles_labels() - self.drawing_pane.axes.legend(handles[::-1], labels[::-1]) - # self.drawing_pane.axes.set_ylim(bottom=0.) - self.drawing_figure.tight_layout() - self.cursor = Cursor(self.drawing_pane, self.drawing_pane.axes) - self.drawing_figure.canvas.mpl_connect('motion_notify_event', self.cursor.mouse_move) - self.drawing_pane.draw() - - def onMouse(self, event): - if not self.markerSet: - return - if (event.xdata): - if event.button==1: - x,y = event.xdata, event.ydata - print(x,y) - self.marker.append((x,y)) - self.setMarker(x,y,self.ydmin) - elif event.button==3: - pass - self.drawing_pane.draw() - - def setMarker(self, x, y, ymin=0, size=None): - ''' Set vertical marker with text label. Note that self.figure() needs to be - called before use.''' - # trans = offset(self.ax, 0, 30) - self.drawing_pane.axes.plot([x,x],[ymin,y], lw=1, c='black', ls='dashed') - x = round(x) - # plt.text(x,y,'%4i' % x, rotation=90, verticalalignment='bottom', horizontalalignment='center', transform=trans) - self.drawing_pane.axes.text(x,y,'%4i' % x, rotation=90, verticalalignment='bottom', horizontalalignment='center') - return - - - def updatePlot(self,xmin=10, factor=1, normalized=False, color="red"): - self.drawing_pane.axes.cla() - # self.plotWidget(normalized=normalized) - self.plotWidget(factor=factor, color=color, normalized=normalized) - - def secondPlot(self,xmin=70, factor=1, normalized=False, offset = 0., color="b-"): - self.secondPlotWidget(xmin=xmin, xdmin=self.xdmin, xdmax=self.xdmax, factor=factor, color=color, label=self.d.fname, normalized=normalized, offset = offset) - - def plotWidget(self, xmin=None, xmax=None, factor=1, label='x', normalized=False, color="black",marker=True, offset = 0.): - ''' plot(self, xmin=None, xmax=None, factor=1, label='x', normalized=False, color="b-",marker=True)''' - self.d.pFactor = factor - if xmin: - nstart = self.d.findIndex(xmin) - else: - nstart = 0 - if xmax: - nend = self.d.findIndex(xmax) - else: - nend = len(self.d.xdata) - 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) - self.d.factor = factor - self.drawing_pane.axes.set_xlabel('Kinetic Energy (eV)') - self.drawing_pane.axes.set_ylabel('Intensity (arb. units)') - if marker: - for (x,y) in self.d.marker: - self.d.setMarker(x,y*factor) - return - - def secondPlotWidget(self, xmin=None, xmax=None, xdmin=None, xdmax=None, factor=1, label='x', normalized=False, color="black",marker=True, offset = 0.): - ''' plot(self, xmin=None, xmax=None, factor=1, label='x', normalized=False, color="b-",marker=True)''' - self.d.pFactor = factor - if xmin: - nstart = self.d.findIndex(xmin) - else: - nstart = 0 - if xmax: - nend = self.d.findIndex(xmax) - else: - nend = len(self.d.xdata) - 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) - self.drawing_pane.axes.set_xlim(xdmin, xdmax) - self.d.factor = factor - return - - def getFileList(self, directory): - '''Get the list of all Auger data files. The list is - sorted by the file creation date.''' - list = os.listdir(directory) - files = [] - for file in list: - location = os.path.join(directory, file) - size = os.path.getsize(location) - time = os.path.getmtime(location) - files.append((file, time, size)) - files.sort(key=lambda s: -s[1]) # sort by time - fileNames = [item[0] for item in files] - # SElect the specific Auger data files: E.g. 181207_A_01 - # AESFiles = [fn for fn in fileNames if (fn[6:9]=='_A_')] - AESFiles = [] - for fn in fileNames: - if (fn[6:9]=='_A_'): - AESFiles.append(fn) - elif re.search('^[1-3][0-9][0-1][0-9][0-3][0-9]_', fn): - AESFiles.append(fn) - return AESFiles, len(AESFiles) - - def createFileList(self): - for item in self.getFileList(self.datapath)[0]: - fname = re.split('\.',item)[0] - self.ui.listWidget.addItem(fname) - - def openDirectoryDialog(self): - self.dataDir = QtWidgets.QFileDialog(self) - options = self.dataDir.Options() - # options = self.dataDir.ShowDirsOnly - options |= self.dataDir.DontUseNativeDialog - dir =self.dataDir.getExistingDirectory(self, 'Select data directory', options=options) - if dir: - return dir - -class Cursor(object): - def __init__(self, fig, ax): - self.figure = fig - self.ax = ax - self.ly = ax.axvline(color='r') # the vert line - - def mouse_move(self, event): - if not event.inaxes: - return - self.ly.set_data([event.xdata, event.xdata], [0, 1]) - self.figure.draw() - -def runViewer(datapath= None, remoteDir=None, startWithFile=None): - """ Main function for graphical application start """ - app = QtWidgets.QApplication(sys.argv) - form = Auger_Window(datapath= datapath, remoteDir=remoteDir, startWithFile=startWithFile) - form.show() - sys.exit(app.exec_()) - -################# Command line handling ###################### -def validDate(string): - date = datetime.strptime(string, "%Y-%m-%d") - return date -def is_valid_file(string): - if not os.path.exists(string): - parser.error("The file %s does not exist!" % string) - return False - else: - return string - -def myMain(): - parser = argparse.ArgumentParser() - # parser.add_argument("-v", "--verbosity", type=int, choices=[0, 1, 2],help="increase output verbosity") - parser.add_argument("-s", "--start", help="Start date (2018-01-01)", default='2019-01-01', type=validDate) - #parser.add_argument("-e", "--end", help="End date and time (2018-01-01_08:00)", type=validDate, required=True) - parser.add_argument("-f", "--file", help="Start viewer with this datafile", type=is_valid_file) - args = parser.parse_args() - if args.file: - fPath,fName = os.path.split(args.file) - # print(">>> ", fPath, " <<< ", fName) - else: - fPath = "." - fName = None - - runViewer(datapath=fPath, startWithFile=fName) -if __name__ == '__main__': - myMain() \ No newline at end of file diff --git a/Python code/libhreels/ViewHREELS.py b/Python code/libhreels/ViewHREELS.py deleted file mode 100755 index 570b18807e39bce94f8785b9200d6bb3972a46ad..0000000000000000000000000000000000000000 --- a/Python code/libhreels/ViewHREELS.py +++ /dev/null @@ -1,475 +0,0 @@ -#!/usr/bin/env python3 -import os -import re -import sys - -import matplotlib.pyplot as plt -import numpy as np -from matplotlib.backends.backend_qt5agg import \ - FigureCanvasQTAgg as FigureCanvas -from matplotlib.backends.backend_qt5agg import \ - NavigationToolbar2QT as NavigationToolbar -from PyQt5 import QtCore, QtGui, QtWidgets, uic -import libhreels as hh -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 - -# fix HighRes Displays -# 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 """ - def __init__(self,datapath=None, remoteDir=None, startWithFile=None, comment=None): - super(HREELS_Window, self).__init__() - f = os.path.join(hhPath,"viewhreels.ui") # path to the package directory. Needed to find graphical user interface files (*.ui) - self.ui = self.ui = uic.loadUi(f, self) - self.xmin = 50. - self.factor = 10. - self.offset = 0.1 - self.useOffset = False - self.normalized = False - self.comment = comment - self.showComment = lgb.available - if datapath and os.path.exists(datapath): - self.datapath = datapath - else: - self.datapath = "./" - self.directory = self.datapath - if remoteDir and os.path.exists(remoteDir): - self.remoteDir = remoteDir - else: - self.remoteDir = '//141.48.167.189/BackUp02/0_experiments/EELS-PC4/HREELS/gph_dat/' - self.wideScan = True - self.marker = [] - # self.markerSet = False - - # initialize the widget "drawWidget" and attach it into the ui - self.drawing_figure = plt.figure(frameon=False,figsize=(5, 4), dpi=150, tight_layout = True) - self.drawing_pane = FigureCanvas(self.drawing_figure) - self.drawing_figure.canvas.setFocusPolicy(QtCore.Qt.ClickFocus) - self.drawing_figure.canvas.setFocus() - # self.drawing_figure.canvas.mpl_connect('button_press_event', self.onMouse) - self.drawing_pane.axes = self.drawing_pane.figure.add_subplot(111) - self.ui.drawWidget.layout().addWidget(self.drawing_pane) - - #Add a cursor: - self.cursor = Cursor(self.drawing_pane, self.drawing_pane.axes) - # self.cursorId = self.drawing_figure.canvas.mpl_connect('motion_notify_event', self.cursor.mouse_move) - - # Add toolbar - self.xToolbar = NavigationToolbar(self.drawing_pane, self) - self.ui.drawWidget.layout().addWidget(self.xToolbar) - self.xToolbar.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)) - - self.ui.lineEdit_directory.setText(self.datapath) - self.ui.lineEdit_xmin.setText('%4.1f'%self.xmin) - self.ui.lineEdit_factor.setText('%4.1f'%(self.factor)) - self.ui.lineEdit_offset.setText('%4.1f'%(self.offset)) - self.ui.checkBoxWideScans.setChecked(True) - self.ui.checkBoxComment.setChecked(lgb.available) - # self.ui.listWidget.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection) - - - # Action on user events - self.ui.checkBoxWideScans.toggled.connect(self.onWideScans) - self.ui.checkBoxNormalized.toggled.connect(self.onNormalized) - self.ui.checkBoxOffset.toggled.connect(self.onUseOffset) - self.ui.checkBoxMarker.toggled.connect(self.onMarkerSet) - self.ui.checkBoxComment.toggled.connect(self.onCommentSet) - self.ui.pushButton_details.clicked.connect(self.onPushButton_details) - self.ui.lineEdit_xmin.editingFinished.connect(self.onXmin) - self.ui.lineEdit_factor.editingFinished.connect(self.onFactor) - self.ui.lineEdit_offset.editingFinished.connect(self.onOffset) - self.ui.lineEdit_directory.editingFinished.connect(self.onNewDirectory) - self.ui.listWidget.itemSelectionChanged.connect(self.onFileSelection) - - # Action on user menu events: - self.action_directory.triggered.connect(self.onActionDir) - self.action_test.triggered.connect(self.onActionTest) - self.action_help.triggered.connect(self.onActionHelp) - self.actionFile_info.triggered.connect(self.onPushButton_details) - - # Create list of all datafiles in the directory - self.createFileList() - self.dataDir = QtWidgets.QFileDialog(self) - if os.name == 'nt': - self.dataDir.setDirectory("D:\\Data\\Python\\HREELS\\expHREELS\\data") - else: - self.dataDir.setDirectory("/mnt/d/Data/Python/HREELS/expHREELS/data") - - if startWithFile: - self.selectFile(startWithFile) - - - def onXmin(self): - '''Routine called by a new value of "Xmin". It will trigger a data window update.''' - try: - val = float(self.ui.lineEdit_xmin.text()) - self.xmin = val - except ValueError: - self.ui.lineEdit_xmin.setText('%4.1f'%self.xmin) - self.onFileSelection() - - def onFactor(self): - '''Routine called by a new value of "Factor", which defines the amplification factor for the energy loss - region (larger than Xmin). It will trigger a data window update.''' - try: - val = float(self.ui.lineEdit_factor.text()) - self.factor = val - except ValueError: - self.ui.lineEdit_factor.setText('%4.1f'%(self.factor)) - self.onFileSelection() - - def onUseOffset(self): - '''Routine called by toggling "Use Offset": If set, the energy loss - region (larger than Xmin) will be vertically offseted if multiple spectra are selected. - It will trigger a data window update.''' - self.useOffset = self.ui.checkBoxOffset.isChecked() - self.onOffset() - - def onOffset(self): - try: - val = float(self.ui.lineEdit_offset.text()) - self.offset = val - except ValueError: - self.ui.lineEdit_offset.setText('%4.1f'%(self.offset)) - self.onFileSelection() - - 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.normalized = self.ui.checkBoxNormalized.isChecked() - self.onFileSelection() - - def onActionDir(self): - '''Routine calls Directory Selection Interface upon Menu selection. It will - create a data list from the chosen directory.''' - # if os.name == 'nt': - # self.dataDir.setDirectory("D:\\Data\\Python\\HREELS\\expHREELS\\data") - # else: - # self.dataDir.setDirectory("/mnt/d/Data/Python/HREELS/expHREELS/data") - directory = self.openDirectoryDialog() - if directory: - self.ui.lineEdit_directory.setText(directory) - self.directory = directory - self.ui.listWidget.clear() - self.datapath = directory - self.createFileList() - - def onNewDirectory(self): - '''Routine called if Directory field is modified. It will - create a data list from the chosen new directory (but only if it exists).''' - dirText = self.ui.lineEdit_directory.text() - tt = myPath(dirText) - print('New directory: ',tt) - self.directoryOld = self.directory - if os.path.exists(tt): - self.directory = tt - self.ui.listWidget.clear() - self.datapath = self.directory - self.createFileList() - else: - self.ui.lineEdit_directory.setText(self.directoryOld) - - - def onActionTest(self): - '''Routine called by Menu item 'Test'. It is for playing - with future options.''' - self.dataDir.setDirectory(self.remoteDir) - directory = self.openDirectoryDialog() - if directory: - self.ui.lineEdit_directory.setText(directory) - self.directory = directory - self.ui.listWidget.clear() - self.datapath = directory - self.createFileList() - - def onActionHelp(self): - pass - msg = QtWidgets.QMessageBox() - msg.setText(''' - This is the HREELS data browser of the Martin-Luther University Halle-Wittenberg - (Version 0.9) designed for fast data screening and plotting. - Copyright @ wolf.widdra@physik.uni-halle.de. - ''') - msg.setWindowTitle("HREELS data browser help") - # msg.setStandardButtons(QtWidgets.QMessageBox.Ok) - layout = msg.layout() - widget = QtWidgets.QWidget() - widget.setFixedSize(650, 1) - layout.addWidget(widget, 3, 0, 1, 3) - msg.buttonClicked.connect(self.onOK) - msg.exec_() - - def onPushButton_details(self): - """Routine for showing a dialog window containing HREELS data details""" - try: - self.d.infoText() - except: - return - self.dialog = QtWidgets.QDialog(self) - f = os.path.join(hhPath,"viewhreels_dialog.ui") - self.dialog.ui = uic.loadUi(f, self.dialog) - self.dialog.ui.setWindowTitle('Dataset details') - self.dialog.ui.textArea.setPlainText(self.d.infoText()) - self.dialog.show() - - def onMarkerSet(self): - '''Routine called if selection "Set Marker" is toggled. It allows to draw dashed vertical lines - with the energy loss values. The value 'self.markerSet' is used to decide later if lines have to be drawn.''' - b = self.ui.checkBoxMarker.isChecked() - self.markerSet = b - if not b: - # Disconnect all mouse events from canvas: - self.drawing_figure.canvas.mpl_disconnect(self.cursorId) - self.drawing_figure.canvas.mpl_disconnect(self.canvasId) - else: - # Connect all mouse events from canvas to routines: - self.cursorId = self.drawing_figure.canvas.mpl_connect('motion_notify_event', self.cursor.mouse_move) - self.canvasId = self.drawing_figure.canvas.mpl_connect('button_press_event', self.onMouse) - print('mouse enabled') - - def onCommentSet(self): - '''Routine called if selection "Show Comment" is toggled. It allows to draw dashed vertical lines - with the energy loss values. The value 'self.markerSet' is used to decide later if lines have to be drawn.''' - self.showComment = self.ui.checkBoxComment.isChecked() - # print('onCommentSet:', lgb.available, self.showComment, self.ui.listWidget.selectedItems()[0].text()) - if self.showComment: - if lgb.available: - text = lgb.logbook.getShortMessage4File(self.d.fname) - ids = lgb.logbook.search({'file':self.d.fname}) - if len(ids) > 0: - _, attributes, _ = lgb.logbook.read(ids[0]) - print(self.d.fname, ids[0],': ', attributes['Date'],'\t',text[:-2]) - else: - text = self.comment if self.comment else '' - self.comment = None - self.pCom = self.drawing_pane.axes.text(0.12, 0.98,text, ha='left', va='top', transform=self.drawing_pane.axes.transAxes) - else: - try: - self.pCom.remove() - except: - pass - - def onOK(self, button): - print("Button pressed is:",button.text()) - - def onWideScans(self): - '''Routine called if selection "Only wide scans" is toggled. The switch 'self.wideScan' decides - if all spectra or only spectra with a wider energy range (data files larger than 21 kB) - are listed on the left side.''' - b = self.ui.checkBoxWideScans.isChecked() - self.wideScan = b - self.ui.listWidget.clear() - self.createFileList() - - def selectFile(self, file): - '''Select the file within the QListWidget by the program, e.g. as start parameter. - Make sure before that it exists. The file extension is dropped by re.split. ''' - matchingItems = self.ui.listWidget.findItems(re.split('\.',file)[0], QtCore.Qt.MatchExactly) - self.ui.listWidget.setCurrentItem(matchingItems[0]) - for it in matchingItems: - it.setSelected(True) - self.ui.listWidget.setFocus() - return - - def onFileSelection(self): - '''Routine called if user makes a file selection or changes the file selection within the left list. - The selected spectra are plotted according to the given flags (Xmin, Factor, Normalized, Offset). ''' - iMax = len(self.ui.listWidget.selectedItems()) - if iMax == 0: - return - # print([it.text() for it in self.ui.listWidget.selectedItems()]) - firstItem = self.ui.listWidget.selectedItems()[0] - - 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) - try: - self.dialog.ui.textArea.setPlainText(self.d.infoText()) - except: - pass - else: - self.drawing_pane.axes.cla() - self.drawing_pane.draw() - return - if iMax > 1: - i = 1. - myList = self.ui.listWidget.selectedItems()[1:] - 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) - # print(i, item.text()) - i += 1 - # Reversing the sequence of labels in the legend: - handles, labels = self.drawing_pane.axes.get_legend_handles_labels() - self.drawing_pane.axes.legend(handles[::-1], labels[::-1]) - self.drawing_pane.axes.set_ylim(bottom=0.) - self.drawing_figure.tight_layout() - self.cursor = Cursor(self.drawing_pane, self.drawing_pane.axes) - self.drawing_figure.canvas.mpl_connect('motion_notify_event', self.cursor.mouse_move) - self.drawing_pane.draw() - - def onMouse(self, event): - if not self.markerSet: - return - if (event.xdata): - if event.button==1: - x,y = event.xdata, event.ydata - print(x,y) - self.marker.append((x,y)) - self.setMarker(x,y) - elif event.button==3: - pass - self.drawing_pane.draw() - - def setMarker(self, x, y, ymin=0, size=None): - ''' Set vertical marker with text label. Note that self.figure() needs to be - called before use.''' - # trans = offset(self.ax, 0, 30) - self.drawing_pane.axes.plot([x,x],[ymin,y], lw=1, c='black', ls='dashed') - x = round(x) - # plt.text(x,y,'%4i' % x, rotation=90, verticalalignment='bottom', horizontalalignment='center', transform=trans) - self.drawing_pane.axes.text(x,y,'%4i' % x, rotation=90, verticalalignment='bottom', horizontalalignment='center') - return - - - def updatePlot(self,xmin=70, factor=10, normalized=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) - - def secondPlot(self,xmin=70, factor=10, normalized=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) - - def plotWidget(self, xmin=None, xmax=None, factor=1, label='x', normalized=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 - if xmin: - nstart = self.d.findIndex(xmin) - else: - nstart = 0 - if xmax: - nend = self.d.findIndex(xmax) - else: - nend = len(self.d.xdata) - if normalized: - factor /= self.d.maxIntensity - 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) - self.d.factor = factor - if showComment: self.onCommentSet() - self.drawing_pane.axes.set_xlabel('Energy Loss (cm$^{-1}$)') - if normalized: - self.drawing_pane.axes.set_ylabel('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) - return - - def getFileList(self, directory, sizeMin=0.): - '''Get the list of all *.gph or *.GPH data files with a file size larger - than sizeMin. A good value to remove the datfile with just the elastic peak is - sizeMin=21000. The list is sorted by the file creation date.''' - list = os.listdir(directory) - files = [] - for file in list: - location = os.path.join(directory, file) - size = os.path.getsize(location) - time = os.path.getmtime(location) - if size>sizeMin: - files.append((file, time, size)) - # files.sort(key=lambda s: -s[1]) # sort by time - files.sort(key=lambda s: s[1]) # sort by reversed time - fileNames = [item[0] for item in files] - data_ext = ['gph', 'GPH'] - gphFiles = [fn for fn in fileNames - if any(fn.endswith(ext) for ext in data_ext)] - return gphFiles, len(gphFiles) - - def createFileList(self): - if self.wideScan: - sizeMin = 21000. - else: - sizeMin = 5. - for item in self.getFileList(self.datapath,sizeMin=sizeMin)[0]: - fname = re.split('\.',item)[0] - self.ui.listWidget.addItem(fname) - - def openDirectoryDialog(self): - self.dataDir = QtWidgets.QFileDialog(self) - options = self.dataDir.Options() - # options = self.dataDir.ShowDirsOnly - options |= self.dataDir.DontUseNativeDialog - dir =self.dataDir.getExistingDirectory(self, 'Select data directory', options=options) - if dir: - return dir - -class Cursor(object): - def __init__(self, fig, ax): - self.figure = fig - self.ax = ax - self.ly = ax.axvline(color='r') # the vert line - - def mouse_move(self, event): - if not event.inaxes: - return - self.ly.set_data([event.xdata, event.xdata], [0, 1]) - self.figure.draw() - -def runViewer(datapath= None, remoteDir=None, startWithFile=None, comment=None): - """ Main function for graphical application start """ - app = QtWidgets.QApplication(sys.argv) - form = HREELS_Window(datapath=datapath, remoteDir=remoteDir, startWithFile=startWithFile, comment=comment) - form.show() - sys.exit(app.exec_()) - - -def myMain(): - parser = argparse.ArgumentParser() - ################# Command line handling ###################### - def is_valid_file(string): - if not os.path.exists(string): - parser.error("The file %s does not exist!" % string) - return False - else: - return string - parser.add_argument("file", nargs='?', help="Start viewer with this datafile", type=is_valid_file) - parser.add_argument("-f", "--file2", help="Start viewer with this datafile") - parser.add_argument("-c", "--comment", default=None, help="Text comment") - args = parser.parse_args() - - if args.file: - fPath,fName = os.path.split(args.file) - # print(">>> ", fPath, " <<< ", fName) - elif args.file2: - fPath,fName = os.path.split(args.file2) - # print(">>> ", fPath, " <<< ", fName) - else: - if os.name == 'nt': - fPath = "D:\\Data\\Python\\HREELS\\expHREELS\\data" - else: - fPath = "/mnt/d/Data/Python/HREELS/expHREELS/data" - fPath = "/mnt/c/Users/user/ownCloud/Backup02-EP3/0_experiments/EELS-PC4/HREELS/gph_dat/2021" - fName = None - - runViewer(datapath=fPath, startWithFile=fName, comment=args.comment) - - - - -if __name__ == '__main__': - myMain() \ No newline at end of file diff --git a/Python code/libhreels/analysizeData.py b/Python code/libhreels/analysizeData.py deleted file mode 100755 index 5184c1ef186f696163dc21f2f6cb7b9467e04ffa..0000000000000000000000000000000000000000 --- a/Python code/libhreels/analysizeData.py +++ /dev/null @@ -1,45 +0,0 @@ -import numpy as np -from matplotlib import pyplot as plt - -def findPeriod(list, period): - '''For a list of times (relative to a sync pulse) calculate the average time deviation squared. - ''' - residuum = [] - sum_residuum = 0 - for each in list: - r = each % period - residuum.append(r) - sum_residuum += r - av_res = sum_residuum / len(list) - deviation = 0 - for res in residuum: - deviation += (res - av_res)**2 - deviation /= (len(residuum)*period**2) - return deviation, av_res - -def makeTimeRelative(times, durations): - list = [] - synced = False - t_zero = 0 - for each in pulses: - if synced: - list.append(pulses[each][0]-t_zero) - if 9000 < pulses[each][2] < 9800: - print("synced") - t_zero = pulses[each][0] - synced = True - return list - -data = [] # read dat from file [[time in microsec, low duration, high duration], [...], ...] -with open("data433_Signal2.txt", 'r') as f: - for line in f: - data.append([int(each) for each in line.split(',')]) - -sumOn = 0; sumOff = 0 -for pulse in data[1:]: - sumOn += pulse[2] - sumOff += pulse[1] -sumOn /= len(data) -sumOff /= len(data) - -print("Average on and off times:", sumOn, sumOff) diff --git a/Python code/libhreels/expLogbook.py b/Python code/libhreels/expLogbook.py deleted file mode 100755 index 04ce7c4b26a446bd74c9f308ff90e3159543d125..0000000000000000000000000000000000000000 --- a/Python code/libhreels/expLogbook.py +++ /dev/null @@ -1,48 +0,0 @@ -# print('Executing expLogbook.py') -# from getComment4File import * -import requests -import urllib.parse -import os -import builtins -import re -from elog.logbook_exceptions import * -import elog -from datetime import datetime -from time import localtime - -# disable warnings about ssl verification -from requests.packages.urllib3.exceptions import InsecureRequestWarning -requests.packages.urllib3.disable_warnings(InsecureRequestWarning) - - -class myLogbook(elog.Logbook): - - def getMessage4File(self, filename): - ids = super().search({'file':filename}) - if len(ids) > 0: - message, _ , _ = super().read(ids[0]) - return message - else: - print("File {} in eLog not found!".format(filename)) - return None - - def getShortMessage4File(self,filename): - stuff = self.getMessage4File(filename) - import html2text - h = html2text.HTML2Text() - # Ignore converting links from HTML - h.ignore_links = True - if stuff: return h.handle(stuff) - return - - -########################################################################################################## -# ogf settings: -try: - from libhreels.eLogCredentials import dummy, unsafe # Defines User credentials - logbook = myLogbook('https://labor-ep3.physik.uni-halle.de/HREELS/', user=dummy, password=unsafe) - print('eLog available!') - available = True -except: - available = False - diff --git a/Python code/libhreels/viewauger.ui b/Python code/libhreels/viewauger.ui deleted file mode 100755 index 226a8c13d88881d4cdf92d9b4e27a7cb22da2b6a..0000000000000000000000000000000000000000 --- a/Python code/libhreels/viewauger.ui +++ /dev/null @@ -1,280 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Auger_data_browser</class> - <widget class="QMainWindow" name="Auger_data_browser"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1004</width> - <height>685</height> - </rect> - </property> - <property name="windowTitle"> - <string>Auger data browser</string> - </property> - <widget class="QWidget" name="centralwidget"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="sizeConstraint"> - <enum>QLayout::SetMinimumSize</enum> - </property> - <property name="leftMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>5</number> - </property> - <item> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="sizeConstraint"> - <enum>QLayout::SetMinimumSize</enum> - </property> - <property name="leftMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>5</number> - </property> - <item> - <widget class="QLineEdit" name="lineEdit_directory"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QListWidget" name="listWidget"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="topMargin"> - <number>1</number> - </property> - <property name="bottomMargin"> - <number>1</number> - </property> - <item> - <widget class="QPushButton" name="pushButton_details"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>14</height> - </size> - </property> - <property name="toolTip"> - <string>Show all details for the last data file</string> - </property> - <property name="text"> - <string>Details</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="sizeConstraint"> - <enum>QLayout::SetMinimumSize</enum> - </property> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Factor:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_factor"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>10</width> - <height>0</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBoxOffset"> - <property name="text"> - <string>Offset</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_offset"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>10</width> - <height>0</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBoxMarker"> - <property name="text"> - <string>set Marker</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>300</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <widget class="QLabel" name="drawWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>50</width> - <height>50</height> - </size> - </property> - <property name="text"> - <string/> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"/> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit"/> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QMenuBar" name="menubar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1004</width> - <height>22</height> - </rect> - </property> - <widget class="QMenu" name="menuSelect_directory"> - <property name="title"> - <string>Select directory</string> - </property> - <addaction name="action_test"/> - <addaction name="action_directory"/> - </widget> - <widget class="QMenu" name="menuHelp"> - <property name="title"> - <string>Help</string> - </property> - <addaction name="action_help"/> - </widget> - <widget class="QMenu" name="menuDetails"> - <property name="title"> - <string>Details</string> - </property> - </widget> - <addaction name="menuSelect_directory"/> - <addaction name="menuHelp"/> - <addaction name="menuDetails"/> - </widget> - <widget class="QStatusBar" name="statusbar"/> - <widget class="QToolBar" name="toolBar"> - <property name="windowTitle"> - <string>toolBar</string> - </property> - <attribute name="toolBarArea"> - <enum>TopToolBarArea</enum> - </attribute> - <attribute name="toolBarBreak"> - <bool>false</bool> - </attribute> - </widget> - <action name="action_test"> - <property name="text"> - <string>Backup directory</string> - </property> - </action> - <action name="action_directory"> - <property name="text"> - <string>Data directory</string> - </property> - </action> - <action name="action_help"> - <property name="text"> - <string>About</string> - </property> - </action> - </widget> - <resources/> - <connections/> -</ui> diff --git a/Python code/libhreels/viewhreels.ui b/Python code/libhreels/viewhreels.ui deleted file mode 100755 index ab9f52a78bc470925448d9cbe1aa64c246cbfebb..0000000000000000000000000000000000000000 --- a/Python code/libhreels/viewhreels.ui +++ /dev/null @@ -1,330 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>HREELS_data_browser</class> - <widget class="QMainWindow" name="HREELS_data_browser"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1364</width> - <height>673</height> - </rect> - </property> - <property name="windowTitle"> - <string>HREELS data browser</string> - </property> - <widget class="QWidget" name="centralwidget"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="sizeConstraint"> - <enum>QLayout::SetMinimumSize</enum> - </property> - <property name="leftMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>5</number> - </property> - <item> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="sizeConstraint"> - <enum>QLayout::SetMinimumSize</enum> - </property> - <property name="leftMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>5</number> - </property> - <item> - <widget class="QLineEdit" name="lineEdit_directory"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QListWidget" name="listWidget"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="topMargin"> - <number>1</number> - </property> - <property name="bottomMargin"> - <number>1</number> - </property> - <item> - <widget class="QCheckBox" name="checkBoxWideScans"> - <property name="text"> - <string>only wide scans</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_details"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>14</height> - </size> - </property> - <property name="toolTip"> - <string>Show all details for the last data file</string> - </property> - <property name="text"> - <string>Details</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="sizeConstraint"> - <enum>QLayout::SetMinimumSize</enum> - </property> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Start:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_xmin"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>10</width> - <height>0</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Factor:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_factor"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>10</width> - <height>0</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBoxNormalized"> - <property name="text"> - <string>Normalized</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBoxOffset"> - <property name="text"> - <string>Offset</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_offset"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>10</width> - <height>0</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBoxMarker"> - <property name="text"> - <string>set Marker</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBoxComment"> - <property name="text"> - <string>comments</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>300</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <widget class="QLabel" name="drawWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>50</width> - <height>50</height> - </size> - </property> - <property name="text"> - <string/> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"/> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit"/> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QMenuBar" name="menubar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1364</width> - <height>22</height> - </rect> - </property> - <widget class="QMenu" name="menuSelect_directory"> - <property name="title"> - <string>Select directory</string> - </property> - <addaction name="action_test"/> - <addaction name="action_directory"/> - </widget> - <widget class="QMenu" name="menuHelp"> - <property name="title"> - <string>Help</string> - </property> - <addaction name="action_help"/> - </widget> - <widget class="QMenu" name="menuDetails"> - <property name="title"> - <string>Details</string> - </property> - <addaction name="actionFile_info"/> - </widget> - <addaction name="menuSelect_directory"/> - <addaction name="menuHelp"/> - <addaction name="menuDetails"/> - </widget> - <widget class="QStatusBar" name="statusbar"/> - <widget class="QToolBar" name="toolBar"> - <property name="windowTitle"> - <string>toolBar</string> - </property> - <attribute name="toolBarArea"> - <enum>TopToolBarArea</enum> - </attribute> - <attribute name="toolBarBreak"> - <bool>false</bool> - </attribute> - </widget> - <action name="action_test"> - <property name="text"> - <string>Backup directory</string> - </property> - </action> - <action name="action_directory"> - <property name="text"> - <string>Data directory</string> - </property> - </action> - <action name="action_help"> - <property name="text"> - <string>About</string> - </property> - </action> - <action name="actionFile_info"> - <property name="text"> - <string>File info</string> - </property> - </action> - </widget> - <resources/> - <connections/> -</ui> diff --git a/Python code/libhreels/viewhreels_dialog.ui b/Python code/libhreels/viewhreels_dialog.ui deleted file mode 100755 index 5663a3ad626c854108e6659ef2053ecf13a93c9a..0000000000000000000000000000000000000000 --- a/Python code/libhreels/viewhreels_dialog.ui +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Dialog</class> - <widget class="QDialog" name="Dialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>645</width> - <height>256</height> - </rect> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <family>Courier New</family> - <pointsize>10</pointsize> - </font> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPlainTextEdit" name="textArea"/> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/Python code/libhreels/materials.json b/Python code/materials.json similarity index 100% rename from Python code/libhreels/materials.json rename to Python code/materials.json diff --git a/Python code/libhreels/myBoson.f90 b/Python code/myBoson.f90 similarity index 100% rename from Python code/libhreels/myBoson.f90 rename to Python code/myBoson.f90 diff --git a/Python code/libhreels/myEels2.f90 b/Python code/myEels2.f90 similarity index 100% rename from Python code/libhreels/myEels2.f90 rename to Python code/myEels2.f90 diff --git a/Python code/libhreels/myEels3.f90 b/Python code/myEels3.f90 similarity index 100% rename from Python code/libhreels/myEels3.f90 rename to Python code/myEels3.f90 diff --git a/Python code/libhreels/myEels3cole.f90 b/Python code/myEels3cole.f90 similarity index 100% rename from Python code/libhreels/myEels3cole.f90 rename to Python code/myEels3cole.f90 diff --git a/Python code/libhreels/myEels4.f90 b/Python code/myEels4.f90 similarity index 100% rename from Python code/libhreels/myEels4.f90 rename to Python code/myEels4.f90