Пример #1
0
def test_verify_image2(run_image2, rtdata_module, fitsdiff_default_kwargs,
                       suffix):
    """Test results of the detector1 and image2 processing"""
    rtdata = rtdata_module
    rtdata.input = replace_suffix(ROOT, 'uncal') + '.fits'
    output = replace_suffix(ROOT, suffix) + '.fits'
    rtdata.output = output
    rtdata.get_truth('truth/test_nirspec_verify/' + output)

    diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
    assert diff.identical, diff.report()
Пример #2
0
def run_spec3(jail, run_spec2):
    """Run the Spec3Pipeline on the results from the Spec2Pipeline run"""
    rtdata = run_spec2

    # Create the level 3 `spec3` association from the output product
    # name of `run_spec2`
    product = run_spec2.asn['products'][0]['name']
    input_name = replace_suffix(product, 'cal') + '.fits'
    asn = asn_from_list([input_name], product_name=product)
    _, serialized = asn.dump()
    asn_name = product + '_spec3_asn.json'
    with open(asn_name, 'w') as asn_fh:
        asn_fh.write(serialized)

    # Set the input in the RegtestData instance to avoid download.
    rtdata.input = asn_name
    step_params = {
        'step': 'calwebb_spec3.cfg',
        'args': [
            '--steps.master_background.save_results=true',
            '--steps.mrs_imatch.save_results=true',
            '--steps.outlier_detection.save_results=true',
            '--steps.resample_spec.save_results=true',
            '--steps.cube_build.save_results=true',
            '--steps.extract_1d.save_results=true',
            '--steps.combine_1d.save_results=true',
        ]
    }

    rtdata = rt.run_step_from_dict(rtdata, **step_params)
    return rtdata
Пример #3
0
def run_image2(run_detector1, rtdata_module):
    """Run NRS_VERIFY through image2"""
    rtdata = rtdata_module

    # Get some predefined references due to insufficient coverage
    # from CRDS.
    refs = [
        'jwst_nirspec_fpa_0005.asdf', 'jwst_nirspec_flat_0061.fits',
        'jwst_nirspec_area_0001.fits'
    ]
    for ref in refs:
        rtdata.get_data('nirspec/imaging/' + ref)

    rtdata.input = replace_suffix(ROOT, 'rate') + '.fits'

    args = [
        'jwst.pipeline.Image2Pipeline',
        rtdata.input,
        '--steps.assign_wcs.save_results=true',
        '--steps.assign_wcs.override_fpa=jwst_nirspec_fpa_0005.asdf',
        '--steps.flat_field.save_results=true',
        '--steps.flat_field.override_flat=jwst_nirspec_flat_0061.fits',
        '--steps.flat_field.override_sflat=N/A',
        '--steps.flat_field.override_fflat=N/A',
        '--steps.flat_field.override_dflat=N/A',
        '--steps.photom.save_results=true',
        '--steps.photom.override_area=jwst_nirspec_area_0001.fits',
    ]
    Step.from_cmdline(args)
Пример #4
0
def test_suffix_replacement(suffix,
                            enable_logging,
                            base='file',
                            new='junk',
                            sep='_'):
    """Test suffix replacement"""
    full_path = base + sep + suffix
    replaced = s.replace_suffix(full_path, new)
    assert replaced == base + sep + new
Пример #5
0
def is_like_truth(rtdata,
                  fitsdiff_default_kwargs,
                  suffix,
                  truth_path='truth/fgs/test_fgs_guider'):
    """Compare step outputs with truth"""
    output = replace_suffix(
        os.path.splitext(os.path.basename(rtdata.input))[0], suffix) + '.fits'
    rtdata.output = output

    rtdata.get_truth(os.path.join(truth_path, output))

    diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
    assert diff.identical, diff.report()
Пример #6
0
def test_nirspec_brightobj_spec2(run_tso_spec2_pipeline, fitsdiff_default_kwargs, suffix):
    """
        Regression test of calwebb_spec2 pipeline performed on NIRSpec
        fixed-slit data that uses the NRS_BRIGHTOBJ mode (S1600A1 slit).
    """
    rtdata = run_tso_spec2_pipeline
    output = replace_suffix(
        os.path.splitext(os.path.basename(rtdata.input))[0], suffix) + '.fits'
    rtdata.output = output

    # Get the truth files
    rtdata.get_truth(os.path.join("truth/test_nirspec_brightobj_spec2", output))

    # Compare the results
    diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
    assert diff.identical, diff.report()
