Skip to content

Mfx dod old

led_scan(start, end, nsteps, duration)

Function to scan led delays and dwell at each delay. Goes back to original delay after scanning.

Parameters

start : float Start delay in microseconds. end : float End delay in microseconds. nsteps : integer number of steps for delay. duration : float Dwell time at each delay. In seconds.

Source code in dod/mfx_dod_old.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def led_scan(start, end, nsteps, duration):
    """
    Function to scan led delays and dwell at each delay. Goes back to original delay after scanning.

    Parameters
    ---------
    start : float
        Start delay in microseconds.
    end : float
        End delay in microseconds.
    nsteps : integer
        number of steps for delay.
    duration : float
        Dwell time at each delay. In seconds.
    """

    from hutch_python.utils import safe_load
    import time
    import numpy as np
    from pcdsdevices.evr import Trigger

    with safe_load ('LED'):
        #self.led = Trigger('XCS:R42:EVR:01:TRIG6', name='led_delay')
        led = Trigger('MFX:LAS:EVR:01:TRIG3', name='led_delay')
        #self.led = Trigger('XCS:R44:EVR:44:TRIG6', name='led_delay')
        led_uS = MicroToNano()

    old_led = led.ns_delay.get()
    print('Scanning LED delays...')
    steps = np.linspace(start * 1000.0, end * 1000.0, nsteps)
    for step in steps:
        led.ns_delay.put(step)
        time.sleep(duration)
    led.ns_delay.put(old_led)
    print('Scan complete setting delay back to old value: ' +str(old_led))

perform_run(events, record=True, comment='', post=True, **kwargs)

Perform a single run of the experiment

Parameters

events: int Number of events to include in run

bool, optional

Whether to record the run

str, optional

Comment for ELog

bool, optional

Whether to post to the experimental ELog or not. Will not post if not recording

Note

Source code in dod/mfx_dod_old.py
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
def perform_run(events, record=True, comment='', post=True,
                **kwargs):
    """
    Perform a single run of the experiment

    Parameters
    ----------
    events: int
        Number of events to include in run

    record: bool, optional
        Whether to record the run

    comment : str, optional
        Comment for ELog

    post: bool, optional
        Whether to post to the experimental ELog or not. Will not post if
        not recording

    Note
    ----
    """
    import logging
    logger = logging.getLogger(__name__)
    import time
    import elog
    from mfx.db import daq

    comment = comment or ''
    # Start recording
    logger.info("Starting DAQ run, -> record=%s", record)
    daq.begin(events=events, record=record)
    time.sleep(1)
    # Post to ELog if desired
    runnum = daq._control.runnumber()
    info = [runnum, comment, events, self._delaystr]
    post_msg = post_template.format(*info)
    print(post_msg)
    if post and record:
        elog(msg=post_msg, run=runnum)

    # Wait for the DAQ to finish
    logger.info("Waiting or DAQ to complete %s events ...", events)
    daq.wait()
    logger.info("Run complete!")
    daq.end_run()
    time.sleep(0.5)
    return