Exemple #1
0
def wafer_edge(motor='x'):
    '''Fit an error function to the linear scan against It. Plot the
    result. Move to the centroid of the error function.'''
    if motor == 'x':
        motor = user_ns['xafs_linx']
    else:
        motor = user_ns['xafs_liny']
    yield from linescan(motor, 'it', -2, 2, 41, pluck=False)
    close_last_plot()
    table = user_ns['db'][-1].table()
    yy = table[motor.name]
    signal = table['It'] / table['I0']
    if float(signal[2]) > list(signal)[-2]:
        ss = -(signal - signal[2])
    else:
        ss = signal - signal[2]
    mod = StepModel(form='erf')
    pars = mod.guess(ss, x=numpy.array(yy))
    out = mod.fit(ss, pars, x=numpy.array(yy))
    print(whisper(out.fit_report(min_correl=0)))
    out.plot()
    target = out.params['center'].value
    yield from mv(motor, target)
    yield from resting_state_plan()
    print(
        f'Edge found at X={user_ns["xafs_x"].position} and Y={user_ns["xafs_y"].position}'
    )
 def cleanup_plan():
     print(
         'Cleaning up after single energy absorption detector measurement')
     BMM_clear_suspenders()
     #RE.clear_suspenders()
     yield from resting_state_plan()
     dcm.mode = 'fixed'
 def cleanup_plan():
     print('Cleaning up after single energy absorption detector measurement')
     RE.clear_suspenders()
     yield from resting_state_plan()
     dotfile = '/home/xf06bm/Data/.time.scan.running'
     if os.path.isfile(dotfile): os.remove(dotfile)
     dcm.mode = 'fixed'
 def cleanup_plan():
     yield from mv(user_ns['slits3'].vsize, slit_height)
     yield from abs_set(user_ns['_locked_dwell_time'], 0.5, wait=True)
     yield from sleep(1.0)
     yield from abs_set(motor.kill_cmd, 1, wait=True)
     yield from sleep(1.0)
     yield from user_ns['dcm'].kill_plan()
     yield from resting_state_plan()
 def cleanup_plan():
     yield from mv(slits3.vsize, slit_height)
     yield from mv(_locked_dwell_time, 0.5)
     yield from sleep(1.0)
     yield from mv(motor.kill_cmd, 1)
     yield from sleep(1.0)
     yield from dcm.kill_plan()
     yield from resting_state_plan()
Exemple #6
0
    def cleanup_plan():
        print('Cleaning up after an area scan')
        RE.clear_suspenders()
        if BMMuser.final_log_entry is True:
            BMM_log_info('areascan finished\n\tuid = %s, scan_id = %d' %
                         (db[-1].start['uid'], db[-1].start['scan_id']))
        yield from resting_state_plan()
        RE.msg_hook = BMM_msg_hook

        print('Disabling plot for re-plucking.')
        try:
            cid = BMMuser.fig.canvas.mpl_disconnect(cid)
        except:
            pass
        BMMuser.x = None
        BMMuser.y = None
        BMMuser.motor = None
        BMMuser.motor2 = None
        BMMuser.fig = None
        BMMuser.ax = None
Exemple #7
0
def calibrate_low_end(mono='111', focus=False):
    '''Step through the lower 5 elements of the mono calibration procedure.'''
    BMMuser, shb, dcm_pitch = user_ns['BMMuser'], user_ns['shb'], user_ns[
        'dcm_pitch']
    (ok, text) = BMM_clear_to_start()
    if ok is False:
        print(error_msg('\n' + text) + bold_msg('Quitting macro....\n'))
        return (yield from null())

    BMM_log_info('Beginning low end calibration macro')

    def main_plan():
        BMMuser.prompt = False

        datafile = os.path.join(BMMuser.DATA, 'edges%s.ini' % mono)
        handle = open(datafile, 'w')
        handle.write('[config]\n')
        handle.write("mono      = %s\n" % mono)
        if mono == '111':
            handle.write('DSPACING  = 3.13597211\n')
        else:
            handle.write('DSPACING  = 1.63762644\n')
        handle.write('thistitle = Si(%s) calibration curve\n' % mono)
        handle.write(
            'reference = Kraft et al, Review of Scientific Instruments 67, 681 (1996)\n'
        )
        handle.write('doi       = https://doi.org/10.1063/1.1146657\n\n')
        handle.write('##       found, tabulated, found_angle, dcm_pitch\n')
        handle.write('[edges]\n')
        handle.flush()

        yield from change_edge('Fe', target=0, focus=focus)
        pitch = dcm_pitch.user_readback.get()
        yield from xafs('/home/xf06bm/Data/Staff/mono_calibration/cal.ini',
                        folder=BMMuser.DATA,
                        filename='fecal',
                        edge='Fe',
                        e0=7112,
                        sample='Fe foil')
        close_last_plot()
        handle.write('fe = 11111.11,    7110.75,    22222.22,   %.5f\n' %
                     pitch)
        handle.flush()

        yield from change_edge('Co', target=0, focus=focus)
        pitch = dcm_pitch.user_readback.get()
        yield from xafs('/home/xf06bm/Data/Staff/mono_calibration/cal.ini',
                        folder=BMMuser.DATA,
                        filename='cocal',
                        edge='Co',
                        e0=7709,
                        sample='Co foil')
        close_last_plot()
        handle.write('co = 11111.11,    7708.78,    22222.22,   %.5f\n' %
                     pitch)
        handle.flush()

        yield from change_edge('Ni', target=0, focus=focus)
        pitch = dcm_pitch.user_readback.get()
        yield from xafs('/home/xf06bm/Data/Staff/mono_calibration/cal.ini',
                        folder=BMMuser.DATA,
                        filename='nical',
                        edge='Ni',
                        e0=8333,
                        sample='Ni foil')
        close_last_plot()
        handle.write('ni = 11111.11,    8331.49,    22222.22,   %.5f\n' %
                     pitch)
        handle.flush()

        yield from change_edge('Cu', target=0, focus=focus)
        pitch = dcm_pitch.user_readback.get()
        yield from xafs('/home/xf06bm/Data/Staff/mono_calibration/cal.ini',
                        folder=BMMuser.DATA,
                        filename='cucal',
                        edge='Cu',
                        e0=8979,
                        sample='Cu foil')
        close_last_plot()
        handle.write('cu = 11111.11,    8980.48,    22222.22,   %.5f\n' %
                     pitch)
        handle.flush()

        yield from change_edge('Zn', target=0, focus=focus)
        pitch = dcm_pitch.user_readback.get()
        yield from xafs('/home/xf06bm/Data/Staff/mono_calibration/cal.ini',
                        folder=BMMuser.DATA,
                        filename='zncal',
                        edge='Zn',
                        e0=9659,
                        sample='Zn foil')
        close_last_plot()
        handle.write('zn = 11111.11,    9660.76,    22222.22,   %.5f\n' %
                     pitch)

        handle.flush()
        handle.close()

        #yield from shb.close_plan()

    def cleanup_plan():
        yield from resting_state_plan()

    yield from finalize_wrapper(main_plan(), cleanup_plan())
    yield from resting_state_plan()
    BMM_log_info('Low end calibration macro finished!')
