Ejemplo n.º 1
0
def test_6grps_satat6_crat1(setup_cube):
    ngroups = 6
    #crmag = 1000
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,
                                                               readnoise=5 *
                                                               np.sqrt(2))
    nframes = 1
    data[0, 0, 100, 100] = 10000
    data[0, 1, 100, 100] = 35000  #CR
    data[0, 2, 100, 100] = 40005
    data[0, 3, 100, 100] = 45029
    data[0, 4, 100, 100] = 50014
    data[0, 5, 100, 101] = 61000
    data[0, 0, 100, 101] = 10000
    data[0, 1, 100, 101] = 15001
    data[0, 2, 100, 101] = 20003
    data[0, 3, 100, 101] = 25006
    data[0, 4, 100, 101] = 30010
    data[0, 5, 100, 101] = 35015
    gdq[0, 5, 100, 100] = dqflags.group['SATURATED']
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    # assert(4 == np.max(gdq))  # no CR was found
    assert (np.array_equal(
        [0, dqflags.group['JUMP_DET'], 0, 0, 0, dqflags.group['SATURATED']],
        gdq[0, :, 100, 100]))
Ejemplo n.º 2
0
def test_6grps_satat6_crat1_flagadjpixels(setup_cube):
    ngroups = 6
    #crmag = 1000
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups, readnoise=5 * np.sqrt(2))
    nframes=1
    data[0, 0, 100, 100] = 10000
    data[0, 1, 100, 100] = 35000 #CR
    data[0, 2, 100, 100] = 40005
    data[0, 3, 100, 100] = 45029
    data[0, 4, 100, 100] = 50014
    data[0, 5, 100, 101] = 61000
    data[0, 0, 100, 101] = 10000
    data[0, 1, 100, 101] = 15001
    data[0, 2, 100, 101] = 20003
    data[0, 3, 100, 101] = 25006
    data[0, 4, 100, 101] = 30010
    data[0, 5, 100, 101] = 35015
    gdq[0, 5, 100, 100] = dqflags.group['SATURATED']
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
   # assert(4 == np.max(gdq))  # no CR was found
    assert (np.array_equal([0, dqflags.group['JUMP_DET'], 0,0,0, dqflags.group['SATURATED']], gdq[0, :, 100, 100]))
    assert (np.array_equal([0, dqflags.group['JUMP_DET'], 0, 0, 0, dqflags.group['SATURATED']], gdq[0, :, 99, 100]))
    assert (np.array_equal([0, dqflags.group['JUMP_DET'], 0, 0, 0, dqflags.group['SATURATED']], gdq[0, :, 101, 100]))
    assert (np.array_equal([0, dqflags.group['JUMP_DET'], 0, 0, 0, dqflags.group['SATURATED']], gdq[0, :, 100, 99]))
    assert (np.array_equal([0, dqflags.group['JUMP_DET'], 0, 0, 0, dqflags.group['SATURATED']], gdq[0, :, 100, 101]))
Ejemplo n.º 3
0
def test_4grps_cr2_noflux(setup_cube):
    ngroups = 4
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    data[0, 0, 100, 100] = 10.0
    data[0, 1:4, 100, 100] = 1000
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(4 == np.max(gdq)) #a CR was found
    assert(1 == np.argmax(gdq[0,:,100,100])) #find the CR in the expected group
Ejemplo n.º 4
0
def test_4grps_cr2_noflux(setup_cube):
    ngroups = 4
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    data[0, 0, 100, 100] = 10.0
    data[0, 1:4, 100, 100] = 1000
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert (4 == np.max(gdq))  #a CR was found
    assert (1 == np.argmax(gdq[0, :, 100,
                               100]))  #find the CR in the expected group
Ejemplo n.º 5
0
def test_10grps_cr2_3sigma_2frames_nocr(setup_cube):
    ngroups = 10
    crmag=15
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,readnoise=5*np.sqrt(2))
    nframes = 2
    data[0, 0, 100, 100] = 0
    data[0, 1:11, 100, 100] = crmag
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(0 == np.max(gdq))  # a CR was found
    assert(np.array_equal([0, 0, 0, 0, 0, 0, 0, 0, 0, 0] , gdq[0, :, 100, 100]))
