From ee85290fc863c488a732f0abf655e23ad005ebbc Mon Sep 17 00:00:00 2001 From: gac-x03da Date: Tue, 28 May 2019 16:29:02 +0200 Subject: [PATCH] Script execution --- script/XPSSpectrum.py | 109 ++++-------------------------------------- 1 file changed, 10 insertions(+), 99 deletions(-) diff --git a/script/XPSSpectrum.py b/script/XPSSpectrum.py index 5b36a98a..67e1c2cc 100644 --- a/script/XPSSpectrum.py +++ b/script/XPSSpectrum.py @@ -36,60 +36,21 @@ plots = plot(None, names) for p in plots[1:]: p.getAxis(p.AxisId.X).label = "kinetic energy" p.getAxis(p.AxisId.X2).setLabel("binding energy") - #p.getAxis(p.AxisId.X2).inverted = True - """ - eb_axis = NumberAxis("binding energy") - eb_axis.inverted = True - jf = p.chart.plot - jf.setDomainAxis(1, eb_axis) - jf.getDomainAxis(1).labelPaint = jf.getDomainAxis(0).labelPaint - jf.getDomainAxis(1).labelFont = jf.getDomainAxis(0).labelFont - jf.getDomainAxis(1).tickLabelPaint = jf.getDomainAxis(0).tickLabelPaint - jf.getDomainAxis(1).tickLabelFont = jf.getDomainAxis(0).tickLabelFont - """ - - -# online spectrum -""" + p = plots[0] +be_axis = plots[0].getAxis(p.AxisId.X2) +be_axis.setLabel("binding energy") + spectrum_series = p.getSeries(0) -jf = p.chart.plot -eb_axis = NumberAxis("binding energy") -jf.setDomainAxis(1, eb_axis) -jf.getDomainAxis(1).labelPaint = jf.getDomainAxis(0).labelPaint -jf.getDomainAxis(1).labelFont = jf.getDomainAxis(0).labelFont -jf.getDomainAxis(1).tickLabelPaint = jf.getDomainAxis(0).tickLabelPaint -jf.getDomainAxis(1).tickLabelFont = jf.getDomainAxis(0).tickLabelFont - - -def set_online_spectrum_x2_range(): - spectrum_eb_axis = jf.getDomainAxis(1) - # adjust the binding energy scale - # if Eph returns an invalid number, we take energy_high as photon energy - ephot = Eph.take(100) - elo = Scienta.lowEnergy.take(100) - ehi = Scienta.highEnergy.take(100) - workfunc = 4.5 - if ephot is not float or ephot < 0.: - ephot = ehi - eb1 = ephot - elo - workfunc - eb2 = ephot - ehi - workfunc - spectrum_eb_axis.setRange(eb2, eb1) - -set_online_spectrum_x2_range() -""" -p = plots[0] -spectrum_series = p.getSeries(0) -p.getAxis(p.AxisId.X2).setLabel("binding energy") def get_binding_range(): ephot = Eph.take(100) elo = Scienta.lowEnergy.take(100) - ehi = Scienta.highEnergy.take(100) + ehi = Scienta.highEnergy.take(100) workfunc = 4.5 - if ephot is not float or ephot < 0.: + if type(ephot) != float or ephot < 0.: ephot = ehi eb1 = ephot - elo - workfunc eb2 = ephot - ehi - workfunc @@ -97,39 +58,8 @@ def get_binding_range(): eb2, eb1 = get_binding_range() -plots[0].getAxis(p.AxisId.X2).setRange(eb2, eb1) +be_axis.setRange(eb2, eb1) -# -#def plot_cur_spectrum_eb(): -# """ -# plot online spectrum function for forked task. -# with binding energy scale. -# issue: this should not set the axis while the plot is zoomed! -# """ -# global spectrum_series -# global spectrum_eb_axis -# try: -# while get_context().state.running: -# y = Scienta.spectrum.take(100) -# x = Scienta.spectrumX -# spectrum_series.setData(x, y) -# -# # adjust the binding energy scale -# # if Eph returns an invalid number, we take energy_high as photon energy -# ephot = Eph.take(100) -# elo = Scienta.lowEnergy.take(100) -# ehi = Scienta.highEnergy.take(100) -# workfunc = 4.5 -# if ephot is not float or ephot < 0.: -# ephot = ehi -# eb1 = ephot - elo - workfunc -# eb2 = ephot - ehi - workfunc -# spectrum_eb_axis.setRange(eb2, eb1) -# -# time.sleep(1.0) -# finally: -# print "Stopping spectrum plotting" -# def plot_cur_spectrum(): try: @@ -137,12 +67,11 @@ def plot_cur_spectrum(): y = Scienta.spectrum.take(100) x = Scienta.spectrumX spectrum_series.setData(x, y) - #set_online_spectrum_x2_range() - + eb2, eb1 = get_binding_range() - if True: #(plots[0].getAxis(p.AxisId.X2).min != eb2) or (plots[0].getAxis(p.AxisId.X2).max != eb1): + if (be_axis.min != eb2) or (be_axis.max != eb1): plots[0].resetZoom() - plots[0].getAxis(p.AxisId.X2).setRange(eb2, eb1) + be_axis.setRange(eb2, eb1) time.sleep(1.0) finally: @@ -165,10 +94,6 @@ try: Scienta.stepTime.write(vars[0]) Scienta.stepSize.write(vars[1]) Scienta.setIterations(1) - - eb2, eb1 = get_binding_range() - plots[0].getAxis(p.AxisId.X2).setRange(eb2, eb1) - set_adc_averaging() @@ -200,20 +125,6 @@ try: xdata = Scienta.spectrumX p.getSeries(0).setData(xdata, ydata) - """ - # adjust the binding energy scale - # if Eph returns an invalid number, we take energy_high as photon energy - eb_axis = p.chart.plot.getDomainAxis(1) - ephot = Eph.take(100) - elo = Scienta.lowEnergy.take(100) - ehi = Scienta.highEnergy.take(100) - workfunc = 4.5 - if ephot is not float or ephot < 0.: - ephot = ehi - eb1 = ephot - elo - workfunc - eb2 = ephot - ehi - workfunc - eb_axis.setRange(eb2, eb1) - """ eb2, eb1 = get_binding_range() p.getAxis(p.AxisId.X2).setRange(eb2, eb1)