Esempio n. 1
0
def test_header_offset(adinputs2, caplog):
    """Test that the offset is correctly read from the headers."""
    p = GMOSLongslit(adinputs2)
    adout = p.adjustWCSToReference(method='offsets')

    for rec in caplog.records:
        assert not rec.message.startswith('WARNING - Offset from correlation')

    assert np.isclose(adout[0].phu['SLITOFF'], 0)
    assert np.isclose(adout[1].phu['SLITOFF'], -92.9368)
    assert np.isclose(adout[2].phu['SLITOFF'], -92.9368)
    assert np.isclose(adout[3].phu['SLITOFF'], 0)
Esempio n. 2
0
def test_correlation_and_w1_w2(adinputs, caplog):
    add_fake_offset(adinputs, offset=10)
    p = GMOSLongslit(adinputs)
    adout = p.adjustWCSToReference()

    assert adout[1].phu['SLITOFF'] == -10
    assert adout[2].phu['SLITOFF'] == -20

    p.resampleToCommonFrame(dw=0.15, w1=700, w2=850)
    _check_params(caplog.records, 'w1=700.000 w2=850.000 dw=0.150 npix=1001')

    adstack = p.stackFrames()
    assert adstack[0][0].shape == (512, 1001)
Esempio n. 3
0
def test_header_offset_fallback(adinputs2, caplog):
    """For this dataset the correlation method fails, and give an offset very
    different from the header one. So we check that the fallback to the header
    offset works.
    """
    p = GMOSLongslit(adinputs2)
    adout = p.adjustWCSToReference()

    # WARNING when offset is too large
    assert caplog.records[3].message.startswith('WARNING - Offset for')

    assert np.isclose(adout[0].phu['SLITOFF'], 0)
    assert np.isclose(adout[1].phu['SLITOFF'], -92.9368)
    assert np.isclose(adout[2].phu['SLITOFF'], -92.9368)
    assert np.isclose(adout[3].phu['SLITOFF'], 0, atol=0.2, rtol=0)
Esempio n. 4
0
def test_correlation_non_linearize(adinputs, caplog):
    add_fake_offset(adinputs, offset=10)
    p = GMOSLongslit(adinputs)
    adout = p.adjustWCSToReference()

    assert adout[1].phu['SLITOFF'] == -10
    assert adout[2].phu['SLITOFF'] == -20

    p.resampleToCommonFrame(force_linear=False)
    _check_params(caplog.records, 'w1=508.198 w2=1088.323 dw=0.151 npix=3841')
    caplog.clear()
    adout = p.resampleToCommonFrame(dw=0.15)
    assert 'ALIGN' in adout[0].phu
    _check_params(caplog.records, 'w1=508.198 w2=1088.232 dw=0.150 npix=3868')

    adstack = p.stackFrames()
    assert adstack[0][0].shape == (512, 3868)
Esempio n. 5
0
def test_correlation_and_trim(adinputs, caplog):
    add_fake_offset(adinputs, offset=10)
    p = GMOSLongslit(adinputs)
    adout = p.adjustWCSToReference()

    assert adout[1].phu['SLITOFF'] == -10
    assert adout[2].phu['SLITOFF'] == -20

    p.resampleToCommonFrame(dw=0.15, trim_data=True)
    _check_params(caplog.records, 'w1=508.198 w2=978.802 dw=0.150 npix=3139')

    ad = p.stackFrames()[0]
    assert ad[0].shape == (512, 3139)

    caplog.clear()
    ad = p.findSourceApertures(max_apertures=1)[0]
    assert len(ad[0].APERTURE) == 1
    np.testing.assert_allclose(ad[0].APERTURE['c0'], 260.8, atol=0.25)

    ad = p.extract1DSpectra()[0]
    assert ad[0].shape == (3139, )
Esempio n. 6
0
def test_correlation(adinputs, caplog):
    add_fake_offset(adinputs, offset=10)
    p = GMOSLongslit(adinputs)
    adout = p.adjustWCSToReference()

    assert adout[1].phu['SLITOFF'] == -10
    assert adout[2].phu['SLITOFF'] == -20

    p.resampleToCommonFrame(dw=0.15)
    _check_params(caplog.records, 'w1=508.198 w2=1088.323 dw=0.150 npix=3869')

    ad = p.stackFrames()[0]
    assert ad[0].shape == (512, 3869)

    caplog.clear()
    ad = p.findSourceApertures(max_apertures=1)[0]
    assert len(ad[0].APERTURE) == 1
    #assert caplog.records[3].message == 'Found sources at rows: 260.8'
    np.testing.assert_allclose(ad[0].APERTURE['c0'], 260.8, atol=0.25)

    ad = p.extract1DSpectra()[0]
    assert ad[0].shape == (3869, )