Ejemplo n.º 6
0
def test_10grps_cr2_gt3sigma(setup_cube):
    ngroups = 10
    crmag=16
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,readnoise=5)
    nframes = 1
    data[0, 0, 100, 100] = 0
    data[0, 1:11, 100, 100] = crmag
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(4 == np.max(gdq))  # a CR was found
    assert(np.array_equal([0, 4, 0, 0, 0,0,0,0,0,0] , gdq[0, :, 100, 100]))
Ejemplo n.º 7
0
def test_10grps_nocr_2pixels_sigma0(setup_cube):
    ngroups = 10
    crmag = 15
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups, readnoise=5 * np.sqrt(2))
    nframes=1
    data[0, 0, 100, 100] = crmag
    data[0, 1:11, 100, 100] = crmag
    read_noise[500, 500] = 0.0
    read_noise[600, 600] = 0.0
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(0 == np.max(gdq))  # no CR was found
Ejemplo n.º 8
0
def test_10grps_cr2_3sigma_nocr(setup_cube):
    ngroups = 10
    crmag = 15
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,
                                                               readnoise=5)
    nframes = 1
    data[0, 0, 100, 100] = 0
    data[0, 1:11, 100, 100] = crmag
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert (0 == np.max(gdq))  # a CR was found
    assert (np.array_equal([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], gdq[0, :, 100,
                                                               100]))
Ejemplo n.º 9
0
def test_6grps_twocrs_2nd_5th_nframes2(setup_cube):
    ngroups = 6
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,readnoise=10*np.sqrt(2))
    nframes=2
    data[0, 0, 100, 100] = 10.0
    data[0, 1, 100, 100] = 60
    data[0, 2, 100, 100] = 60
    data[0, 3, 100, 100] = 60
    data[0, 4, 100, 100] = 115
    data[0, 5, 100, 100] = 115
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(4 == np.max(gdq)) #a CR was found
    assert(np.array_equal([0,4,0,0,4,0] , gdq[0, :, 100, 100]) )
Ejemplo n.º 10
0
def test_10grps_cr2_gt3sigma_2frames(setup_cube):
    ngroups = 10
    crmag = 16
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,
                                                               readnoise=5 *
                                                               np.sqrt(2))
    nframes = 2
    data[0, 0, 100, 100] = 0
    data[0, 1:11, 100, 100] = crmag
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert (4 == np.max(gdq))  # a CR was found
    assert (np.array_equal([0, 4, 0, 0, 0, 0, 0, 0, 0, 0], gdq[0, :, 100,
                                                               100]))
Ejemplo n.º 11
0
def test_10grps_nocr_2pixels_sigma0(setup_cube):
    ngroups = 10
    crmag = 15
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,
                                                               readnoise=5 *
                                                               np.sqrt(2))
    nframes = 1
    data[0, 0, 100, 100] = crmag
    data[0, 1:11, 100, 100] = crmag
    read_noise[500, 500] = 0.0
    read_noise[600, 600] = 0.0
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert (0 == np.max(gdq))  # no CR was found
Ejemplo n.º 12
0
def test_6grps_twocrs_2nd_5th_nframes2(setup_cube):
    ngroups = 6
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,
                                                               readnoise=10 *
                                                               np.sqrt(2))
    nframes = 2
    data[0, 0, 100, 100] = 10.0
    data[0, 1, 100, 100] = 60
    data[0, 2, 100, 100] = 60
    data[0, 3, 100, 100] = 60
    data[0, 4, 100, 100] = 115
    data[0, 5, 100, 100] = 115
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert (4 == np.max(gdq))  #a CR was found
    assert (np.array_equal([0, 4, 0, 0, 4, 0], gdq[0, :, 100, 100]))
