def test_add_oiwfs_warns_when_wfs_if_not_in_field(caplog, filename):
    """
    Test that the primitive does not run if the input file does not have a DQ
    plan.

    Parameters
    ----------
    caplog : fixture
    filename : str
    """
    caplog.set_level(logging.DEBUG)
    file_path = download_from_archive(filename)
    ad = astrodata.open(file_path)

    p = GMOSImage([ad])
    p.addDQ()
    p.addVAR(read_noise=True)
    p.addOIWFSToDQ()

    # plot(p.streams['main'][0])
    print(caplog.records)
    assert any("No good rows in" in r.message for r in caplog.records)

    assert any("Cannot distinguish probe region from sky for"
               in r.message for r in caplog.records)
def test_add_oiwfs_runs_normally(caplog, ext_num, filename, x0, y0):
    """
    Test that the primitive does not run if the input file does not have a DQ
    plan.

    Parameters
    ----------
    caplog : fixture
    filename : str
    """
    caplog.set_level(logging.DEBUG)
    file_path = download_from_archive(filename)
    ad = astrodata.open(file_path)

    p = GMOSImage([ad])
    p.addDQ()
    p.addVAR(read_noise=True)
    p.addOIWFSToDQ()

    # plot(p.streams['main'][0])
    assert len(caplog.records) > 0
    assert any("Guide star location found at" in r.message for r in caplog.records)

    # Some kind of regression test
    for r in caplog.records:
        if r.message.startswith("Guide star location found at"):
            coords = re.findall(r"\((.*?)\)", r.message).pop().split(',')

            x = float(coords[0])
            y = float(coords[1])
            n = int(r.message.split(' ')[-1])

            assert abs(x - x0) < 1
            assert abs(y - y0) < 1
            assert n == ext_num
def test_fit_continuum_slit_image(path_to_inputs):
    results = {'N20180118S0344': 1.32}
    for fname, fwhm in results.items():
        ad = astrodata.open(
            os.path.join(path_to_inputs, 'gt/slit_images',
                         '{}.fits'.format(fname)))
        p = GMOSImage([ad])
        p.prepare(attach_mdf=True)
        p.addDQ()
        p.trimOverscan()
        p.ADUToElectrons()
        p.mosaicDetectors()
        tbl = gt.fit_continuum(p.streams['main'][0])[0]

        assert isinstance(tbl, Table)
        assert len(tbl) == 1
        assert abs(tbl['fwhm_arcsec'].data[0] - fwhm) < 0.05
Exemple #4
0
def test_fit_continuum_slit_image(fname, fwhm, change_working_dir):

    with change_working_dir():

        log_file = 'log_{}.log'.format(fname.replace('.fits', ''))
        logutils.config(file_name=log_file)

        ad = astrodata.open(astrodata.testing.download_from_archive(fname))
        p = GMOSImage([ad])
        p.prepare(attach_mdf=True)
        p.addDQ()
        p.trimOverscan()
        p.ADUToElectrons()
        p.mosaicDetectors()
        tbl = gt.fit_continuum(p.streams['main'][0])[0]

        assert isinstance(tbl, Table)
        assert len(tbl) == 1
        assert abs(tbl['fwhm_arcsec'].data[0] - fwhm) < 0.05