コード例 #1
0
ファイル: test_refpix.py プロジェクト: STScI-JWST/jwst
def test_do_top_bottom_correction(setup_cube):
    '''Test top/bottom correction for NIRCam data.'''

    ngroups = 5
    nrows = 2048
    ncols = 2048

    odd_even_columns = True
    use_side_ref_pixels = True
    side_smoothing_length = 11
    side_gain = 1.0

    input_model = setup_cube('NIRCAM','NRCALONG', ngroups, nrows, ncols)
    input_model.meta.subarray.name = 'FULL'
    init_dataset = NIRDataset(input_model,
                              odd_even_columns,
                              use_side_ref_pixels,
                              side_smoothing_length,
                              side_gain)

    abounds = [0, 512, 1024, 1536, 2048]
    top_even_amps = [12, 13, 14, 15]
    top_odd_amps = [16, 17, 18, 19]
    bottom_even_amps = [20, 21, 22, 23]
    bottom_odd_amps = [24, 25, 26, 27]
    dataval = [50, 51, 52, 53]

    for i in np.arange(0, len(abounds)-1):

        # bottom, odd
        input_model.data[0, 0, :4, abounds[i]:abounds[i+1]:2] = bottom_even_amps[i]

        # bottom, even
        input_model.data[0, 0, :4, abounds[i]+1:abounds[i+1]-1:2] = bottom_odd_amps[i]

        # top, odd
        input_model.data[0, 0, -4:, abounds[i]:abounds[i+1]:2] = top_even_amps[i]

        # top, even
        input_model.data[0, 0, -4:, abounds[i]+1:abounds[i+1]-1:2] = top_odd_amps[i]

        # data
        input_model.data[0, 0, 4:-4, abounds[i]:abounds[i+1]] = dataval[i]

    refpix = init_dataset.get_refvalues(input_model.data[0, 0, :, :])
    init_dataset.do_top_bottom_correction(input_model.data[0, 0, :, :], refpix)

    for i in np.arange(0, len(abounds)-1):
        even_rmean = np.mean([bottom_even_amps[i], top_even_amps[i]])
        odd_rmean = np.mean([bottom_odd_amps[i], top_odd_amps[i]])
        rmean = np.mean([even_rmean, odd_rmean])
        np.testing.assert_almost_equal(np.mean(input_model.data[0, 0, :4, abounds[i]:abounds[i+1]:2]), bottom_even_amps[i] - even_rmean, decimal=1)
        np.testing.assert_almost_equal(np.mean(input_model.data[0, 0, :4, abounds[i]+1:abounds[i+1]:2]), bottom_odd_amps[i] - odd_rmean, decimal=1)
        np.testing.assert_almost_equal(np.mean(input_model.data[0, 0, -4:, abounds[i]:abounds[i+1]:2]), top_even_amps[i] - even_rmean, decimal=1)
        np.testing.assert_almost_equal(np.mean(input_model.data[0, 0, -4:, abounds[i]+1:abounds[i+1]:2]), top_odd_amps[i] - odd_rmean, decimal=1)
        np.testing.assert_almost_equal(np.mean(input_model.data[0, 0, 4:-4, abounds[i]:abounds[i+1]]), dataval[i] - rmean, decimal=1)
コード例 #2
0
def test_do_top_bottom_correction_no_even_odd(setup_cube):
    '''Test top/bottom correction with no even/odd.'''

    ngroups = 3
    nrows = 2048
    ncols = 2048

    odd_even_columns = False
    use_side_ref_pixels = True
    side_smoothing_length = 11
    side_gain = 1.0

    input_model = setup_cube('NIRCAM', 'NRCALONG', ngroups, nrows, ncols)
    input_model.meta.subarray.name = 'FULL'
    init_dataset = NIRDataset(input_model, odd_even_columns,
                              use_side_ref_pixels, side_smoothing_length,
                              side_gain)

    abounds = [0, 512, 1024, 1536, 2048]
    top_amps = [12, 13, 14, 15]
    bottom_amps = [16, 17, 18, 19]
    dataval = [50, 51, 52, 53]

    for i in np.arange(0, len(abounds) - 1):

        # bottom
        input_model.data[0, 0, :4, abounds[i]:abounds[i + 1]] = bottom_amps[i]

        # top
        input_model.data[0, 0, -4:, abounds[i]:abounds[i + 1]] = top_amps[i]

        # data
        input_model.data[0, 0, 4:-4, abounds[i]:abounds[i + 1]] = dataval[i]

    refpix = init_dataset.get_refvalues(input_model.data[0, 0, :, :])
    init_dataset.do_top_bottom_correction(input_model.data[0, 0, :, :], refpix)

    for i in np.arange(0, len(abounds) - 1):
        rmean = np.mean([top_amps[i], bottom_amps[i]])
        np.testing.assert_almost_equal(np.mean(
            input_model.data[0, 0, :4, abounds[i]:abounds[i + 1]]),
                                       bottom_amps[i] - rmean,
                                       decimal=1)
        np.testing.assert_almost_equal(np.mean(
            input_model.data[0, 0, -4:, abounds[i]:abounds[i + 1]]),
                                       top_amps[i] - rmean,
                                       decimal=1)
        np.testing.assert_almost_equal(np.mean(
            input_model.data[0, 0, 4:-4, abounds[i]:abounds[i + 1]]),
                                       dataval[i] - rmean,
                                       decimal=1)
