コード例 #1
0
def test_imatch_background_reset(_jail, miri_dither_ch12):
    """ Test if background polynomail is already determined - reset it"""

    all_models = datamodels.ModelContainer(miri_dither_ch12)

    # added a background and test is reset background
    # removes the background
    new_container = []
    degree = (1, 1, 1,)
    center = (5, 5, 5,)
    poly = np.ndarray(9)
    poly[:] = 1.3
    channel = '2'
    for m in all_models:
        m.meta.background.polynomial_info.append(
            {
                'degree': degree,
                'refpoint': center,
                'coefficients': poly.ravel().tolist(),
                'channel': channel
            }
        )
        new_container.append(m)

    # test if reset backgound - removes background
    step = MRSIMatchStep()
    step._reset_background(new_container)

    for i in range(len(new_container)):
        m = new_container[i]
        test = len(m.meta.background.polynomial_info)
        assert test == 0
コード例 #2
0
def test_imatch_background_subtracted(_jail, miri_dither_ch12):
    """ Test if data is already background subtracted - raise error"""

    all_models = datamodels.ModelContainer(miri_dither_ch12)
    # modify the data set backgroud subtracted
    new_container = []
    for m in all_models:
        m.meta.background.subtracted = True
        new_container.append(m)

    # test if background subtracted - raise error
    with pytest.raises(ValueError):
        step = MRSIMatchStep()
        step.run(new_container)
コード例 #3
0
def test_imatch_degree(_jail, miri_dither_ch12):
    """ Test if polynomial degree is not a 3 element tuple or integer then raise error """

    all_models = datamodels.ModelContainer(miri_dither_ch12)
    new_container = []
    degree = (
        1,
        1,
        1,
    )
    center = (
        5,
        5,
        5,
    )
    poly = np.ndarray(9)
    poly[:] = 1.3
    channel = '2'
    for m in all_models:
        m.meta.background.polynomial_info.append({
            'degree':
            degree,
            'refpoint':
            center,
            'coefficients':
            poly.ravel().tolist(),
            'channel':
            channel
        })
        new_container.append(m)

    # test catches degree set incorrectly - raise error
    #  check that degree must be a 3 element tuple
    with pytest.raises(ValueError):
        step = MRSIMatchStep()
        step.bkg_degree = (
            1,
            1,
        )
        step.run(new_container)