Exemple #1
0
def run(run_start=None, sleep=0):
    if sleep != 0:
        raise NotImplementedError("A sleep time is not implemented for this "
                                  "example.")
    # Make the data
    ramp = common.stepped_ramp(start, stop, step, points_per_step)
    deadbanded_ramp = common.apply_deadband(ramp, deadband_size)

    # Create Event Descriptors
    data_keys = {'Tsam': dict(source='PV:ES:Tsam', dtype='number'),
                 'point_det': dict(source='PV:ES:point_det', dtype='number')}
    ev_desc = insert_descriptor(run_start=run_start,
                                      data_keys=data_keys, time=0.,
                                      uid=str(uuid.uuid4()))

    # Create Events.
    events = []

    # Temperature Events
    for i, (time, temp) in enumerate(zip(*deadbanded_ramp)):
        time = float(time)
        point_det = np.random.randn()
        data = {'Tsam': temp, 'point_det': point_det}
        timestamps = {'Tsam': time, 'point_det': time}
        event_uid = insert_event(descriptor=ev_desc, time=time, data=data,
                                 seq_num=i, timestamps=timestamps,
                                 uid=str(uuid.uuid4()))
        event, = find_events(uid=event_uid)
        events.append(event)

    return events
Exemple #2
0
def run(run_start=None, sleep=0):
    if sleep != 0:
        raise NotImplementedError("A sleep time is not implemented for this "
                                  "example.")
    # Make the data
    ramp = common.stepped_ramp(start, stop, step, points_per_step)
    deadbanded_ramp = common.apply_deadband(ramp, deadband_size)
    rs = np.random.RandomState(5)
    point_det_data = rs.randn(num_exposures)

    # Create Event Descriptors
    data_keys1 = {'point_det': dict(source='PV:ES:PointDet', dtype='number')}
    data_keys2 = {
        'Tsam': dict(source='PV:ES:Tsam', dtype='number'),
        'Troom': dict(source='PV:ES:Troom', dtype='number')
    }
    ev_desc1_uid = insert_descriptor(run_start=run_start,
                                     data_keys=data_keys1,
                                     time=common.get_time(),
                                     uid=str(uuid.uuid4()))
    ev_desc2_uid = insert_descriptor(run_start=run_start,
                                     data_keys=data_keys2,
                                     time=common.get_time(),
                                     uid=str(uuid.uuid4()))
    print('event descriptor 1 uid = {0!s}'.format(ev_desc1_uid))
    print('event descriptor 2 uid = {0!s}'.format(ev_desc2_uid))
    # Create Events.
    events = []

    # Point Detector Events
    base_time = common.get_time()
    for i in range(num_exposures):
        time = float(i + 0.5 * rs.randn()) + base_time
        data = {'point_det': (point_det_data[i], time)}
        data = {'point_det': point_det_data[i]}
        timestamps = {'point_det': time}
        event_uid = insert_event(descriptor=ev_desc1_uid,
                                 seq_num=i,
                                 time=time,
                                 data=data,
                                 uid=str(uuid.uuid4()),
                                 timestamps=timestamps)
        event, = find_events(uid=event_uid)
        events.append(event)

    # Temperature Events
    for i, (time, temp) in enumerate(zip(*deadbanded_ramp)):
        time = float(time) + base_time
        data = {'Tsam': temp, 'Troom': temp + 10}
        timestamps = {'Tsam': time, 'Troom': time}
        event_uid = insert_event(descriptor=ev_desc2_uid,
                                 time=time,
                                 data=data,
                                 seq_num=i,
                                 uid=str(uuid.uuid4()),
                                 timestamps=timestamps)
        event, = find_events(uid=event_uid)
        events.append(event)
    return events
