Пример #1
0
def test_row_to_spectrum():
    intensities = [10.0, 20.0, 30.0, 40.0, 50.0]
    columns = ["x", "wavelength_1.2", "y", "wavelength_2.3", "z"]
    s = pd.Series(intensities, index=columns)
    x, y = row_to_spectrum(s)
    assert np.array_equal(x, [1.2, 2.3])
    assert np.array_equal(y, [20.0, 40.0])

    x, y = row_to_spectrum(intensities, columns=columns)
    assert np.array_equal(x, [1.2, 2.3])
    assert np.array_equal(y, [20.0, 40.0])
Пример #2
0
def label_spectrum_single(
        row,
        known_emission_lines,
        peak_threshold_fraction,
        label_peaks_strategy,
        filter_elements_fraction,
        delta):

    xs, ys = row_to_spectrum(row)
    px, py = extract_peaks(xs, ys,
        threshold_fraction = peak_threshold_fraction,
        delta = delta)
    filtered_elements = filter_elements(px, known_emission_lines,
        drop_if_below_fraction = filter_elements_fraction,
        delta = delta,
        group_by = ["elt", "ex"])
    e_to_p, p_to_e, unlabeled = label_peaks(
        px,
        known_emission_lines,
        delta = delta,
        strategy = label_peaks_strategy)

    labeled_peaks = json.dumps(p_to_e)
    extra_columns = pd.Series([labeled_peaks], index = ['labeled_peaks'])
    return row.append(extra_columns)