Beispiel #1
0
def test_get_y_scale(ycen, height, width):
    xrange = (0, width)
    xwd = (10, 10)
    y_lower_lim, y_upper_lim = extract.get_y_scale(ycen, xrange, xwd, height)

    assert isinstance(y_lower_lim, int)
    assert isinstance(y_upper_lim, int)
    assert y_lower_lim >= 0
    assert y_upper_lim < height

    xwd = (2 * height, 2 * height)
    y_lower_lim, y_upper_lim = extract.get_y_scale(ycen, xrange, xwd, height)
    assert isinstance(y_lower_lim, int)
    assert isinstance(y_upper_lim, int)
    assert y_lower_lim >= 0
    assert y_upper_lim < height

    ycen_tmp = ycen + height
    xwd = (10, 10)
    y_lower_lim, y_upper_lim = extract.get_y_scale(ycen_tmp, xrange, xwd,
                                                   height)
    assert isinstance(y_lower_lim, int)
    assert isinstance(y_upper_lim, int)
    assert y_lower_lim >= 0
    assert y_upper_lim < height
Beispiel #2
0
def test_extract_spectrum(sample_data, orders, ycen, width, height):
    img, spec, slitf = sample_data

    column_range = np.array([[20, width]])
    extraction_width = np.array([[10, 10]])

    yrange = extract.get_y_scale(ycen, column_range[0], extraction_width[0],
                                 height)
    xrange = column_range[0]

    out_spec = np.zeros(width)
    out_sunc = np.zeros(width)
    out_slitf = np.zeros(10 + 10 + 2 + 1)
    out_mask = np.zeros(width)

    extract.extract_spectrum(
        np.copy(img),
        np.copy(ycen),
        np.copy(yrange),
        np.copy(xrange),
        out_spec=out_spec,
        out_sunc=out_sunc,
        out_slitf=out_slitf,
        out_mask=out_mask,
    )

    assert np.any(out_spec != 0)
    assert np.any(out_sunc != 0)
    assert np.any(out_slitf != 0)
    assert np.any(out_mask)

    spec, slitf, mask, sunc = extract.extract_spectrum(np.copy(img),
                                                       np.copy(ycen),
                                                       np.copy(yrange),
                                                       np.copy(xrange))

    assert np.array_equal(out_spec, spec)
    assert np.array_equal(out_sunc, sunc)
    assert np.array_equal(out_slitf, slitf)
    assert np.array_equal(out_mask, mask)