From 85f3b58123e7c9a5cba87555fb361c65a066b05e Mon Sep 17 00:00:00 2001 From: gac-x03da Date: Tue, 19 Feb 2019 11:51:30 +0100 Subject: [PATCH] Closedown --- script/HoloScan.py | 3 ++- script/XPSSpectrum.py | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/script/HoloScan.py b/script/HoloScan.py index 45fc9da6..f3520d74 100644 --- a/script/HoloScan.py +++ b/script/HoloScan.py @@ -18,7 +18,8 @@ set_adc_averaging() set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1}) try: - ascan((ManipulatorPhi, ManipulatorTheta), SENSORS, (PHI_RANGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS, LATENCY, RELATIVE, zigzag = ZIGZAG, before_read=before_readout, after_read = after_readout) + ascan((ManipulatorPhi, ManipulatorTheta), SENSORS, (PHI_RANGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS, LATENCY, RELATIVE, zigzag = ZIGZAG, \ + before_read=before_readout, after_read = after_readout, compression = True) finally: if ENDSCAN: after_scan() \ No newline at end of file diff --git a/script/XPSSpectrum.py b/script/XPSSpectrum.py index 515efb37..b8bd3978 100644 --- a/script/XPSSpectrum.py +++ b/script/XPSSpectrum.py @@ -31,7 +31,7 @@ for i in range(len(ranges)): names.append(str(ranges[i])) plots = plot(None, names) -for p in plots: +for p in plots[1:]: p.getAxis(p.AxisId.X).label = "kinetic energy" eb_axis = NumberAxis("binding energy") eb_axis.inverted = True @@ -45,10 +45,15 @@ for p in plots: # online spectrum -p = plots[0] -spectrum_series = p.getSeries(0) -spectrum_eb_axis = p.chart.plot.getDomainAxis(1) -def plot_cur_spectrum(): +# p = plots[0] +# spectrum_series = p.getSeries(0) +# spectrum_eb_axis = p.chart.plot.getDomainAxis(1) +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: @@ -72,6 +77,18 @@ def plot_cur_spectrum(): time.sleep(1.0) finally: print "Stopping spectrum plotting" + +def plot_cur_spectrum(): + try: + while get_context().state.running: + y = Scienta.spectrum.take(100) + x = Scienta.spectrumX + spectrum_series.setData(x, y) + + time.sleep(1.0) + finally: + print "Stopping spectrum plotting" + task = None @@ -96,7 +113,7 @@ try: xdata = None ydata = None image_data = None - task = fork(plot_cur_spectrum) + task = fork(plot_cur_spectrum) path="scan" + str(cur_range+1) + "/" for cur_iteration in range(vars[2]): @@ -107,6 +124,8 @@ try: trig_scienta() spectrum_array = Scienta.spectrum.read() if beam_ok: + if image_data is None: + (_width, _height) = Scienta.getImageSize() break if ydata is None: ydata = spectrum_array @@ -129,9 +148,15 @@ try: eb1 = ephot - elo - workfunc eb2 = ephot - ehi - workfunc eb_axis.setRange(eb2, eb1) - + if save_scienta_image: image_array = Scienta.dataMatrix.read() + if _width != len(image_array[0]) or _height != len(image_array): + err = "Scienta image size changed during the acquisition: " + str((len(image_array[0]), len(image_array))) + " - original: " + str((_width, _height)) + print err + log(err) + raise Exception(err) + if image_data is None: image_data = image_array else: @@ -143,7 +168,7 @@ try: save_dataset(path + "ScientaSpectrum", ydata) set_attribute(path, "Iterations",cur_iteration+1) if save_scienta_image: - save_dataset(path + "ScientaImage", image_data) + save_dataset(path + "ScientaImage", image_data, features = {"compression":True}) if cur_iteration==0: save_dataset(path + "ScientaChannels", xdata) set_attribute(path + "ScientaChannels", ATTR_WRITABLE_DIMENSION, 1)