""" Arguments: DRY_RUN (BOOL) CENTER_Z, CENTER_Y (FLOAT) STEPS_Z, STEPS_Y (INT) STEP_SIZE_Z, STEP_SIZE_Y (FLOAT) EXPOSURES (list or None) SETTLING_TIME (double) ZIGZAG (BOOLEAN) COMPRESSION (BOOLEAN) NOISE (FLOAT) """ import random position_plot = None if "POSITION_PLOT_YZ" not in globals() else POSITION_PLOT_YZ #Debugging if (get_exec_pars().args is None) and (get_exec_pars().script=="Regine"): DRY_RUN = False CENTER_Z = 11458.0 CENTER_Y = 10398.0 EXPOSURES = [1] #unit:s STEPS_Z = 30 STEPS_Y= 0 STEP_SIZE_Z = 2.5 STEP_SIZE_Y = 5 NOISE=0.0 SETTLING_TIME = 1.0 ZIGZAG = True COMPRESSION = False position_plot=None if not position_plot: position_plot=plot(None, title="Motor Positions")[0] #Constants SENSORS = [current, ccd.dataMatrix, interf_0, interf_1] POSITIONERS = [dummy_z, dummy_y] if DRY_RUN else [sample_z, sample_y] ENABLED_PLOTS = [ccd.dataMatrix] CUSTOM_PLOT_TYPES = {ccd.dataMatrix:"ch.psi.pshell.plot.MatrixPlotRenderer"} RANGE_Z=[CENTER_Z - STEP_SIZE_Z*STEPS_Z, CENTER_Z + STEP_SIZE_Z*STEPS_Z] RANGE_Y=[CENTER_Y - STEP_SIZE_Y*STEPS_Y, CENTER_Y + STEP_SIZE_Y*STEPS_Y] print(RANGE_Z[0]) position_plot.clear() position_plot.addSeries(LinePlotSeries("positions")) position_plot.getAxis(AxisId.X).label = POSITIONERS[0].name position_plot.getAxis(AxisId.X).setRange(RANGE_Z[0]-STEP_SIZE_Z, RANGE_Z[1]+STEP_SIZE_Z) position_plot.getAxis(AxisId.Y).label = POSITIONERS[1].name position_plot.getAxis(AxisId.Y).setRange(RANGE_Y[0]-STEP_SIZE_Y, RANGE_Y[1]+STEP_SIZE_Y) def after_read(record, scan): after_readout(record, scan) position_plot.getSeries(0).appendData(record[POSITIONERS[0]], record[POSITIONERS[1]]) if EXPOSURES: POSITIONERS = POSITIONERS + [exposure_index()] SENSORS = SENSORS + [exposure()] RANGE_E=[0, len(EXPOSURES)-1] def gen(): z_index = y_index = e_index = 0 for z_step in range(-STEPS_Z, STEPS_Z+1): range_y= range(STEPS_Y, -STEPS_Y-1, -1) if (ZIGZAG and(z_index%2 ==1)) else range(-STEPS_Y, STEPS_Y+1) for y_step in range_y: zpos = CENTER_Z + z_step*STEP_SIZE_Z + (random.random()-0.5)*NOISE*2*STEP_SIZE_Z ypos = CENTER_Y + y_step*STEP_SIZE_Y + (random.random()-0.5)*NOISE*2*STEP_SIZE_Y if EXPOSURES: range_e= range(len(EXPOSURES)-1,-1, -1) if (ZIGZAG and(y_index%2 ==1)) else range(len(EXPOSURES)) for e in range_e: yield([zpos,ypos,e]) else: yield([zpos,ypos]) y_index=y_index+1 z_index=z_index+1 try: r = vscan(POSITIONERS, SENSORS , gen(), False,\ SETTLING_TIME, relative=False, zigzag = ZIGZAG, initial_move=False, \ before_read=before_readout, after_read = after_read, \ manual_range=RANGE_Z, manual_range_y=RANGE_Y, \ compression = COMPRESSION, enabled_plots=ENABLED_PLOTS, \ keep=False, check_positions=False, plot_types=CUSTOM_PLOT_TYPES) set_return(r) finally: after_scan()