Exemple #8
0
 def cleanup_plan():
     yield from resting_state_plan()
Exemple #9
0
 def main_plan():
     dcm = user_ns['dcm']
     report(f'Calibrating the {dcm._crystal} monochrmoator', 'bold')
     yield from calibrate_low_end(mono=dcm._crystal, focus=focus)
     yield from calibrate_high_end(mono=dcm._crystal, focus=focus)
     yield from resting_state_plan()
Exemple #10
0
def calibrate_high_end(mono='111', focus=False):
    '''Step through the upper 5 elements of the mono calibration procedure.'''
    BMMuser, shb, dcm_pitch = user_ns['BMMuser'], user_ns['shb'], user_ns[
        'dcm_pitch']
    (ok, text) = BMM_clear_to_start()
    if ok is False:
        print(error_msg('\n' + text) + bold_msg('Quitting macro....\n'))
        return (yield from null())

    BMM_log_info('Beginning high end calibration macro')

    def main_plan():
        BMMuser.prompt = False
        datafile = os.path.join(BMMuser.DATA, 'edges%s.ini' % mono)
        handle = open(datafile, 'a')

        #yield from shb.open_plan()

        yield from change_edge('Pt', target=0, focus=focus)
        pitch = dcm_pitch.user_readback.get()
        yield from xafs('/home/xf06bm/Data/Staff/mono_calibration/cal.ini',
                        folder=BMMuser.DATA,
                        filename='ptcal',
                        edge='Pt',
                        e0=11563,
                        sample='Pt foil')
        close_last_plot()
        handle.write('pt = 11111.11,    11562.76,    22222.22,   %.5f\n' %
                     pitch)
        handle.flush()

        yield from change_edge('Au', target=0, focus=focus)
        pitch = dcm_pitch.user_readback.get()
        yield from xafs('/home/xf06bm/Data/Staff/mono_calibration/cal.ini',
                        folder=BMMuser.DATA,
                        filename='aucal',
                        edge='Au',
                        e0=11919,
                        sample='Au foil')
        close_last_plot()
        handle.write('au = 11111.11,    11919.70,    22222.22,   %.5f\n' %
                     pitch)
        handle.flush()

        yield from change_edge('Pb', target=0, focus=focus)
        pitch = dcm_pitch.user_readback.get()
        yield from xafs('/home/xf06bm/Data/Staff/mono_calibration/cal.ini',
                        folder=BMMuser.DATA,
                        filename='pbcal',
                        edge='Pb',
                        e0=13035,
                        sample='Pb foil')
        close_last_plot()
        handle.write('pb = 11111.11,    13035.07,    22222.22,   %.5f\n' %
                     pitch)
        handle.flush()

        yield from change_edge('Nb', target=0, focus=focus)
        pitch = dcm_pitch.user_readback.get()
        yield from xafs('/home/xf06bm/Data/Staff/mono_calibration/cal.ini',
                        folder=BMMuser.DATA,
                        filename='nbcal',
                        edge='Nb',
                        e0=18986,
                        sample='Nb foil')
        close_last_plot()
        handle.write('nb = 11111.11,     18982.97,   22222.22,   %.5f\n' %
                     pitch)
        handle.flush()

        yield from change_edge('Mo', target=0, focus=focus)
        pitch = dcm_pitch.user_readback.get()
        yield from xafs('/home/xf06bm/Data/Staff/mono_calibration/cal.ini',
                        folder=BMMuser.DATA,
                        filename='mocal',
                        edge='Mo',
                        e0=20000,
                        sample='Mo foil')
        close_last_plot()
        handle.write('mo = 11111.11,    20000.36,    22222.22,   %.5f\n' %
                     pitch)

        handle.flush()
        handle.close()

        #yield from shb.close_plan()

    def cleanup_plan():
        yield from resting_state_plan()

    yield from finalize_wrapper(main_plan(), cleanup_plan())
    yield from resting_state_plan()
    BMM_log_info('High end calibration macro finished!')
 def cleanup_plan():
     ## BMM_clear_suspenders()
     ##RE.clear_suspenders()       # disable suspenders
     yield from resting_state_plan()
 def cleanup_plan():
     ## BMM_clear_suspenders()
     ##user_ns['RE'].clear_suspenders()       # disable suspenders
     yield from resting_state_plan()