Esempio n. 1
0
def test_ami_analyze_cube_fail():
    """Make sure ami_analyze fails if input is CubeModel (_calints)"""
    model = datamodels.ImageModel((25, 19, 19))
    model.meta.instrument.name = "NIRISS"
    model.meta.instrument.filter = "F277W"
    model.meta.observation.date = "2019-01-01"
    model.meta.observation.time = "00:00:00"
    with pytest.raises(RuntimeError):
        AmiAnalyzeStep.call(model)
Esempio n. 2
0
def test_ami_analyze_calints_fail(tmpdir):
    """Make sure ami_analyze fails if input is CubeModel (_calints)"""
    input_file = str(tmpdir.join("ami_analyze_input.fits"))
    model = datamodels.CubeModel((25, 19, 19))
    model.meta.instrument.name = "NIRISS"
    model.meta.instrument.filter = "F277W"
    model.meta.observation.date = "2019-01-01"
    model.meta.observation.time = "00:00:00"
    model.save(input_file)
    with pytest.raises(RuntimeError):
        AmiAnalyzeStep.call(input_file)
Esempio n. 3
0
def test_ami_analyze_with_nans(rtdata, fitsdiff_default_kwargs):
    """Test the AmiAnalyzeStep using an input image with NaNs"""
    data = rtdata.get_data(
        'niriss/ami/jw00042004001_01101_00005_nis_withNAN_cal.fits')

    AmiAnalyzeStep.call(data, save_results=True)
    rtdata.output = 'jw00042004001_01101_00005_nis_withNAN_amianalyzestep.fits'

    rtdata.get_truth(
        'truth/test_niriss_ami3/jw00042004001_01101_00005_nis_withNAN_amianalyzestep.fits'
    )
    diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
    assert diff.identical, diff.report()
Esempio n. 4
0
def test_ami_analyze_no_reffile_fail(monkeypatch):
    """Make sure that ami_analyze fails if no throughput reffile is available"""
    model = datamodels.ImageModel((19, 19))
    model.meta.instrument.name = "NIRISS"
    model.meta.instrument.filter = "F277W"
    model.meta.observation.date = "2019-01-01"
    model.meta.observation.time = "00:00:00"

    def mockreturn(input_model, reftype):
        return("N/A")
    monkeypatch.setattr(jwst.stpipe.crds_client, 'get_reference_file', mockreturn)

    with pytest.raises(RuntimeError):
        AmiAnalyzeStep.call(model)
def test_ami_analyze(_bigdata):
    """

    Regression test of ami_analyze step performed on NIRISS AMI data.

    """
    suffix = 'ami_analyze'
    output_file_base, output_file = add_suffix('ami_analyze_output_16.fits',
                                               suffix)

    AmiAnalyzeStep.call(_bigdata +
                        '/niriss/test_ami_analyze/ami_analyze_input_16.fits',
                        oversample=3,
                        rotation=1.49,
                        output_file=output_file_base,
                        suffix=suffix)

    h = fits.open(output_file)
    href = fits.open(_bigdata +
                     '/niriss/test_ami_analyze/ami_analyze_ref_output_16.fits')
    newh = fits.HDUList([
        h['primary'], h['fit'], h['resid'], h['closure_amp'], h['closure_pha'],
        h['fringe_amp'], h['fringe_pha'], h['pupil_pha'], h['solns']
    ])
    newhref = fits.HDUList([
        href['primary'], href['fit'], href['resid'], href['closure_amp'],
        href['closure_pha'], href['fringe_amp'], href['fringe_pha'],
        href['pupil_pha'], href['solns']
    ])

    result = fits.diff.FITSDiff(
        newh,
        newhref,
        ignore_keywords=['DATE', 'CAL_VER', 'CAL_VCS', 'CRDS_VER', 'CRDS_CTX'],
        rtol=0.001)
    assert result.identical, result.report()