Skip to content

Commit c6b5ff5

Browse files
committed
WIP: Test DQs with LIKELY
1 parent 78bbefa commit c6b5ff5

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

tests/test_ramp_fitting.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import numpy as np
2-
31
import sys
42

3+
import numpy as np
4+
import pytest
5+
56
from stcal.multiprocessing import compute_num_cores
67
from stcal.ramp_fitting.ramp_fit import ramp_fit_data
78
from stcal.ramp_fitting.ramp_fit_class import RampData
@@ -439,7 +440,8 @@ def test_miri_ramp_dnu_and_jump_at_ramp_beginning():
439440
assert abs(s2[0, 0] - answer) < tol
440441

441442

442-
def test_2_group_cases():
443+
@pytest.mark.parametrize("algo", [DEFAULT_OLS, "LIKELY"])
444+
def test_2_group_cases(algo):
443445
"""
444446
Tests the special cases of 2 group ramps. Create multiple pixel ramps
445447
with two groups to test the various DQ cases.
@@ -494,7 +496,7 @@ def test_2_group_cases():
494496
ramp_data.set_dqflags(dqflags)
495497

496498
# Run ramp fit on RampData
497-
save_opt, algo, wt, ncores = True, DEFAULT_OLS, "optimal", "none"
499+
save_opt, wt, ncores = True, "optimal", "none"
498500
slopes, cube, optional = ramp_fit_data(
499501
ramp_data, save_opt, rnoise, gain, algo, wt, ncores
500502
)
@@ -519,7 +521,7 @@ def test_2_group_cases():
519521
np.testing.assert_allclose(err, check, tol)
520522

521523

522-
def run_one_group_ramp_suppression(nints, suppress):
524+
def run_one_group_ramp_suppression(nints, suppress, algo=DEFAULT_OLS):
523525
"""
524526
Forms the base of the one group suppression tests. Create three ramps
525527
using three pixels with two integrations. In the first integration:
@@ -568,7 +570,6 @@ def run_one_group_ramp_suppression(nints, suppress):
568570

569571
ramp_data.suppress_one_group_ramps = suppress
570572

571-
algo = DEFAULT_OLS
572573
save_opt, ncores = False, "none"
573574
slopes, cube, ols_opt = ramp_fit_data(
574575
ramp_data, save_opt, rnoise2d, gain2d, algo, "optimal", ncores
@@ -577,11 +578,12 @@ def run_one_group_ramp_suppression(nints, suppress):
577578
return slopes, cube, dims
578579

579580

580-
def test_one_group_ramp_suppressed_one_integration():
581+
@pytest.mark.parametrize("algo", [DEFAULT_OLS, "LIKELY"])
582+
def test_one_group_ramp_suppressed_one_integration(algo):
581583
"""
582584
Tests one group ramp fitting where suppression turned on.
583585
"""
584-
slopes, cube, dims = run_one_group_ramp_suppression(1, True)
586+
slopes, cube, dims = run_one_group_ramp_suppression(1, True, algo=algo)
585587
nints, ngroups, nrows, ncols = dims
586588
tol = 1e-5
587589

tests/test_ramp_fitting_likely_fit.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def create_blank_ramp_data(dims, var, tm):
3838
data = np.zeros(shape=(nints, ngroups, nrows, ncols), dtype=np.float32)
3939
pixdq = np.zeros(shape=(nrows, ncols), dtype=np.uint32)
4040
gdq = np.zeros(shape=(nints, ngroups, nrows, ncols), dtype=np.uint8)
41-
dark_current = np.zeros(shape=(nrows, ncols), dtype = np.float32)
41+
dark_current = np.zeros(shape=(nrows, ncols), dtype=np.float32)
4242

4343
ramp_data = RampData()
4444
ramp_data.set_arrays(data=data, groupdq=gdq, pixeldq=pixdq, average_dark_current=dark_current)
@@ -152,7 +152,7 @@ def test_basic_ramp_multi_pixel():
152152
data_tol = 1e-4
153153
err_tol = 0.1
154154
np.testing.assert_allclose(data, data1, data_tol)
155-
np.testing.assert_allclose(dq, dq1)
155+
np.testing.assert_array_equal(dq, dq1)
156156
np.testing.assert_allclose(vp, vp1, err_tol)
157157
np.testing.assert_allclose(vr, vr1, err_tol)
158158
np.testing.assert_allclose(err, err1, err_tol)
@@ -266,8 +266,7 @@ def test_long_ramp():
266266

267267
data = cube[0][0, 0, 0]
268268
ddiff = (ramp_data.data[0, ngroups-1, 0, 0] - ramp_data.data[0, 0, 0, 0])
269-
check = ddiff / float(ngroups-1)
270-
check = check / ramp_data.group_time
269+
check = ddiff / ((ngroups - 1) * ramp_data.group_time)
271270
tol = 1.e-5
272271
np.testing.assert_allclose(data, check, tol)
273272

@@ -309,8 +308,7 @@ def test_short_group_ramp(nframes):
309308

310309
data = cube[0][0, 0, 0]
311310
ddiff = (ramp_data.data[0, ngroups-1, 0, 0] - ramp_data.data[0, 0, 0, 0])
312-
check = ddiff / float(ngroups-1)
313-
check = check / ramp_data.group_time
311+
check = ddiff / ((ngroups - 1) * ramp_data.group_time)
314312
tol = 1.e-5
315313
np.testing.assert_allclose(data, check, tol)
316314

@@ -467,10 +465,10 @@ def test_zeroframe_bad_group(caplog):
467465
np.testing.assert_allclose(slopes[0], slopes1[0], tol)
468466

469467

470-
471468
# -----------------------------------------------------------------
472469
# DEBUG
473470
# -----------------------------------------------------------------
471+
474472
def dbg_print_basic_ramp(ramp_data, pix=(0, 0)):
475473
row, col = pix
476474
nints = ramp_data.data.shape[0]

0 commit comments

Comments
 (0)