コード例 #3
0
ファイル: test_refpix.py プロジェクト: STScI-JWST/jwst
def test_do_top_bottom_correction_no_evenOdd(setup_cube):
    '''Test top/bottom correction with no even/odd.'''

    ngroups = 5
    nrows = 2048
    ncols = 2048

    odd_even_columns = False
    use_side_ref_pixels = True
    side_smoothing_length = 11
    side_gain = 1.0

    input_model = setup_cube('NIRCAM','NRCALONG', ngroups, nrows, ncols)
    input_model.meta.subarray.name = 'FULL'
    init_dataset = NIRDataset(input_model,
                              odd_even_columns,
                              use_side_ref_pixels,
                              side_smoothing_length,
                              side_gain)

    abounds = [0, 512, 1024, 1536, 2048]
    top_amps = [12, 13, 14, 15]
    bottom_amps = [16, 17, 18, 19]
    dataval = [50, 51, 52, 53]

    for i in np.arange(0, len(abounds)-1):

        # bottom
        input_model.data[0, 0, :4, abounds[i]:abounds[i+1]] = bottom_amps[i]

        # top
        input_model.data[0, 0, -4:, abounds[i]:abounds[i+1]] = top_amps[i]

        # data
        input_model.data[0, 0, 4:-4, abounds[i]:abounds[i+1]] = dataval[i]

    refpix = init_dataset.get_refvalues(input_model.data[0, 0, :, :])
    init_dataset.do_top_bottom_correction(input_model.data[0, 0, :, :], refpix)

    for i in np.arange(0, len(abounds)-1):
        rmean = np.mean([top_amps[i], bottom_amps[i]])
        np.testing.assert_almost_equal(np.mean(input_model.data[0, 0, :4, abounds[i]:abounds[i+1]]), bottom_amps[i] - rmean, decimal=1)
        np.testing.assert_almost_equal(np.mean(input_model.data[0, 0, -4:, abounds[i]:abounds[i+1]]), top_amps[i] - rmean, decimal=1)
        np.testing.assert_almost_equal(np.mean(input_model.data[0, 0, 4:-4, abounds[i]:abounds[i+1]]), dataval[i] - rmean, decimal=1)
コード例 #4
0
def test_do_top_bottom_correction(setup_cube):
    '''Test top/bottom correction for NIRCam data.'''

    ngroups = 3
    nrows = 2048
    ncols = 2048

    odd_even_columns = True
    use_side_ref_pixels = True
    side_smoothing_length = 11
    side_gain = 1.0

    input_model = setup_cube('NIRCAM', 'NRCALONG', ngroups, nrows, ncols)
    input_model.meta.subarray.name = 'FULL'
    init_dataset = NIRDataset(input_model, odd_even_columns,
                              use_side_ref_pixels, side_smoothing_length,
                              side_gain)

    abounds = [0, 512, 1024, 1536, 2048]
    top_even_amps = [12, 13, 14, 15]
    top_odd_amps = [16, 17, 18, 19]
    bottom_even_amps = [20, 21, 22, 23]
    bottom_odd_amps = [24, 25, 26, 27]
    dataval = [50, 51, 52, 53]

    for i in np.arange(0, len(abounds) - 1):

        # bottom, odd
        input_model.data[0, 0, :4,
                         abounds[i]:abounds[i + 1]:2] = bottom_even_amps[i]

        # bottom, even
        input_model.data[0, 0, :4, abounds[i] + 1:abounds[i + 1] -
                         1:2] = bottom_odd_amps[i]

        # top, odd
        input_model.data[0, 0, -4:,
                         abounds[i]:abounds[i + 1]:2] = top_even_amps[i]

        # top, even
        input_model.data[0, 0, -4:,
                         abounds[i] + 1:abounds[i + 1] - 1:2] = top_odd_amps[i]

        # data
        input_model.data[0, 0, 4:-4, abounds[i]:abounds[i + 1]] = dataval[i]

    refpix = init_dataset.get_refvalues(input_model.data[0, 0, :, :])
    init_dataset.do_top_bottom_correction(input_model.data[0, 0, :, :], refpix)

    for i in np.arange(0, len(abounds) - 1):
        even_rmean = np.mean([bottom_even_amps[i], top_even_amps[i]])
        odd_rmean = np.mean([bottom_odd_amps[i], top_odd_amps[i]])
        rmean = np.mean([even_rmean, odd_rmean])
        np.testing.assert_almost_equal(np.mean(
            input_model.data[0, 0, :4, abounds[i]:abounds[i + 1]:2]),
                                       bottom_even_amps[i] - even_rmean,
                                       decimal=1)
        np.testing.assert_almost_equal(np.mean(
            input_model.data[0, 0, :4, abounds[i] + 1:abounds[i + 1]:2]),
                                       bottom_odd_amps[i] - odd_rmean,
                                       decimal=1)
        np.testing.assert_almost_equal(np.mean(
            input_model.data[0, 0, -4:, abounds[i]:abounds[i + 1]:2]),
                                       top_even_amps[i] - even_rmean,
                                       decimal=1)
        np.testing.assert_almost_equal(np.mean(
            input_model.data[0, 0, -4:, abounds[i] + 1:abounds[i + 1]:2]),
                                       top_odd_amps[i] - odd_rmean,
                                       decimal=1)
        np.testing.assert_almost_equal(np.mean(
            input_model.data[0, 0, 4:-4, abounds[i]:abounds[i + 1]]),
                                       dataval[i] - rmean,
                                       decimal=1)