""" author chritstoph seitz starting the xps measurement Fermi edge of C1s test """ global ranges, pass_energy, skip_iteration, ENDSCAN from ch.psi.pshell.data.LayoutDefault import ATTR_WRITABLE_DIMENSION as ATTR_WRITABLE_DIMENSION cur_range = 0 cur_iteration = 0 Scienta.acquisitionMode = Scienta.AcquisitionMode.Swept ret=[] set_exec_pars(open = True) #Global arguments Scienta.passEnergy = pass_energy names=[] names.append("Online Spectrum") for i in range(len(ranges)): names.append(str(ranges[i][0])) plots = plot(None, names) spectrum_series = plots[0].getSeries(0) def plot_cur_spectrum(): global spectrum_series 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 try: for cur_range in range(len(ranges)): cur_iteration = 0 skip_iteration = False params = ranges[cur_range] Eph.move(params[0]) time.sleep(5.0) Scienta.lowEnergy.write(params[1]) Scienta.highEnergy.write(params[2]) Scienta.update() Scienta.stepSize.write(params[3]) Scienta.stepTime.write(params[4]) Scienta.setIterations(1) set_adc_averaging() #iterations done in script xdata = None ydata = None image_data = None task = fork(plot_cur_spectrum) path="scan" + str(cur_range+1) + "/" for cur_iteration in range(params[5]): plots[cur_range+1].setTitle(str(params[0]) + " - iteration " + str(cur_iteration+1)) while True: wait_beam() trig_scienta() spectrum_array = Scienta.spectrum.read() if beam_ok: break if ydata is None: ydata = spectrum_array else: for k in range (len(spectrum_array)): ydata[k] = ydata[k] + spectrum_array[k] if xdata is None: xdata = Scienta.spectrumX plots[cur_range+1].getSeries(0).setData(xdata, ydata) if skip_iteration: break save_dataset(path + "ScientaSpectrum", ydata) set_attribute(path, "Iterations",cur_iteration+1) if cur_iteration==0: save_dataset(path + "ScientaChannels", xdata) set_attribute(path + "ScientaChannels", ATTR_WRITABLE_DIMENSION, 1) set_attribute(path, "Range Low", params[1]) set_attribute(path, "Range High", params[2]) set_attribute(path, "Step Time", params[4]) set_attribute(path, "Step Size", params[3]) set_attribute(path, "Pass Energy", pass_energy) set_attribute(path, "Readables", ["ScientaSpectrum",]) set_attribute(path, "Writables", ["ScientaChannels",]) create_diag_datasets(path) append_diag_datasets(path) plots[cur_range+1].setTitle(str(params[0])) ret.append((xdata, ydata)) finally: cur_range = -1 if not Scienta.isReady(): Scienta.stop() Scienta.update() task[0].cancel(True) if ENDSCAN: after_scan() set_return(to_array(ret,'o'))