示例#1
0
def generate_mask_func(data, store, signal, context):
    logger.debug("Generating mask")
    md = data['md']
    mask = generate_mask(**md)['mask']
    data['mask'] = mask

    # pass the stream name
    data['md']['stream_name'] = context.task_name
示例#2
0
def to_thumb_func(data, store, signal, context):
    logger.debug("Making thumb of image")
    data_dict = dict(img=data['img'])
    attrs = data['md']
    store_results_mpl(data_dict, attrs, images=['img'])

    # pass the stream name
    data['md']['stream_name'] = context.task_name
示例#3
0
def parse_attributes_func(data, store, signal, context):
    logger.debug("Parsing attributes")
    md = data['md']
    md = normalize_calib_dict(**md)
    md = add_detector_info(**md)
    #print("parse attributes, final metadata: {}".format(md))
    data['md'] = md

    # pass the stream name
    data['md']['stream_name'] = context.task_name
示例#4
0
def make_calibration_func(data, store, signal, context):
    logger.debug("Making calibration")
    md = data['md']
    #print("making calibration from metadata {}".format(md))
    calibration = make_calibration(**md)
    calibration.generate_maps()
    #print("done")
    data['calibration'] = calibration

    # pass the stream name
    data['md']['stream_name'] = context.task_name
示例#5
0
def qphiavg_plot_func(data, store, signal, context):
    logger.debug("Plotting qphiavg")
    data_dict = dict(sqphi=data['sqphi'])
    attr = data['md']
    attr['stream_name'] = 'qphiavg'
    store_results_mpl(
        data_dict,
        attr,
        img_norm=normalizer,
        aspect='auto',
        images=['sqphi'],
        xlabel="$\phi\,$(radians)",
        ylabel="$q\,$(pixel)",
    )
示例#6
0
def qphiavg_func(data, store, signal, context):
    logger.debug("making qphiavg")
    image = data['img']
    calibration = data.get_by_alias('calibration')['calibration']
    q_map = calibration.q_map
    phi_map = calibration.angle_map
    mask = data.get_by_alias('mask')['mask']
    data['sqphi'] = qphiavg(image,
                            q_map=None,
                            phi_map=None,
                            mask=None,
                            bins=(800, 360),
                            origin=None,
                            range=None,
                            statistic='mean')
    data['md']['stream_name'] = context.task_name
示例#7
0
def circavg_plot_func(data, store, signal, context):
    logger.debug("Plotting circular average")
    data_dict = dict()
    data_dict['sqx'] = data['sqx']
    data_dict['sqy'] = data['sqy']
    attrs = data['md']
    xlbl = "$q\,(\AA^\{-1\})$"
    ylbl = "$I(q)$"
    store_results_mpl(
        data_dict,
        attrs,
        lines=[('sqx', 'sqy')],
        scale='loglog',
        xlabel=xlbl,
        ylabel=ylbl,
    )
示例#8
0
def peakfind_func(data, signal, store, context):
    logger.debug("Finding peaks")
    from SciStreams.processing.peak_finding import peak_finding

    sqx = data['sqx']
    sqy = data['sqy']

    res = peak_finding(intensity=sqy, frac=0.0001).peak_position()

    model = res[0]
    y_origin = res[1]
    inds_peak = res[2]
    xdata = res[3]
    ratio = res[4]
    ydata = res[5]
    wdata = res[6]
    bkgd = res[7]
    variance = res[8]
    variance_mean = res[9]

    peaksx = list()
    peaksy = list()

    for ind in inds_peak:
        peaksx.append(sqx[ind])
        peaksy.append(sqy[ind])

    res_dict = dict(
        model=model,
        y_origin=y_origin,
        inds_peak=inds_peak,
        xdata=xdata,
        ratio=ratio,
        ydata=ydata,
        wdata=wdata,
        bkgd=bkgd,
        variance=variance,
        variance_mean=variance_mean,
        peaksx=peaksx,
        peaksy=peaksy,
    )
    for key in res_dict.keys():
        data[key] = res_dict[key]
    data['md']['stream_name'] = context.task_name
示例#9
0
def peakfind_plot_func(data, store, signal, context):
    logger.debug("Plotting found peaks")
    data['md']['stream_name'] = 'peakfind'
    data_dict = dict()
    data_dict['sqx'] = data['sqx']
    data_dict['sqy'] = data['sqy']
    data_dict['peaksx'] = data['peaksx']
    data_dict['peaksy'] = data['peaksy']
    xlbl = "$q,(\AA^{-1})$"
    ylbl = "I(q)"
    store_results_mpl(
        data_dict,
        data['md'],
        lines=[
            dict(x='sqx', y='sqy'),
            dict(x='peaksx', y='peaksy', marker='o', color='r', linewidth=0)
        ],
        xlabel=xlbl,
        ylabel=ylbl,
        scale='loglog',
    )
示例#10
0
def circavg_func(data, store, signal, context):
    logger.debug("Computing circular average")
    image = data.get_by_alias('image')['img']
    calibration = data.get_by_alias('calibration')['calibration']
    q_map = calibration.q_map
    r_map = calibration.r_map
    mask = data.get_by_alias('mask')['mask']
    #print("computing circavg")
    #print("q_map: {}".format(q_map))
    #print("r_map: {}".format(r_map))
    #print("image: {}".format(image))
    #print("mask: {}".format(mask))
    res = circavg(image, q_map=q_map, r_map=r_map, mask=mask)
    #print("done")
    data['sqx'] = res['sqx']
    data['sqxerr'] = res['sqxerr']
    data['sqy'] = res['sqy']
    data['sqyerr'] = res['sqyerr']

    # pass the stream name
    data['md']['stream_name'] = context.task_name
示例#11
0
def input_func(data, store, signal, context):
    # pass the stream name
    logger.debug("Beginning of one image pipeline")
    data['md']['stream_name'] = context.task_name