Пример #1
0
def test_NIRCAMForwardRowGrismDispersion():
    xmodels = [
        Polynomial1D(1, c0=0.59115385, c1=0.00038615),
        Polynomial1D(1, c0=-0.16596154, c1=0.00019308)
    ]
    ymodels = [Polynomial1D(1, c0=0., c1=0.), Polynomial1D(1, c0=0., c1=0.)]
    lmodels = [
        Polynomial1D(1, c0=2.4, c1=2.6),
        Polynomial1D(1, c0=2.4, c1=2.6)
    ]
    model = transforms.NIRCAMForwardRowGrismDispersion([1, 2], lmodels,
                                                       xmodels, ymodels)

    x0 = 913.7
    y0 = 15.5
    order = 1

    slit = create_slit(model, x0, y0, order)

    expected = np.array([[
        3.03973415, 3.04073814, 3.04174213, 3.04274612, 3.04375011, 3.0447541
    ], [3.03973415, 3.04073814, 3.04174213, 3.04274612, 3.04375011, 3.0447541],
                         [
                             3.03973415, 3.04073814, 3.04174213, 3.04274612,
                             3.04375011, 3.0447541
                         ],
                         [
                             3.03973415, 3.04073814, 3.04174213, 3.04274612,
                             3.04375011, 3.0447541
                         ],
                         [
                             3.03973415, 3.04073814, 3.04174213, 3.04274612,
                             3.04375011, 3.0447541
                         ],
                         [
                             3.03973415, 3.04073814, 3.04174213, 3.04274612,
                             3.04375011, 3.0447541
                         ]])

    # refactored call
    x, y = grid_from_bounding_box(slit.meta.wcs.bounding_box)
    wavelength = compute_wavelength_array(
        slit
    )  # x, y, np.zeros(x.shape)  +x0, np.zeros(y.shape)+y0, np.zeros(x.shape)+order)
    assert_allclose(wavelength, expected)

    with pytest.raises(ValueError):
        slit = create_slit(model, x0, y0, 3)
        compute_wavelength_array(slit)
Пример #2
0
def test_NIRCAMForwardColumnGrismDispersion():
    ymodels = [
        Polynomial1D(1, c0=0.5911538461431823, c1=0.000386153846153726),
        Polynomial1D(1, c0=-0.1659615384582264, c1=0.0001930769230768787)
    ]

    xmodels = [Polynomial1D(1, c0=0., c1=0.), Polynomial1D(1, c0=0., c1=0.)]
    lmodels = [
        Polynomial1D(1, c0=2.4, c1=2.6),
        Polynomial1D(1, c0=2.4, c1=2.6)
    ]
    model = transforms.NIRCAMForwardColumnGrismDispersion([1, 2], lmodels,
                                                          xmodels, ymodels)

    x0 = 913.7
    y0 = 15.5
    order = 1

    slit = create_slit(model, x0, y0, order)
    expected = np.array(
        [[4.724638, 4.724638, 4.724638, 4.724638, 4.724638, 4.724638],
         [4.725642, 4.725642, 4.725642, 4.725642, 4.725642, 4.725642],
         [4.726646, 4.726646, 4.726646, 4.726646, 4.726646, 4.726646],
         [4.72765, 4.72765, 4.72765, 4.72765, 4.72765, 4.72765],
         [4.728654, 4.728654, 4.728654, 4.728654, 4.728654, 4.728654],
         [4.729658, 4.729658, 4.729658, 4.729658, 4.729658, 4.729658]])

    # refactored call
    x, y = grid_from_bounding_box(slit.meta.wcs.bounding_box)
    wavelength = compute_wavelength_array(
        slit
    )  # x, y, np.zeros(x.shape)  +x0, np.zeros(y.shape)+y0, np.zeros(x.shape)+order)
    assert_allclose(wavelength, expected)

    with pytest.raises(ValueError):
        slit = create_slit(model, x0, y0, 3)
        compute_wavelength_array(slit)
Пример #3
0
def test_NIRISSForwardColumnGrismDispersion():
    ymodels = [[
        Polynomial2D(2,
                     c0_0=-1.876215,
                     c1_0=-5.179793e-04,
                     c2_0=2.116366e-08,
                     c0_1=-2.259297e-04,
                     c0_2=-2.502127e-12,
                     c1_1=4.771951e-08),
        Polynomial2D(2,
                     c0_0=-3.089115,
                     c1_0=3.063270e-03,
                     c2_0=-9.786785e-07,
                     c0_1=1.237905e-03,
                     c0_2=-1.510774e-11,
                     c1_1=-5.405480e-09)
    ]]

    xmodels = [[
        Polynomial2D(2,
                     c0_0=63.55173,
                     c1_0=3.846599e-06,
                     c2_0=-7.173816e-10,
                     c0_1=8.158127e-07,
                     c0_2=-1.274281e-09,
                     c1_1=4.098804e-11),
        Polynomial2D(2,
                     c0_0=-331.8532,
                     c1_0=-1.24494e-05,
                     c2_0=4.210112e-10,
                     c0_1=-1.615311e-06,
                     c0_2=6.665276e-09,
                     c1_1=1.43762e-10)
    ]]

    lmodels = [
        Polynomial1D(1, c0=0.75, c1=1.55),
        Polynomial1D(1, c0=0.75, c1=1.55)
    ]

    model = transforms.NIRISSForwardColumnGrismDispersion([1, 2, 3, -1],
                                                          lmodels=lmodels,
                                                          xmodels=xmodels,
                                                          ymodels=ymodels,
                                                          theta=33.5677)

    x0 = 913.7
    y0 = 15.5
    order = 1

    slit = create_slit(model, x0, y0, order)
    slit.meta.wcs.bounding_box = ((910, 916), (12, 18))

    expected = np.array([[
        1.05844596, 1.05844596, 1.05844596, 1.05844596, 1.05844596, 1.05844596,
        1.05844596
    ],
                         [
                             1.0500404, 1.0500404, 1.0500404, 1.0500404,
                             1.0500404, 1.0500404, 1.0500404
                         ],
                         [
                             1.04163483, 1.04163483, 1.04163483, 1.04163483,
                             1.04163483, 1.04163483, 1.04163483
                         ],
                         [
                             1.03322927, 1.03322927, 1.03322927, 1.03322927,
                             1.03322927, 1.03322927, 1.03322927
                         ],
                         [
                             1.02482371, 1.02482371, 1.02482371, 1.02482371,
                             1.02482371, 1.02482371, 1.02482371
                         ],
                         [
                             1.01641815, 1.01641815, 1.01641815, 1.01641815,
                             1.01641815, 1.01641815, 1.01641815
                         ],
                         [
                             1.00801258, 1.00801258, 1.00801258, 1.00801258,
                             1.00801258, 1.00801258, 1.00801258
                         ]])

    # refactored call
    x, y = grid_from_bounding_box(slit.meta.wcs.bounding_box)
    wavelength = compute_wavelength_array(slit)
    assert_allclose(wavelength, expected)