def run(run_start_uid=None, sleep=0):
    if sleep != 0:
        raise NotImplementedError("A sleep time is not implemented for this "
                                  "example.")
    # Make the data
    ramp = common.stepped_ramp(start, stop, step, points_per_step)
    deadbanded_ramp = common.apply_deadband(ramp, deadband_size)
    rs = np.random.RandomState(5)
    point_det_data = rs.randn(num_exposures) + np.arange(num_exposures)

    # Create Event Descriptors
    data_keys1 = {'point_det': dict(source='PV:ES:PointDet', dtype='number')}
    data_keys2 = {'Tsam': dict(source='PV:ES:Tsam', dtype='number')}
    ev_desc1_uid = insert_descriptor(run_start=run_start_uid,
                                     data_keys=data_keys1,
                                     time=common.get_time(),
                                     uid=str(uuid.uuid4()),
                                     name='primary')
    ev_desc2_uid = insert_descriptor(run_start=run_start_uid,
                                     data_keys=data_keys2,
                                     time=common.get_time(),
                                     uid=str(uuid.uuid4()),
                                     name='baseline')

    # Create Events.
    events = []

    # Point Detector Events
    base_time = common.get_time()
    for i in range(num_exposures):
        time = float(2 * i + 0.5 * rs.randn()) + base_time
        data = {'point_det': point_det_data[i]}
        timestamps = {'point_det': time}
        event_dict = dict(descriptor=ev_desc1_uid, seq_num=i,
                          time=time, data=data, timestamps=timestamps,
                          uid=str(uuid.uuid4()))
        event_uid = insert_event(**event_dict)
        # grab the actual event from metadatastore
        event, = find_events(uid=event_uid)
        events.append(event)
        assert event['data'] == event_dict['data']

    # Temperature Events
    for i, (time, temp) in enumerate(zip(*deadbanded_ramp)):
        time = float(time) + base_time
        data = {'Tsam': temp}
        timestamps = {'Tsam': time}
        event_dict = dict(descriptor=ev_desc2_uid, time=time,
                          data=data, timestamps=timestamps, seq_num=i,
                          uid=str(uuid.uuid4()))
        event_uid = insert_event(**event_dict)
        event, = find_events(uid=event_uid)
        events.append(event)
        assert event['data'] == event_dict['data']

    return events
def run(mds, run_start=None, sleep=0):
    if sleep != 0:
        raise NotImplementedError("A sleep time is not implemented for this "
                                  "example.")
    # Make the data
    ramp = common.stepped_ramp(start, stop, step, points_per_step)
    deadbanded_ramp = common.apply_deadband(ramp, deadband_size)
    rs = np.random.RandomState(5)
    point_det_data = rs.randn(num_exposures)

    # Create Event Descriptors
    data_keys1 = {'point_det': dict(source='PV:ES:PointDet',
                                    dtype='number')}
    data_keys2 = {'Tsam': dict(source='PV:ES:Tsam', dtype='number'),
                  'Troom': dict(source='PV:ES:Troom', dtype='number')}
    ev_desc1_uid = mds.insert_descriptor(run_start=run_start,
                                         data_keys=data_keys1,
                                         time=common.get_time(),
                                         uid=str(uuid.uuid4()))
    ev_desc2_uid = mds.insert_descriptor(run_start=run_start,
                                         data_keys=data_keys2,
                                         time=common.get_time(),
                                         uid=str(uuid.uuid4()))
    # Create Events.
    events = []

    # Point Detector Events
    base_time = common.get_time()
    for i in range(num_exposures):
        time = float(i + 0.5 * rs.randn()) + base_time
        data = {'point_det': point_det_data[i]}
        timestamps = {'point_det': time}
        event_uid = mds.insert_event(descriptor=ev_desc1_uid,
                                     seq_num=i, time=time, data=data,
                                     uid=str(uuid.uuid4()),
                                     timestamps=timestamps)
        event, = mds.find_events(uid=event_uid)
        events.append(event)

    # Temperature Events
    for i, (time, temp) in enumerate(zip(*deadbanded_ramp)):
        time = float(time) + base_time
        data = {'Tsam': temp,
                'Troom': temp + 10}
        timestamps = {'Tsam': time,
                      'Troom': time}
        event_uid = mds.insert_event(descriptor=ev_desc2_uid,
                                     time=time, data=data, seq_num=i,
                                     uid=str(uuid.uuid4()),
                                     timestamps=timestamps)
        event, = mds.find_events(uid=event_uid)
        events.append(event)
    return events