Пример #7
0
def test_nirspec_lamp_ifu_spec2(run_pipeline, fitsdiff_default_kwargs, suffix):
    """Regression test of the calwebb_spec2 pipeline on a
       NIRSpec lamp exposure in IFU mode."""

    # Run the pipeline and retrieve outputs
    rtdata = run_pipeline
    output = replace_suffix(
        os.path.splitext(os.path.basename(rtdata.input))[0], suffix) + '.fits'
    rtdata.output = output

    # Get the truth files
    rtdata.get_truth(os.path.join("truth/test_nirspec_lamp_spec2", output))

    # Compare the results
    diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
    assert diff.identical, diff.report()
Пример #8
0
def is_like_truth(rtdata,
                  fitsdiff_default_kwargs,
                  output,
                  truth_path,
                  is_suffix=True):
    """Compare step outputs with truth

    Parameters
    ----------
    rtdata: RegtestData
        The artifactory object from the step run.

    fitsdiff_default_kwargs: dict
        The `fitsdiff` keyword arguments

    output: str
        The suffix or full file name to check on.

    truth_path: str
        Location of the truth files.

    is_suffix: bool
        Interpret `output` as just a suffix on the expected output root.
        Otherwise, assume it is a full file name
    """

    # If given only a suffix, get the root to change the suffix of.
    # If the input was an association, the output should be the name of the product
    # Otherwise, output is based on input.
    if is_suffix:
        suffix = output
        if rtdata.asn:
            output = rtdata.asn['products'][0]['name']
        else:
            output = os.path.splitext(os.path.basename(rtdata.input))[0]
        output = replace_suffix(output, suffix) + '.fits'
    rtdata.output = output

    rtdata.get_truth(os.path.join(truth_path, output))

    diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
    assert diff.identical, diff.report()
Пример #9
0
def run_spec2(jail, rtdata_module):
    """Run the Spec2Pipeline on a single exposure"""
    rtdata = rtdata_module

    # Setup the inputs
    asn_name = 'ifushort_ch12_rate_asn3.json'
    rtdata.get_data(INPUT_PATH + '/' + asn_name)
    asn_path = rtdata.input
    with open(asn_path, 'r') as asn_fh:
        asn = load_asn(asn_fh)
    member_path = Path(asn['products'][0]['members'][0]['expname'])
    rate_path = member_path.stem
    rate_path = replace_suffix(rate_path, 'rate')
    rate_path = INPUT_PATH + '/' + rate_path + member_path.suffix

    # Run the pipeline
    step_params = {
        'input_path':
        rate_path,
        'step':
        'calwebb_spec2.cfg',
        'args': [
            '--steps.bkg_subtract.save_results=true',
            '--steps.assign_wcs.save_results=true',
            '--steps.imprint_subtract.save_results=true',
            '--steps.msa_flagging.save_results=true',
            '--steps.extract_2d.save_results=true',
            '--steps.flat_field.save_results=true',
            '--steps.srctype.save_results=true',
            '--steps.straylight.save_results=true',
            '--steps.fringe.save_results=true',
            '--steps.pathloss.save_results=true',
            '--steps.barshadow.save_results=true',
            '--steps.photom.save_results=true',
            '--steps.resample_spec.save_results=true',
            '--steps.cube_build.save_results=true',
            '--steps.extract_1d.save_results=true',
        ]
    }

    rtdata = rt.run_step_from_dict(rtdata, **step_params)
    return rtdata, asn_path
Пример #10
0
def run_detector1(rtdata_module):
    """Run NRS_VERIFY through detector1"""
    rtdata = rtdata_module
    rtdata.get_data('nirspec/imaging/' + replace_suffix(ROOT, 'uncal') +
                    '.fits')

    collect_pipeline_cfgs('config')

    args = [
        'config/calwebb_detector1.cfg',
        rtdata.input,
        '--steps.dq_init.save_results=True',
        '--steps.saturation.save_results=True',
        '--steps.superbias.save_results=True',
        '--steps.refpix.save_results=True',
        '--steps.linearity.save_results=True',
        '--steps.dark_current.save_results=True',
        '--steps.jump.save_results=True',
    ]
    Step.from_cmdline(args)