示例#1
0
    def run_jump_step(self, infile, threshold, run_steps):
        '''Function to run the jump detection step.'''

        # output file name
        out = infile[:-5] + "_jump_CRthresh" + str(threshold) + ".fits"

        # if run_steps, run all steps prior to jump
        if run_steps:

            m = DQInitStep.call(infile)
            m = SaturationStep.call(m)
            m = SuperBiasStep.call(m)
            m_ref = RefPixStep.call(m, config_file='refpix.cfg')
            m_lin = LinearityStep.call(m)
            m_dark = DarkCurrentStep.call(m)

            # if threshold is given, use that rejection threshold
            if threshold is not None:
                m = JumpStep.call(m,
                                  output_file=out,
                                  rejection_threshold=threshold)
            else:
                m = JumpStep.call(m, output_file=out)

        # else, run only jump_step
        else:
            if threshold is not None:
                m = JumpStep.call(infile,
                                  output_file=out,
                                  rejection_threshold=threshold)
            else:
                m = JumpStep.call(infile, output_file=out)

        return m
示例#2
0
def test_jump_niriss(_bigdata):
    """

    Regression test of jump step performed on NIRISS data.

    """
    suffix = 'jump'
    output_file_base, output_file = add_suffix('jump1_output.fits', suffix)

    JumpStep.call(
        _bigdata +
        '/niriss/test_jump/jw00034001001_01101_00001_NIRISS_linearity.fits',
        rejection_threshold=20.0,
        output_file=output_file_base,
        suffix=suffix)
    h = fits.open(output_file)
    href = fits.open(
        _bigdata +
        '/niriss/test_jump/jw00034001001_01101_00001_NIRISS_jump.fits')
    newh = fits.HDUList(
        [h['primary'], h['sci'], h['err'], h['pixeldq'], h['groupdq']])
    newhref = fits.HDUList([
        href['primary'], href['sci'], href['err'], href['pixeldq'],
        href['groupdq']
    ])
    result = fits.diff.FITSDiff(
        newh,
        newhref,
        ignore_keywords=['DATE', 'CAL_VER', 'CAL_VCS', 'CRDS_VER', 'CRDS_CTX'],
        rtol=0.00001)
    assert result.identical, result.report()
示例#3
0
def test_two_CRs(generate_miri_reffiles, max_cores, setup_inputs):
    override_gain, override_readnoise = generate_miri_reffiles
    grouptime = 3.0
    deltaDN = 5
    ingain = 6
    inreadnoise = np.float64(7)
    ngroups = 100
    CR_fraction = 5
    xsize = 103
    ysize = 102
    model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups,
        nrows=ysize, ncols=xsize,
        gain=ingain, readnoise=inreadnoise, deltatime=grouptime)
    for i in range(ngroups):
        model1.data[0, i, :, :] = deltaDN * i
    first_CR_group_locs = [x for x in range(1,89) if x % 5 == 0]
    CR_locs = [x for x in range(xsize*ysize) if x % CR_fraction == 0]
    CR_x_locs = [x % ysize for x in CR_locs]
    CR_y_locs = [np.int(x / xsize) for x in CR_locs]
    CR_pool = cycle(first_CR_group_locs)
    for i in range(len(CR_x_locs)):
        CR_group = next(CR_pool)
        model1.data[0,CR_group:,CR_y_locs[i], CR_x_locs[i]] = \
            model1.data[0,CR_group:, CR_y_locs[i], CR_x_locs[i]] + 500
        model1.data[0, CR_group+8:, CR_y_locs[i], CR_x_locs[i]] = \
            model1.data[0, CR_group+8:, CR_y_locs[i], CR_x_locs[i]] + 700
    out_model = JumpStep.call(model1, override_gain=override_gain,
        override_readnoise=override_readnoise, maximum_cores=max_cores)
    CR_pool = cycle(first_CR_group_locs)
    for i in range(len(CR_x_locs)):
        CR_group = next(CR_pool)
        assert (4 == np.max(out_model.groupdq[0, CR_group, CR_y_locs[i], CR_x_locs[i]]))
        assert (4 == np.max(out_model.groupdq[0, CR_group+8, CR_y_locs[i], CR_x_locs[i]]))