Exemple #5
0
def run(run_start=None, sleep=0):
    if sleep != 0:
        raise NotImplementedError("A sleep time is not implemented for this " "example.")
    # Make the data
    ramp = common.stepped_ramp(start, stop, step, points_per_step)
    deadbanded_ramp = common.apply_deadband(ramp, deadband_size)

    # Create Event Descriptors
    data_keys = {
        "Tsam": dict(source="PV:ES:Tsam", dtype="number"),
        "point_det": dict(source="PV:ES:point_det", dtype="number"),
    }
    conf = {
        "point_det": {
            "data_keys": {"exposure_time": {"source": "PS:ES:point_det_exp"}},
            "data": {"exposure_time": 5},
            "timestamps": {"exposure_time": 0.0},
        }
    }
    ev_desc = insert_descriptor(
        run_start=run_start, data_keys=data_keys, time=0.0, uid=str(uuid.uuid4()), configuration=conf
    )

    # Create Events.
    events = []

    # Temperature Events
    for i, (time, temp) in enumerate(zip(*deadbanded_ramp)):
        time = float(time)
        point_det = np.random.randn()
        data = {"Tsam": temp, "point_det": point_det}
        timestamps = {"Tsam": time, "point_det": time}
        event_uid = insert_event(
            descriptor=ev_desc, time=time, data=data, seq_num=i, timestamps=timestamps, uid=str(uuid.uuid4())
        )
        event, = find_events(uid=event_uid)
        events.append(event)

    return events
def test_bad_deadbands():
    # the -1 should throw a ValueError
    apply_deadband(None, -1)
def run(mds, run_start_uid=None, sleep=0):
    if sleep != 0:
        raise NotImplementedError("A sleep time is not implemented for this "
                                  "example.")
    # Make the data
    ramp = common.stepped_ramp(start, stop, step, points_per_step)
    deadbanded_ramp = common.apply_deadband(ramp, deadband_size)
    rs = np.random.RandomState(5)
    point_det_data = rs.randn(num_exposures) + np.arange(num_exposures)

    # Create Event Descriptors
    data_keys1 = {
        'point_det': dict(source='PV:ES:PointDet', dtype='number'),
        'boolean_det': dict(source='PV:ES:IntensityDet', dtype='string'),
        'ccd_det_info': dict(source='PV:ES:CCDDet', dtype='list')
    }
    data_keys2 = {'Tsam': dict(source='PV:ES:Tsam', dtype='number')}
    ev_desc1_uid = mds.insert_descriptor(run_start=run_start_uid,
                                         data_keys=data_keys1,
                                         time=common.get_time(),
                                         uid=str(uuid.uuid4()),
                                         name='primary')
    ev_desc2_uid = mds.insert_descriptor(run_start=run_start_uid,
                                         data_keys=data_keys2,
                                         time=common.get_time(),
                                         uid=str(uuid.uuid4()),
                                         name='baseline')

    # Create Events.
    events = []

    # Point Detector Events
    base_time = common.get_time()
    for i in range(num_exposures):
        time = float(2 * i + 0.5 * rs.randn()) + base_time
        data = {
            'point_det': point_det_data[i],
            'boolean_det': 'Yes',
            'ccd_det_info': ['on', 'off']
        }
        timestamps = {
            'point_det': time,
            'boolean_det': time,
            'ccd_det_info': time
        }
        event_dict = dict(descriptor=ev_desc1_uid,
                          seq_num=i,
                          time=time,
                          data=data,
                          timestamps=timestamps,
                          uid=str(uuid.uuid4()))
        event_uid = mds.insert_event(**event_dict)
        # grab the actual event from metadatastore
        event, = mds.find_events(uid=event_uid)
        events.append(event)
        assert event['data'] == event_dict['data']

    # Temperature Events
    for i, (time, temp) in enumerate(zip(*deadbanded_ramp)):
        time = float(time) + base_time
        data = {'Tsam': temp}
        timestamps = {'Tsam': time}
        event_dict = dict(descriptor=ev_desc2_uid,
                          time=time,
                          data=data,
                          timestamps=timestamps,
                          seq_num=i,
                          uid=str(uuid.uuid4()))
        event_uid = mds.insert_event(**event_dict)
        event, = mds.find_events(uid=event_uid)
        events.append(event)
        assert event['data'] == event_dict['data']

    return events
Exemple #8
0
def test_bad_deadbands():
    # the -1 should throw a ValueError
    with pytest.raises(ValueError):
        apply_deadband(None, -1)
def test_bad_deadbands():
    # the -1 should throw a ValueError
    with pytest.raises(ValueError):
        apply_deadband(None, -1)
def test_bad_deadbands():
    # the -1 should throw a ValueError
    apply_deadband(None, -1)