Beispiel #1
0
# yrange = extract.get_y_scale(ycen, [400, 600], [5, 5], nrow)

index = extract.make_index(ycen_int - ylow, ycen_int + yhigh, ibeg, iend)
swath_img = img[index]
swath_ycen = ycen[ibeg:iend] - ycen_int[ibeg:iend]
shear = 0
osample = 10

np.savetxt("image.txt", swath_img)
np.savetxt("ycen.txt", swath_ycen)

# return sp, sl, model, unc, mask
# data1 = cwrappers.slitfunc(swath_img, swath_ycen, osample=osample)
data2 = cwrappers.slitfunc_curved(swath_img,
                                  swath_ycen,
                                  shear,
                                  osample=osample,
                                  yrange=(ylow, yhigh))

data = data2
spec = data[0]
slitf = data[1]
model = data[2]
unc = data[3]
mask = data[4]

np.savetxt("spectrum.txt", spec)
np.savetxt("slitfunction.txt", slitf)
np.savetxt("model.txt", model)
np.savetxt("unc.txt", unc)
np.savetxt("mask.txt", mask)
Beispiel #2
0
def test_slitfunc_curved():
    img = np.full((100, 100), 1)
    ycen = np.full(100, 50)
    tilt = np.full(100, 0)
    shear = np.full(100, 0)
    lambda_sp = 0
    lambda_sf = 0.1
    osample = 1
    yrange = (49, 50)

    # Run it once the way it is supposed to
    slitfunc_curved(img, ycen, tilt, shear, lambda_sp, lambda_sf, osample,
                    yrange)
    slitfunc_curved(img, ycen, 1, 0.01, lambda_sp, lambda_sf, osample, yrange)

    # Then try different incompatible inputs, which have to be caught before going to the C code
    with pytest.raises(AssertionError):
        slitfunc_curved(None, ycen, tilt, shear, lambda_sp, lambda_sf, osample,
                        yrange)
    with pytest.raises(ValueError):
        slitfunc_curved("bla", ycen, tilt, shear, lambda_sp, lambda_sf,
                        osample, yrange)

    with pytest.raises(AssertionError):
        slitfunc_curved(img, None, tilt, shear, lambda_sp, lambda_sf, osample,
                        yrange)
    with pytest.raises(ValueError):
        slitfunc_curved(img, "blub", tilt, shear, lambda_sp, lambda_sf,
                        osample, yrange)

    with pytest.raises(AssertionError):
        slitfunc_curved(img, ycen, tilt, None, lambda_sp, lambda_sf, osample,
                        yrange)
    with pytest.raises(ValueError):
        slitfunc_curved(img, ycen, tilt, "boo", lambda_sp, lambda_sf, osample,
                        yrange)

    with pytest.raises(TypeError):
        slitfunc_curved(img, ycen, tilt, shear, None, lambda_sf, osample,
                        yrange)
    with pytest.raises(ValueError):
        slitfunc_curved(img, ycen, tilt, shear, "bla", lambda_sf, osample,
                        yrange)
    with pytest.raises(TypeError):
        slitfunc_curved(img, ycen, tilt, shear, lambda_sp, None, osample,
                        yrange)
    with pytest.raises(ValueError):
        slitfunc_curved(img, ycen, tilt, shear, lambda_sp, "bla", osample,
                        yrange)
    with pytest.raises(TypeError):
        slitfunc_curved(img, ycen, tilt, shear, lambda_sp, lambda_sf, None,
                        yrange)
    with pytest.raises(ValueError):
        slitfunc_curved(img, ycen, tilt, shear, lambda_sp, lambda_sf, "bla",
                        yrange)

    # Then try different sizes for img and ycen
    with pytest.raises(AssertionError):
        ycen_bad = np.full(50, 0, dtype=float)
        slitfunc_curved(img, ycen_bad, tilt, shear, lambda_sp, lambda_sf,
                        osample, yrange)

    with pytest.raises(AssertionError):
        tilt_bad = np.full(50, 0, dtype=float)
        slitfunc_curved(img, ycen, tilt_bad, shear, lambda_sp, lambda_sf,
                        osample, yrange)

    with pytest.raises(AssertionError):
        shear_bad = np.full(50, 0, dtype=float)
        slitfunc_curved(img, ycen, tilt, shear_bad, lambda_sp, lambda_sf,
                        osample, yrange)

    with pytest.raises(AssertionError):
        slitfunc_curved(img, ycen, tilt, shear, lambda_sp, lambda_sf, 0,
                        yrange)
    with pytest.raises(AssertionError):
        slitfunc_curved(img, ycen, tilt, shear, lambda_sp, -1, osample, yrange)
    with pytest.raises(AssertionError):
        slitfunc_curved(img, ycen, tilt, shear, -1, lambda_sf, osample, yrange)
Beispiel #3
0
ycen_int = ycen.astype(int)
# yrange = extract.get_y_scale(ycen, [400, 600], [5, 5], nrow)

index = extract.make_index(ycen_int - ylow, ycen_int + yhigh, ibeg, iend)
swath_img = img[index]
swath_ycen = ycen[ibeg:iend] - ycen_int[ibeg:iend]
shear = 0
osample = 10

np.savetxt("image.txt", swath_img)
np.savetxt("ycen.txt", swath_ycen)

# return sp, sl, model, unc, mask
# data1 = cwrappers.slitfunc(swath_img, swath_ycen, osample=osample)
data2 = cwrappers.slitfunc_curved(swath_img,
                                  swath_ycen,
                                  shear,
                                  osample=osample)

data = data2
spec = data[0]
slitf = data[1]
model = data[2]
unc = data[3]
mask = data[4]

np.savetxt("spectrum.txt", spec)
np.savetxt("slitfunction.txt", slitf)
np.savetxt("model.txt", model)
np.savetxt("unc.txt", unc)
np.savetxt("mask.txt", mask)