From aa5cf65f85ff3a138810aa74887cd1e34d4f8d0e Mon Sep 17 00:00:00 2001 From: x03daop Date: Wed, 12 Apr 2017 12:17:39 +0200 Subject: [PATCH] Script execution --- script/MultiRegionScan.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/script/MultiRegionScan.py b/script/MultiRegionScan.py index 0b33b9b3..bb23b962 100644 --- a/script/MultiRegionScan.py +++ b/script/MultiRegionScan.py @@ -7,8 +7,8 @@ MOTORS = [Eph] POSITIONS = [400.0, 401.0] LATENCY = 0.0 -REGION1 = {'elo': 243.0, 'ehi': 245.0, 'estep': 0.1, 'epass': 50, 'tstep': 0.1, 'iter': 1, 'cis': True} -REGION2 = {'elo': 214.0, 'ehi': 217.0, 'estep': 0.1, 'epass': 50, 'tstep': 0.1, 'iter': 1, 'cis': False} +REGION1 = {'name': 'Peak 1', 'elo': 243.0, 'ehi': 245.0, 'estep': 0.1, 'epass': 50, 'tstep': 0.1, 'iter': 1, 'cis': True} +REGION2 = {'name': 'Peak 2', 'elo': 214.0, 'ehi': 217.0, 'estep': 0.1, 'epass': 50, 'tstep': 0.1, 'iter': 1, 'cis': False} REGIONS = [REGION1, REGION2] CLOSE_SHUTTER_AT_END = True @@ -73,6 +73,8 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray): append_dataset(self.iterations_dataset_name, self.region['iter']) def read(self): + global current_region_index + current_region_index = self.region_index self.setup() print "Photon energy {ephot} eV. Acquiring spectrum {elo}-{ehi} eV.".format(ephot=Eph.read(), elo=Scienta.lowEnergy.value, ehi=Scienta.highEnergy.value) trig_scienta() @@ -98,26 +100,28 @@ class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix): return ny # plotting current spectrum -names = "Scienta spectrum" -plots = plot(None, names, title="Live Spectrum") +names = [region['name'] for region in REGIONS] +global live_plots +live_plots = plot(None, names, title="Live Spectrum") global spectrum_series +global current_region_index +current_region_index = 0 spectrum_series = plots[0].getSeries(0) task = None def plot_cur_spectrum(): global spectrum_series + global live_plots + global current_region_index try: - #time.sleep(5.0) while get_context().state.running: - # if spectrum_series is None: - # print "create new plot" - # names = "Scienta spectrum" - # plots = plot(None, names, title="Online") - # spectrum_series = plots[0].getSeries(0) - y = Scienta.spectrum.take(100) x = Scienta.spectrumX - spectrum_series.setData(x, y) + #spectrum_series.setData(x, y) + try: + live_plots[current_region_index].setData(x, y) + except IndexError: + pass time.sleep(1.0) finally: print "Stopping spectrum plotting"