Ejemplo n.º 13
0
def test_5grps_satat4_crat3(setup_cube):
    ngroups = 5
    #crmag = 1000
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups, readnoise=5 * np.sqrt(2))
    nframes=1
    data[0, 0, 100, 100] = 10000
    data[0, 1, 100, 100] = 30000
    data[0, 2, 100, 100] = 60000
    data[0, 3, 100, 100] = 61000
    data[0, 4, 100, 100] = 61000
    gdq[0, 3, 100, 100] = dqflags.group['SATURATED']
    gdq[0, 4, 100, 100] = dqflags.group['SATURATED']
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    # assert(4 == np.max(gdq))  # no CR was found
    assert (np.array_equal([0, 0, dqflags.group['JUMP_DET'],dqflags.group['SATURATED'], dqflags.group['SATURATED']], gdq[0, :, 100, 100]))
Ejemplo n.º 14
0
def test_nocrs_noflux(setup_cube):
    ngroups = 5
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise,
                                                     rej_threshold, nframes,
                                                     False, 200, 10)
    assert 0 == np.max(out_gdq)  # no CR found
Ejemplo n.º 15
0
def test_10grps_satat8_crsat3and6(setup_cube):
    ngroups = 10
    # crmag = 1000
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,
                                                               readnoise=5 *
                                                               np.sqrt(2))
    nframes = 1
    data[0, 0, 100, 100] = 0
    data[0, 1, 100, 100] = 5000
    data[0, 2, 100, 100] = 15000  # CR
    data[0, 3, 100, 100] = 20000
    data[0, 4, 100, 100] = 25000
    data[0, 5, 100, 100] = 40000  # CR
    data[0, 6, 100, 100] = 45000
    data[0, 7:11, 100, 100] = 61000
    gdq[0, 7:11, 100, 100] = dqflags.group['SATURATED']
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise,
                                                     rej_threshold, nframes,
                                                     False, 200, 10)
    # assert(4 == np.max(out_gdq))  # no CR was found
    assert np.array_equal([
        0, 0, dqflags.group['JUMP_DET'], 0, 0, dqflags.group['JUMP_DET'], 0,
        dqflags.group['SATURATED'], dqflags.group['SATURATED'],
        dqflags.group['SATURATED']
    ], out_gdq[0, :, 100, 100])
Ejemplo n.º 16
0
def test_first_last_group(setup_cube):
    ngroups = 7
    nframes = 1
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups, readnoise=25.0)

    #  set up the data so that if the first and last group are used in jump
    #  detection it would cause a jump to be detected between group 1-2
    #  and group 6-7. Add a jump between 3 and 4 just to make sure jump detection is working
    #  set group 1 to be 10,000
    data[0, 0, 100, 100] = 10000.0
    #  set groups 1, 2 - to be around 30,000
    data[0, 1, 100, 100] = 30000.0
    data[0, 2, 100, 100] = 30020.0
    #  set up a jump to make sure it is detected
    data[0, 3, 100, 100] = 40000.0
    data[0, 4, 100, 100] = 40020.0
    data[0, 5, 100, 100] = 40040.0
    #  set group 6 to be 50,000
    data[0, 6, 100, 100] = 50000.0

    gdq[0, 0, 100, 100] = dqflags.group['DO_NOT_USE']
    gdq[0, 6, 100, 100] = dqflags.group['DO_NOT_USE']
    outgdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold, rej_threshold, rej_threshold,
                                                    nframes, False, 200, 10)

    assert outgdq[0, 0, 100, 100] == dqflags.group['DO_NOT_USE']
    assert outgdq[0, 6, 100, 100] == dqflags.group['DO_NOT_USE']
    assert outgdq[0, 3, 100, 100] == dqflags.group['JUMP_DET']