示例#4
0
def test_nircam(generate_nircam_reffiles, setup_inputs, max_cores):
    override_gain, override_readnoise = generate_nircam_reffiles

    grouptime = 3.0
    deltaDN = 5
    ingain = 6
    inreadnoise = np.float64(7)
    ngroups = 100
    CR_fraction = 5
    nrows = 20
    ncols = 20
    model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups,
        nrows=nrows, ncols=ncols, gain=ingain, readnoise=inreadnoise, deltatime=grouptime)
    for i in range(ngroups):
        model1.data[0, i, :, :] = deltaDN * i
    first_CR_group_locs = [x for x in range(1,89) if x % 5 == 0]
    CR_locs = [x for x in range(nrows*ncols) if x % CR_fraction == 0]
    CR_x_locs = [x % ncols for x in CR_locs]
    CR_y_locs = [np.int(x / nrows) for x in CR_locs]
    CR_pool = cycle(first_CR_group_locs)
    for i in range(len(CR_x_locs)):
        CR_group = next(CR_pool)
        model1.data[0,CR_group:,CR_y_locs[i], CR_x_locs[i]] = \
            model1.data[0,CR_group:, CR_y_locs[i], CR_x_locs[i]] + 500

    print("number of CRs {}".format(len(CR_x_locs)))

    out_model = JumpStep.call(model1, override_gain=override_gain,
        override_readnoise=override_readnoise, maximum_cores=max_cores)
    CR_pool = cycle(first_CR_group_locs)
    for i in range(len(CR_x_locs)):
        CR_group = next(CR_pool)
        assert (4 == np.max(out_model.groupdq[0, CR_group, CR_y_locs[i], CR_x_locs[i]]))
示例#5
0
def test_two_group_integration(generate_miri_reffiles, max_cores, setup_inputs):
    override_gain, override_readnoise = generate_miri_reffiles
    grouptime = 3.0
    ingain = 6
    inreadnoise = np.float64(7)
    ngroups = 2
    xsize = 103
    ysize = 102
    model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups,
        nrows=ysize, ncols=xsize,
        gain=ingain, readnoise=inreadnoise, deltatime=grouptime)
    out_model = JumpStep.call(model1, override_gain=override_gain,
                              override_readnoise=override_readnoise, maximum_cores=max_cores)
    assert(out_model.meta.cal_step.jump == 'SKIPPED')
示例#6
0
def test_five_group_integration(generate_miri_reffiles, setup_inputs):
    override_gain, override_readnoise = generate_miri_reffiles
    grouptime = 3.0
    ingain = 6
    inreadnoise = 7
    ngroups = 5
    xsize = 103
    ysize = 102
    model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups,
                                                          nrows=ysize, ncols=xsize,
                                                          gain=ingain, readnoise=inreadnoise,
                                                          deltatime=grouptime)
    out_model = JumpStep.call(model1, override_gain=override_gain,
                              override_readnoise=override_readnoise, maximum_cores='none')
    assert (out_model.meta.cal_step.jump == 'COMPLETE')
示例#7
0
        if len(line) > 3:
            files.append(line.strip())

#assume they've been run thru bpm and saturation
#so now do superbias subtraction, refpix corr,
#linearity corr, jump step

#hardwire for A1 at the moment:
reffile_dir = '/ifs/jwst/wit/witserv/data7/nrc/reference_files/SSB/CV3/cv3_reffile_conversion/'
sbfile = '/ifs/jwst/wit/witserv/data4/nrc/hilbert/superbias/cv3/A1/A1_superbias_from_list_of_biasfiles.list.fits'
linfile = reffile_dir + 'linearity/NRCA1_17004_LinearityCoeff_ADU0_2016-05-14_ssblinearity_DMSorient.fits'
gainfile = reffile_dir + 'gain/NRCA1_17004_Gain_ISIMCV3_2016-01-23_ssbgain_DMSorient.fits'
ronfile = '/grp/jwst/wit/nircam/reference_files/SSB/CV2/delivery_Dec_2015/Read_Noise/NRCA1_16989_CDSNoise_2014-10-24_ssbreadnoise_DMSorient.fits'

for file in files:
    sbout = file[0:-5] + '_superbias.fits'
    data = SuperBiasStep.call(file,
                              override_superbias=sbfile,
                              output_file=sbout)
    refout = sbout[0:-5] + '_refpix.fits'
    data = RefPixStep.call(data, output_file=refout)
    linout = refout[0:-5] + '_linearity.fits'
    data = LinearityStep.call(data,
                              override_linearity=linfile,
                              output_file=linout)
    jumpout = linout[0:-5] + '_jump.fits'
    data = JumpStep.call(data,
                         override_gain=gainfile,
                         override_readnoise=ronfile,
                         output_file=jumpout)
def test_jump_step(fits_input):
    """Make sure the JumpStep runs without error."""
    fname = fits_input[0].header['filename'].replace('.fits', '_jumpstep.fits')
    JumpStep.call(datamodels.open(fits_input),
                  output_file=fname,
                  save_results=True)
def test_jump_step(fits_input):
    """Make sure the JumpStep runs without error."""

    JumpStep.call(datamodels.open(fits_input), save_results=True)