Beispiel #1
0
def test_combine_latest():
    a = Stream()
    b = Stream()
    c = a.combine_latest(b)
    d = a.combine_latest(b, emit_on=[a, b])

    L = c.sink_to_list()
    L2 = d.sink_to_list()

    a.emit(1)
    a.emit(2)
    b.emit("a")
    a.emit(3)
    b.emit("b")

    assert L == [(2, "a"), (3, "a"), (3, "b")]
    assert L2 == [(2, "a"), (3, "a"), (3, "b")]
Beispiel #2
0
def test_combine_latest_emit_on_stream():
    a = Stream()
    b = Stream()
    c = a.combine_latest(b, emit_on=0)

    L = c.sink_to_list()

    a.emit(1)
    b.emit("a")
    a.emit(2)
    a.emit(3)
    b.emit("b")
    a.emit(4)

    assert L == [(2, "a"), (3, "a"), (4, "b")]
Beispiel #3
0
from rapidz import Stream
from operator import add

source1 = Stream(stream_name="source1")
source2 = Stream(stream_name="source2")
source3 = Stream(stream_name="awesome source")

n1 = source1.zip(source2)
n2 = n1.map(add)
n3 = n2.zip(source3)
L = n3.sink_to_list()

n2.visualize("simple.png")

# Rapidz can also visualize more complex graphs
n4 = source1.combine_latest(source2, n1, emit_on=(0, 1))
n4.connect(n3)
nm = n4.scatter(backend='thread').map(add)

# Rapidz can even graph cyclical graphs!
n3.connect(source3)

n2.visualize("complex.png")
Beispiel #4
0
    map_to_binner,
    generate_map_bin,
    move_center,
)

mask_setting = {"setting": "auto"}

motors = Stream(stream_name="motor positions")
raw_foreground = Stream(stream_name="raw foreground")
raw_foreground_dark = Stream(stream_name="raw foreground dark")
raw_background = Stream(stream_name="raw background")
raw_background_dark = Stream(stream_name="raw background dark")

# Get the image shape for the binner
dark_corrected_foreground = raw_foreground.combine_latest(raw_foreground_dark,
                                                          emit_on=0).starmap(
                                                              op.sub)
dark_corrected_background = raw_background.combine_latest(raw_background_dark,
                                                          emit_on=0).starmap(
                                                              op.sub)
bg_corrected_img = dark_corrected_foreground.combine_latest(
    dark_corrected_background,
    emit_on=0).starmap(op.sub, stream_name="background corrected img")

# Calibration management
wavelength = Stream(stream_name="wavelength")
calibrant = Stream(stream_name="calibrant")
detector = Stream(stream_name="detector")
is_calibration_img = Stream(stream_name="Is Calibration")
geo_input = Stream(stream_name="geometry")
gated_cal = (bg_corrected_img.combine_latest(
Beispiel #5
0
def radiograph_correction(img: Stream, dark: Stream, flat_field: Stream,
                          **kwargs):
    norm_img = img.combine_latest(flat_field, dark,
                                  emit_on=0).starmap(normalize)

    return locals()