Ejemplo n.º 17
0
def test_6grps_different_valid_grps_each_pixel(setup_cube):
    ngroups = 6
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups, readnoise=5 * np.sqrt(2), nrows=3, ncols=2)
    nframes = 1
    # pixel 0, 0 no crs
    data[0, 0, 0, 0] = 0
    data[0, 1, 0, 0] = 10
    data[0, 2, 0, 0] = 20
    data[0, 3, 0, 0] = 25
    data[0, 4, 0, 0] = 35
    data[0, 5, 0, 0] = 42
    # pixel 0, 1 one crs grp 3
    data[0, 0, 0, 1] = 0
    data[0, 1, 0, 1] = 10
    data[0, 2, 0, 1] = 20
    data[0, 3, 0, 1] = 2500
    data[0, 4, 0, 1] = 2510
    data[0, 5, 0, 1] = 2522
    # pixel 1, 0 one cr, two last grps saturated
    data[0, 0, 1, 0] = 0
    data[0, 1, 1, 0] = 10
    data[0, 2, 1, 0] = 20
    data[0, 3, 1, 0] = 2500
    data[0, 4, 1, 0] = 2510
    data[0, 5, 1, 0] = 1522
    gdq[0, 4, 1, 0] = dqflags.group['SATURATED']
    gdq[0, 5, 1, 0] = dqflags.group['SATURATED']
    # pixel 1, 1 two crs
    data[0, 0, 1, 1] = 0
    data[0, 1, 1, 1] = 1000
    data[0, 2, 1, 1] = 1100
    data[0, 3, 1, 1] = 10000
    data[0, 4, 1, 1] = 10102
    data[0, 5, 1, 1] = 10208
    # pixel 2, 0 one cr, three last groups saturated
    data[0, 0, 2, 0] = 0
    data[0, 1, 2, 0] = 1000
    data[0, 2, 2, 0] = 10100
    data[0, 3, 2, 0] = 10000
    data[0, 4, 2, 0] = 10102
    data[0, 5, 2, 0] = 10208
    gdq[0, 3, 2, 0] = dqflags.group['SATURATED']
    gdq[0, 4, 2, 0] = dqflags.group['SATURATED']
    gdq[0, 5, 2, 0] = dqflags.group['SATURATED']
    # pixel 2, 1 two crs, last group saturated
    data[0, 0, 2, 1] = 0
    data[0, 1, 2, 1] = 10000
    data[0, 2, 2, 1] = 20100
    data[0, 3, 2, 1] = 20200
    data[0, 4, 2, 1] = 20302
    data[0, 5, 2, 1] = 10208
    gdq[0, 5, 2, 1] = dqflags.group['SATURATED']
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold,
                                                     rej_threshold, rej_threshold, nframes, False, 200, 10)
    assert np.array_equal([0, 0, 0, 0, 0, 0], out_gdq[0, :, 0, 0])
    assert np.array_equal([0, 0, 0, 4, 0, 0], out_gdq[0, :, 0, 1])
    assert np.array_equal([0, 0, 0, 4, 2, 2], out_gdq[0, :, 1, 0])
    assert np.array_equal([0, 4, 0, 4, 0, 0], out_gdq[0, :, 1, 1])
    assert np.array_equal([0, 0, 4, 2, 2, 2], out_gdq[0, :, 2, 0])
    assert np.array_equal([0, 4, 4, 0, 0, 2], out_gdq[0, :, 2, 1])
Ejemplo n.º 18
0
def test_10grps_satat8_crsat3and6(setup_cube):
    ngroups = 10
    #crmag = 1000
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups, readnoise=5 * np.sqrt(2))
    nframes=1
    data[0, 0, 100, 100] = 0
    data[0, 1, 100, 100] = 5000
    data[0, 2, 100, 100] = 15000 #CR
    data[0, 3, 100, 100] = 20000
    data[0, 4, 100, 100] = 25000
    data[0, 5, 100, 100] = 40000 #CR
    data[0, 6, 100, 100] = 45000
    data[0, 7:11, 100, 100] = 61000
    gdq[0, 7:11, 100, 100] = dqflags.group['SATURATED']
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
   # assert(4 == np.max(gdq))  # no CR was found
    assert (np.array_equal([0, 0, dqflags.group['JUMP_DET'], 0, 0, dqflags.group['JUMP_DET'],
                            0,dqflags.group['SATURATED'],dqflags.group['SATURATED'],dqflags.group['SATURATED']], gdq[0, :, 100, 100]))
