From 3c3f9c0db9d37568d84db28f63502608762de702 Mon Sep 17 00:00:00 2001 From: gac-x03da Date: Tue, 28 May 2019 13:07:59 +0200 Subject: [PATCH] Closedown --- script/XPSSpectrum.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/script/XPSSpectrum.py b/script/XPSSpectrum.py index e1b4d425..c6a42719 100644 --- a/script/XPSSpectrum.py +++ b/script/XPSSpectrum.py @@ -16,8 +16,10 @@ ret=[] adjusted_ranges = [] for cur_range in range(len(ranges)): - r = ranges[cur_range] - ar = [round(r.min / r.vars[1]) * r.vars[1], round(r.max / r.vars[1]) * r.vars[1]] + r = ranges[cur_range] + print r + print r.vars + ar = [round(r.min / r.vars[1]) * r.vars[1], round(r.max / r.vars[1]) * r.vars[1]] adjusted_ranges.append(ar) set_exec_pars(open = True) @@ -49,25 +51,29 @@ p = plots[0] spectrum_series = p.getSeries(0) jf = p.chart.plot eb_axis = NumberAxis("binding energy") -eb_axis.setRange(-100.0, 100.0) -spectrum_eb_axis = jf.getDomainAxis(1) 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 -""" -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 -""" +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() + def plot_cur_spectrum_eb(): """ plot online spectrum function for forked task. @@ -104,7 +110,7 @@ def plot_cur_spectrum(): y = Scienta.spectrum.take(100) x = Scienta.spectrumX spectrum_series.setData(x, y) - + set_online_spectrum_x2_range() time.sleep(1.0) finally: print "Stopping spectrum plotting" @@ -133,7 +139,7 @@ try: xdata = None ydata = None image_data = None - task = fork(plot_cur_spectrum_eb) + task = fork(plot_cur_spectrum) path="scan" + str(cur_range+1) + "/" for cur_iteration in range(vars[2]): @@ -145,6 +151,7 @@ try: spectrum_array = Scienta.spectrum.read() if beam_ok: if image_data is None: + time.sleep(2.0) (_width, _height) = Scienta.getImageSize() break if ydata is None: