Ejemplo n.º 1
0
def clean_images(header, pivot_key, timesource_key, dark_images=None, static_keys=None):
    if static_keys is None:
        static_keys = ["sx", "sy", "temp_a", "temp_b", "sz"]
    # sort out which descriptor has the key we want to pivot on
    pv_desc = [d for d in header["descriptors"] if pivot_key in d["data_keys"]][0]
    # sort out which descriptor has the key that we want to zip with to get time stamps
    ts_desc = [d for d in header["descriptors"] if timesource_key in d["data_keys"]][0]

    ts_events = get_events_generator(ts_desc)
    pv_events = get_events_generator(pv_desc)
    # fill_event works in place, sillyness to work around that
    pv_events = ((ev, fill_event(ev))[0] for ev in pv_events)
    pivoted_events = pivot_timeseries(pv_events, [pivot_key], static_keys)

    if dark_images:
        pivoted_events = correct_events(pivoted_events, pivot_key, dark_images)
    merged_events = zip_events(pivoted_events, ts_events)
    out_ev = reset_time(merged_events, timesource_key)
    yield from out_ev
Ejemplo n.º 2
0
def clean_images(header, pivot_key, timesource_key, dark_images=None, static_keys=None):
    if static_keys is None:
        static_keys = ['sx', 'sy', 'temp_a', 'temp_b', 'sz']
    # sort out which descriptor has the key we want to pivot on
    pv_desc = [d for d in header['descriptors'] if pivot_key in d['data_keys']][0]
    # sort out which descriptor has the key that we want to zip with to get time stamps
    ts_desc = [d for d in header['descriptors'] if timesource_key in d['data_keys']][0]

    ts_events = get_events_generator(ts_desc)
    pv_events = get_events_generator(pv_desc)
    # fill_event works in place, sillyness to work around that
    pv_events = ((ev, fill_event(ev))[0] for ev in pv_events)
    pivoted_events = pivot_timeseries(pv_events, [pivot_key], static_keys)

    if dark_images:
        pivoted_events = correct_events(pivoted_events, pivot_key, dark_images)
    merged_events = zip_events(pivoted_events, ts_events)
    out_ev = reset_time(merged_events, timesource_key)
    yield from out_ev
Ejemplo n.º 3
0
def test_zip_events_lazy():
    dd = _zip_data_helper(('abc', 'def'), 10)
    for ev in zip_events(*dd, lazy=False):
        assert set('abcdef') == set(ev['descriptor']['data_keys'])
        assert set('abcdef') == set(ev['data'])
        assert set('abcdef') == set(ev['timestamps'])
Ejemplo n.º 4
0
def test_zip_events_lazy():
    dd = _zip_data_helper(('abc', 'def'), 10)
    for ev in zip_events(*dd, lazy=False):
        assert set('abcdef') == set(ev['descriptor']['data_keys'])
        assert set('abcdef') == set(ev['data'])
        assert set('abcdef') == set(ev['timestamps'])