Ejemplo n.º 19
0
def test_5grps_cr2_negjumpflux(setup_cube):
    ngroups = 5
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)

    data[0, 0, 100, 100] = 1000.0
    data[0, 1:6, 100, 100] = 10
    median_diff, out_gdq =find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(4 == np.max(out_gdq)) #a CR was found
    assert(1 == np.argmax(out_gdq[0,:,100,100])) #find the CR in the expected group
Ejemplo n.º 20
0
def test_3grps_cr2_noflux(setup_cube):
    ngroups = 3
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    data[0, 0, 100, 100] = 10.0
    data[0, 1:4, 100, 100] = 1000
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold, rej_threshold, rej_threshold,
                                                     nframes, False, 200, 10)
    assert 4 == np.max(out_gdq)  # a CR was found
    assert np.array_equal([0, 4, 0], out_gdq[0, :, 100, 100])
Ejemplo n.º 21
0
def test_3grps_cr2_noflux(setup_cube):
    ngroups = 3
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    data[0, 0, 100, 100] = 10.0
    data[0, 1:4, 100, 100] = 1000
    median_diff, out_gdq = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(4 == np.max(out_gdq)) # a CR was found
    #    assert(1,np.argmax(out_gdq[0,:,100,100])) #find the CR in the expected group
    assert(np.array_equal([0, 4, 0], out_gdq[0, :, 100, 100]))
Ejemplo n.º 22
0
def test_10grps_cr2_3sigma_2frames_nocr(setup_cube):
    ngroups = 10
    crmag = 15
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,readnoise=5*np.sqrt(2))
    nframes = 2
    data[0, 0, 100, 100] = 0
    data[0, 1:11, 100, 100] = crmag
    median_diff, out_gdq = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(0 == np.max(out_gdq))  # a CR was found
    assert(np.array_equal([0, 0, 0, 0, 0, 0, 0, 0, 0, 0] , out_gdq[0, :, 100, 100]))
Ejemplo n.º 23
0
def test_5grps_cr2_negjumpflux(setup_cube):
    ngroups = 5
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)

    data[0, 0, 100, 100] = 1000.0
    data[0, 1:6, 100, 100] = 10
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold, rej_threshold, rej_threshold,
                                                     nframes, False, 200, 10)
    assert 4 == np.max(out_gdq)  # a CR was found
    assert 1 == np.argmax(out_gdq[0, :, 100, 100])  # find the CR in the expected group
Ejemplo n.º 24
0
def test_4grps_cr2_noflux(setup_cube):
    # This test should fail because with 2 CRs and only 4 groups we cannot detect the jump
    ngroups = 4
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    data[0, 0, 100, 100] = 10.0
    data[0, 1:4, 100, 100] = 1000
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold, rej_threshold, rej_threshold,
                                                     nframes, False, 200, 10)
    assert 4 == np.max(out_gdq)  # a CR was found
    assert 1 == np.argmax(out_gdq[0, :, 100, 100])  # find the CR in the expected group
Ejemplo n.º 25
0
def test_4grps_twocrs_2nd_4th(setup_cube):
    ngroups = 4
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    nframes=1
    data[0, 0, 100, 100] = 10.0
    data[0, 1, 100, 100] = 60
    data[0, 2, 100, 100] = 60
    data[0, 3, 100, 100] = 115
    median_diff, out_gdq = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(4 == np.max(out_gdq)) #a CR was found
    assert(np.array_equal([0,4,0,4] , out_gdq[0, :, 100, 100]) )
Ejemplo n.º 26
0
def test_10grps_cr2_3sigma_2frames_nocr(setup_cube):
    ngroups = 10
    crmag = 15
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups, readnoise=5 * np.sqrt(2))
    nframes = 2
    data[0, 0, 100, 100] = 0
    data[0, 1:11, 100, 100] = crmag
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold, rej_threshold, rej_threshold,
                                                     nframes, False, 200, 10)
    assert 0 == np.max(out_gdq)  # a CR was found
    assert np.array_equal([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], out_gdq[0, :, 100, 100])
Ejemplo n.º 27
0
def test_5grps_nocr(setup_cube):
    ngroups = 6
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,readnoise=10)
    nframes = 1
    data[0, 0, 100, 100] = 0
    data[0, 1, 100, 100] = 10
    data[0, 2, 100, 100] = 21
    data[0, 3, 100, 100] = 33
    data[0, 4, 100, 100] = 46
    median_diff, out_gdq = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(11 == median_diff[0, 100, 100])
