From 5ff752da530fa7565ac9223d1cff7f3019bb2409 Mon Sep 17 00:00:00 2001 From: gac-x03da Date: Wed, 19 Jun 2019 09:50:03 +0200 Subject: [PATCH] Closedown --- script/XPSSpectrum.py | 23 ++++++++++++----------- script/test/TestGenerator.py | 8 ++++---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/script/XPSSpectrum.py b/script/XPSSpectrum.py index 77db58b5..bd2aba06 100644 --- a/script/XPSSpectrum.py +++ b/script/XPSSpectrum.py @@ -47,16 +47,15 @@ be_axis.setLabel("binding energy") spectrum_series = p.getSeries(0) -def get_binding_range(): +def get_binding_energy(e): ephot = Eph.take(100) - elo = Scienta.lowEnergy.take(100) - ehi = Scienta.highEnergy.take(100) workfunc = 4.5 if type(ephot) != float or ephot < 0.: - ephot = ehi - eb1 = ephot - elo - workfunc - eb2 = ephot - ehi - workfunc - return eb2, eb1 + ephot = Scienta.highEnergy.take(100) + return ephot - e - workfunc + +def get_binding_range(): + return get_binding_energy(Scienta.highEnergy.take(100)), get_binding_energy(Scienta.lowEnergy.take(100)) eb2, eb1 = get_binding_range() @@ -88,18 +87,19 @@ try: for cur_range in range(len(ranges)): cur_iteration = 0 skip_iteration = False + vars = ranges[cur_range].vars #Check if photon energy is defined + if len(vars) > 2: eph = vars[3] - if not math.isnan(eph): + if eph and (not math.isnan(eph)): Eph.move(eph) Scienta.lowEnergy.write(adjusted_ranges[cur_range][0]) Scienta.highEnergy.write(adjusted_ranges[cur_range][1]) Scienta.update() - - vars = ranges[cur_range].vars + Scienta.stepTime.write(vars[0]) Scienta.stepSize.write(vars[1]) Scienta.setIterations(1) @@ -179,7 +179,8 @@ finally: if not Scienta.isReady(): Scienta.stop() Scienta.update() - task[0].cancel(True) + if task: + task[0].cancel(True) if ENDSCAN: after_scan() diff --git a/script/test/TestGenerator.py b/script/test/TestGenerator.py index 8aa8bc4e..e6a6497c 100644 --- a/script/test/TestGenerator.py +++ b/script/test/TestGenerator.py @@ -2,9 +2,9 @@ import ch.psi.pshell.device.DummyPositioner as DummyPositioner #Energy #Pass Energy -STEPS = [ ( 136.0, 10 ), - ( 350.5, 20 ), - ( 400.0, 50 ), +STEPS = [ ( 136.0, 10 , 5.0), + ( 350.5, 20 , 6.0), + ( 400.0, 50 , 7.0), ] @@ -27,7 +27,7 @@ def scan_gen(): for step in STEPS: yield step -POSITIONERS = [energy, pass_energy] +POSITIONERS = [energy, pass_energy, Scienta.getChild("Scienta step time")] try: vscan( POSITIONERS,