Пример #1
0
def test_nframes_is_none(make_rampmodel):
    """Make sure step is skipped if nframes is None
    """
    datmod = make_rampmodel(2, None, 4, 2048, 2048)
    output = GroupScaleStep.call(datmod)

    assert (output.meta.cal_step.group_scale == 'SKIPPED')
Пример #2
0
def test_nframes_equal_frame_divisor(make_rampmodel):
    """If nframes and frame_divisor are equal, skip correction
    """
    datmod = make_rampmodel(2, 4, 4, 2048, 2048)
    output = GroupScaleStep.call(datmod)
    print(output.meta.exposure.frame_divisor, output.meta.exposure.nframes)
    assert (output.meta.cal_step.group_scale == 'SKIPPED')
Пример #3
0
    def run_early_pipeline(self,
                           filename,
                           odd_even_rows=False,
                           odd_even_columns=True,
                           use_side_ref_pixels=True,
                           group_scale=False):
        """Runs the early steps of the jwst pipeline (dq_init, saturation,
        superbias, refpix) on uncalibrated files and outputs the result.

        Parameters
        ----------
        filename : str
            File on which to run the pipeline steps

        odd_even_rows : bool
            Option to treat odd and even rows separately during refpix step

        odd_even_columns : bools
            Option to treat odd and even columns separately during refpix step

        use_side_ref_pixels : bool
            Option to perform the side refpix correction during refpix step

        group_scale : bool
            Option to rescale pixel values to correct for instances where
            on-board frame averaging did not result in the proper values

        Returns
        -------
        output_filename : str
            The full path to the calibrated file
        """

        output_filename = filename.replace('_uncal', '').replace(
            '.fits', '_superbias_refpix.fits')

        if not os.path.isfile(output_filename):
            # Run the group_scale and dq_init steps on the input file
            if group_scale:
                model = GroupScaleStep.call(filename)
                model = DQInitStep.call(model)
            else:
                model = DQInitStep.call(filename)

            # Run the saturation and superbias steps
            model = SaturationStep.call(model)
            model = SuperBiasStep.call(model)

            # Run the refpix step and save the output
            model = RefPixStep.call(model,
                                    odd_even_rows=odd_even_rows,
                                    odd_even_columns=odd_even_columns,
                                    use_side_ref_pixels=use_side_ref_pixels)
            model.save(output_filename)
            set_permissions(output_filename)
        else:
            logging.info('\t{} already exists'.format(output_filename))

        return output_filename
Пример #4
0
def test_nframes_is_power_of_two(make_rampmodel):
    """When frame_divisor is None, the correction will skip if
    nframes is a power of 2.
    """
    datmod = make_rampmodel(2, 4, None, 2048, 2048)
    output = GroupScaleStep.call(datmod)

    assert (output.meta.cal_step.group_scale == 'SKIPPED')
Пример #5
0
def test_nframes_is_not_power_of_two(make_rampmodel):
    """When frame_divisor is None, then do_correction will be applied if
    nframes is not a power of two but will be skip because if nframes or
    frame_divisor is none.
    """
    datmod = make_rampmodel(2, 3, None, 2048, 2048)
    output = GroupScaleStep.call(datmod)

    assert (output.meta.cal_step.group_scale == 'SKIPPED')
Пример #6
0
def test_nframes_not_equal_frame_divisor(make_rampmodel):
    """If nframes and frame_divisor are not equal, do correction
    """
    datmod = make_rampmodel(2, 2, 4, 2048, 2048)
    output = GroupScaleStep.call(datmod)

    # Assert that the step completed
    assert (output.meta.cal_step.group_scale == 'COMPLETE')

    # This assertion doesn't verify for correct output,
    # it just checks that the correction ran and that the data array
    # outputs are different than the inputs as requested in the document.
    assert not np.array_equal(output.data, datmod.data)
Пример #7
0
def test_scale_value(make_rampmodel):
    """Compare the ratio of the FRMDIVSR/NFRAMES from the data model input and
    compare to the output of the pipeline.
    """

    datmod = make_rampmodel(2, 2, 4, 2048, 2048)

    # Calculate the scale based off of the input.
    scale = datmod.meta.exposure.frame_divisor / datmod.meta.exposure.nframes

    output = GroupScaleStep.call(datmod)

    scale_from_data = np.unique(output.data / datmod.data)

    # Since the scale value is applied uniformly to the array, if we divide the output
    # by the input then we should get a single unique value (ie the scale) calculated
    # by the pipeline.
    assert (len(scale_from_data) == 1)

    # Make sure the scale calculated manually from the data model aboved matched what the
    # pipeline calculated.
    assert (scale == scale_from_data[0])