Ejemplo n.º 28
0
def test_5grps_satat4_crat3(setup_cube):
    ngroups = 5
    #crmag = 1000
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,
                                                               readnoise=5 *
                                                               np.sqrt(2))
    nframes = 1
    data[0, 0, 100, 100] = 10000
    data[0, 1, 100, 100] = 30000
    data[0, 2, 100, 100] = 60000
    data[0, 3, 100, 100] = 61000
    data[0, 4, 100, 100] = 61000
    gdq[0, 3, 100, 100] = dqflags.group['SATURATED']
    gdq[0, 4, 100, 100] = dqflags.group['SATURATED']
    find_crs(data, gdq, read_noise, rej_threshold, nframes)
    # assert(4 == np.max(gdq))  # no CR was found
    assert (np.array_equal([
        0, 0, dqflags.group['JUMP_DET'], dqflags.group['SATURATED'],
        dqflags.group['SATURATED']
    ], gdq[0, :, 100, 100]))
Ejemplo n.º 29
0
def test_5grps_nocr(setup_cube):
    ngroups = 6
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,readnoise=10)
    nframes = 1
    data[0, 0, 100, 100] = 0
    data[0, 1, 100, 100] = 10
    data[0, 2, 100, 100] = 21
    data[0, 3, 100, 100] = 33
    data[0, 4, 100, 100] = 46
    median_diff = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    print("calculated median diff of pixel is ", median_diff[0, 100, 100])
    assert(11 == median_diff[0, 100, 100])
Ejemplo n.º 30
0
def test_5grps_2crs(setup_cube):
    ngroups = 5
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups, readnoise=5 * np.sqrt(2), nrows=2, ncols=2)
    nframes = 1
    data[0, 0, 1, 1] = 0
    data[0, 1, 1, 1] = 1000
    data[0, 2, 1, 1] = 1100
    data[0, 3, 1, 1] = 10000
    data[0, 4, 1, 1] = 10102
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold,
                                                     rej_threshold, rej_threshold, nframes, False, 200, 10)
    assert np.array_equal([0, 4, 0, 4, 0], out_gdq[0, :, 1, 1])
Ejemplo n.º 31
0
def test_5grps_twocrs_2nd_5thbig_nframes2(setup_cube):
    ngroups = 5
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,readnoise=10*np.sqrt(2))
    nframes=2
    data[0, 0, 100, 100] = 10.0
    data[0, 1, 100, 100] = 60
    data[0, 2, 100, 100] = 60
    data[0, 3, 100, 100] = 60
    data[0, 4, 100, 100] = 2115
    median_diff, out_gdq = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(4 == np.max(out_gdq)) #a CR was found
    assert(np.array_equal([0,4,0,0,4] , out_gdq[0, :, 100, 100]) )
Ejemplo n.º 32
0
def test_4grps_twocrs_2nd_4th(setup_cube):
    ngroups = 4
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    nframes = 1
    data[0, 0, 100, 100] = 10.0
    data[0, 1, 100, 100] = 60
    data[0, 2, 100, 100] = 60
    data[0, 3, 100, 100] = 115
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise,
                                                     rej_threshold, nframes,
                                                     False, 200, 10)
    assert np.max(out_gdq) == 4  # a CR was found
Ejemplo n.º 33
0
def test_3grps_cr2_noflux(setup_cube):
    ngroups = 3
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    data[0, 0, 100, 100] = 10.0
    data[0, 1:4, 100, 100] = 1000
    print("test data "+repr(data[0,:,100,100]))
    median_diff = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    print(repr(gdq[0, :, 100, 100]))
    print("calculated median diff of pixel is ", median_diff[0, 100, 100])
    assert(4 == np.max(gdq)) #a CR was found
    #    assert(1,np.argmax(gdq[0,:,100,100])) #find the CR in the expected group
    assert(np.array_equal([0, 4, 0], gdq[0, :, 100, 100]))
Ejemplo n.º 34
0
def test_4grps_twocrs_2nd_4th(setup_cube):
    # This test should fail because two jumps with four groups we cannot find the second jump.
    ngroups = 4
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    nframes = 1
    data[0, 0, 100, 100] = 10.0
    data[0, 1, 100, 100] = 60
    data[0, 2, 100, 100] = 60
    data[0, 3, 100, 100] = 115
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold, rej_threshold, rej_threshold,
                                                     nframes, False, 200, 10)
    assert np.max(out_gdq) == 4  # a CR was found
Ejemplo n.º 35
0
def test_5grps_cr2_nframe2(setup_cube):
    ngroups = 5
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    nframes=2
    data[0, 0, 100, 100] = 10.0
    data[0, 1, 100, 100] = 500
    data[0, 2, 100, 100] = 1002
    data[0, 3, 100, 100] = 1001
    data[0, 4, 100, 100] = 1005
    median_diff, out_gdq = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    assert(4 == np.max(out_gdq)) #a CR was found
    assert(np.array_equal([0,4,4,0,0], out_gdq[0, :, 100, 100]) )
Ejemplo n.º 36
0
def test_3grps_cr2_noflux(setup_cube):
    ngroups = 3
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    data[0, 0, 100, 100] = 10.0
    data[0, 1:4, 100, 100] = 1000
    print("test data " + repr(data[0, :, 100, 100]))
    median_diff = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    print(repr(gdq[0, :, 100, 100]))
    print("calculated median diff of pixel is ", median_diff[0, 100, 100])
    assert (4 == np.max(gdq))  #a CR was found
    #    assert(1,np.argmax(gdq[0,:,100,100])) #find the CR in the expected group
    assert (np.array_equal([0, 4, 0], gdq[0, :, 100, 100]))
Ejemplo n.º 37
0
def test_10grps_nocr_2pixels_sigma0(setup_cube):
    ngroups = 10
    crmag = 15
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups, readnoise=5 * np.sqrt(2))
    nframes = 1
    data[0, 0, 100, 100] = crmag
    data[0, 1:11, 100, 100] = crmag
    read_noise[50, 50] = 0.0
    read_noise[60, 60] = 0.0
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold, rej_threshold, rej_threshold,
                                                     nframes, False, 200, 10)
    assert 0 == np.max(out_gdq)  # no CR was found
Ejemplo n.º 38
0
def test_5grps_cr2_negslope(setup_cube):
    ngroups = 5
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    nframes = 1
    data[0, 0, 100, 100] = 100.0
    data[0, 1, 100, 100] = 0
    data[0, 2, 100, 100] = -200
    data[0, 3, 100, 100] = -260
    data[0, 4, 100, 100] = -360
    median_diff = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    print("calculated median diff of pixel is ", median_diff[0, 100, 100])
    assert(4 == np.max(gdq))  # a CR was found
    assert(np.array_equal([0, 0, 4, 0, 0] , gdq[0, :, 100, 100]))
Ejemplo n.º 39
0
def test_3grps_1cr(setup_cube):
    """"
        A test of a three group integration that has a jump in the third group of pixel 1, 1
        """
    ngroups = 3
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups, readnoise=5 * np.sqrt(2), nrows=2, ncols=2)
    nframes = 1
    data[0, 0, 1, 1] = 0
    data[0, 1, 1, 1] = 40000
    data[0, 2, 1, 1] = 44500
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold,
                                                     rej_threshold, rej_threshold, nframes, False, 200, 10)
    assert np.array_equal([0, 4, 0], out_gdq[0, :, 1, 1])
Ejemplo n.º 40
0
def test_4grps_twocrs_2nd_4th(setup_cube):
    ngroups = 4
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    nframes=1
    data[0, 0, 100, 100] = 10.0
    data[0, 1, 100, 100] = 60
    data[0, 2, 100, 100] = 60
    data[0, 3, 100, 100] = 115
    median_diff = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    print("calculated median diff of pixel is ", median_diff[0, 100, 100])
    print(repr(gdq[0, :, 100, 100]))
    assert(4 == np.max(gdq)) #a CR was found
    assert(np.array_equal([0,4,0,4] , gdq[0, :, 100, 100]) )
Ejemplo n.º 41
0
def test_5grps_twocrs_2nd_5thbig_nframes2(setup_cube):
    ngroups = 5
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups,readnoise=10*np.sqrt(2))
    nframes=2
    data[0, 0, 100, 100] = 10.0
    data[0, 1, 100, 100] = 60
    data[0, 2, 100, 100] = 60
    data[0, 3, 100, 100] = 60
    data[0, 4, 100, 100] = 2115
    median_diff = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    print("calculated median diff of pixel is ", median_diff[0, 100, 100])
    assert(4 == np.max(gdq)) #a CR was found
    assert(np.array_equal([0,4,0,0,4] , gdq[0, :, 100, 100]) )
Ejemplo n.º 42
0
def test_6grps_negative_differences_zeromedian(setup_cube):
    ngroups = 6
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)

    data[0, 0, 100, 100] = 100
    data[0, 1, 100, 100] = 90
    data[0, 2, 100, 100] = 95
    data[0, 3, 100, 100] = 105
    data[0, 4, 100, 100] = 100
    data[0, 5, 100, 100] = 100
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold, rej_threshold, rej_threshold,
                                                     nframes, False, 200, 10)
    assert 0 == np.max(out_gdq)  # no CR was found
Ejemplo n.º 43
0
def test_5grps_cr2_nframe2(setup_cube):
    ngroups = 5
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    nframes = 2
    data[0, 0, 100, 100] = 10.0
    data[0, 1, 100, 100] = 500
    data[0, 2, 100, 100] = 1002
    data[0, 3, 100, 100] = 1001
    data[0, 4, 100, 100] = 1005
    out_gdq, row_below_gdq, row_above_gdq = find_crs(data, gdq, read_noise, rej_threshold, rej_threshold, rej_threshold,
                                                     nframes, False, 200, 10)
    assert 4 == np.max(out_gdq)  # a CR was found
    assert np.array_equal([0, 4, 4, 0, 0], out_gdq[0, :, 100, 100])
Ejemplo n.º 44
0
def test_6grps_negative_differences_zeromedian(setup_cube):
    ngroups = 6
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)

    data[0, 0, 100, 100] = 100
    data[0, 1, 100, 100] = 90
    data[0, 2, 100, 100] = 95
    data[0, 3, 100, 100] = 105
    data[0, 4, 100, 100] = 100
    data[0, 5, 100, 100] = 100
    median_diff = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    print('shape '+str(median_diff.shape))
    print('median differences of 100,100 '+str(median_diff[0,100,100]))
    assert(0 == np.max(gdq)) #no CR was found
    assert(0 == median_diff[0,100,100]) #Median difference is zero
Ejemplo n.º 45
0
def test_10grps_twocrs_10percenthit(setup_cube):
    ngroups = 10
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    nframes=2
    data[0:200, 0, 100, 100] = 10.0
    data[0:200, 1, 100, 100] = 60
    data[0:200, 2, 100, 100] = 60
    data[0:200, 3, 100, 100] = 60
    data[0:200, 4, 100, 100] = 60
    data[0:200, 5, 100, 100] = 60
    data[0:200, 6, 100, 100] = 60
    data[0:200, 7, 100, 100] = 2115
    data[0:200, 8, 100, 100] = 2115
    data[0:200, 9, 100, 100] = 2115
    median_diff = find_crs(data, gdq, read_noise, rej_threshold, nframes)
    print("calculated median diff of pixel is ", median_diff[0, 100, 100])
    assert(4 == np.max(gdq)) #a CR was found
    assert(np.array_equal([0,4,0,0,0,0,0,4,0,0] , gdq[0, :, 100, 100]) )
Ejemplo n.º 46
0
def test_nocrs_noflux(setup_cube):
    ngroups = 5
    data, gdq, nframes, read_noise, rej_threshold = setup_cube(ngroups)
    assert(0 == np.max(find_crs(data, gdq, read_noise, rej_threshold, nframes))) # no CR found