Skip to content

Commit ff89de9

Browse files
kmacdonald-stscihbushouse
authored andcommitted
JP-3242: Proper Handling of Timing for Final Slope Computation for only 0th Good Group Ramps (spacetelescope#7612)
Co-authored-by: Howard Bushouse <[email protected]>
1 parent 3aafb95 commit ff89de9

File tree

4 files changed

+46
-37
lines changed

4 files changed

+46
-37
lines changed

CHANGES.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
1.11.1 (unreleased)
22
===================
33

4-
-
4+
ramp_fitting
5+
------------
6+
7+
- Updated the CI tests due to change in STCAL, which fixed bug for using the
8+
correct timing for slope computation. Since there are now special cases that
9+
use ZEROFRAME data, as well as ramps that have only good data in the 0th
10+
group, the timing for these ramps is not group time. These adjusted times
11+
are now used. [#7612, spacetelescope/stcal#173]
12+
513

614
1.11.0 (2023-06-21)
715
===================

jwst/ramp_fitting/tests/test_ramp_fit.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,10 @@ def test_twenty_groups_two_segments():
744744
np.testing.assert_allclose(oslope[wh_data], 10. / deltatime, rtol=1E-4)
745745
np.testing.assert_allclose(oyint[0, 0, 0, :], model1.data[0, 0, 0, :], rtol=1E-5)
746746

747-
np.testing.assert_allclose(
748-
opedestal[0, 0, :],
749-
model1.data[0, 0, 0, :] - 10.,
750-
rtol=1E-5)
747+
check = model1.data[0, 0, 0, :] - oslope
748+
tol = 1E-5
749+
# Pixel 1 has zero slope, so ignore it.
750+
np.testing.assert_allclose(opedestal[0, 0, 1:], check[0, 0, 0, 1:], tol)
751751

752752

753753
def test_miri_all_sat():
@@ -897,7 +897,7 @@ def test_zeroframe_usage():
897897
# Check slopes information
898898
sdata, sdq, svp, svr, serr = slopes
899899

900-
check = np.array([[20.709406, 0.46572033, 4.6866207]])
900+
check = np.array([[41.003822, 0.46572033, 21.655062]])
901901
np.testing.assert_allclose(sdata, check, tol, tol)
902902

903903
# Since the second integration is GOOD the final DQ is GOOD.
@@ -916,8 +916,8 @@ def test_zeroframe_usage():
916916
# Check slopes information
917917
cdata, cdq, cvp, cvr, cerr = cube
918918

919-
check = np.array([[[186.28912, np.nan, 93.14456]],
920-
[[0.46572027, 0.46572033, 0.46572033]]])
919+
check = np.array([[[3.7257825e+02, np.nan, 4.6572281e+02]],
920+
[[4.6572030e-01, 4.6572030e-01, 4.6572030e-01]]])
921921
np.testing.assert_allclose(cdata, check, tol, tol)
922922

923923
# Column 2 in the first integration is marked GOOD because there
@@ -1041,8 +1041,8 @@ def setup_small_cube(ngroups=10, nints=1, nrows=2, ncols=2, deltatime=10.,
10411041

10421042

10431043
# Need test for multi-ints near zero with positive and negative slopes
1044-
def setup_inputs(ngroups=10, readnoise=10, nints=1,
1045-
nrows=103, ncols=102, nframes=1, grouptime=1.0, gain=1, deltatime=1):
1044+
def setup_inputs(ngroups=10, readnoise=10, nints=1, nrows=103, ncols=102,
1045+
nframes=1, grouptime=1.0, gain=1, deltatime=1):
10461046

10471047
data = np.zeros(shape=(nints, ngroups, nrows, ncols), dtype=np.float32)
10481048
err = np.ones(shape=(nints, ngroups, nrows, ncols), dtype=np.float32)

jwst/ramp_fitting/tests/test_ramp_fit_cases.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from stdatamodels.jwst.datamodels import RampModel, GainModel, ReadnoiseModel, dqflags
77

8+
89
#
910
# The first 12 tests are for a single ramp in a single integration. The ramps
1011
# have a variety of GROUPDQ vectors, with 1 or more segments in each ramp. The
@@ -54,7 +55,7 @@ def test_pix_0():
5455
# Set truth values for OPTIONAL results:
5556
# [slope, sigslope, var_poisson, var_rnoise, yint, sigyint, ped, weights]
5657
o_true = [1.0117551, 4.874572, 0.0020202, 0.00647973,
57-
15.911023, 27.789335, 4.882449, 13841.038]
58+
15.911023, 27.789335, 13.988245, 13841.038]
5859

5960
assert_pri(p_true, new_mod, 0)
6061
assert_opt(o_true, opt_mod, 0)
@@ -92,7 +93,7 @@ def test_pix_1():
9293

9394
# Set truth values for OPTIONAL results:
9495
o_true = [1.9, 56.870003, 0.03454545, 1.0691562, -3., 56.870003,
95-
-3.999998, 0.82091206]
96+
13.1, 0.82091206]
9697

9798
assert_pri(p_true, new_mod, 0)
9899
assert_opt(o_true, opt_mod, 0)
@@ -129,7 +130,7 @@ def test_pix_2():
129130
[0.26728904, 1.0691562, 1.0691562], # var_rnoise
130131
[14.999998, 51., 15.], # yint
131132
[36.709427, 56.870003, 56.870003], # sigyint
132-
[6.5166273], # pedestal
133+
[14.151663], # pedestal
133134
[13.091425, 0.84580624, 0.84580624], # weights
134135
]
135136

@@ -169,7 +170,7 @@ def test_pix_3():
169170
[0.01272805, 1.0691562],
170171
[14.504965, 15.],
171172
[27.842508, 56.870003],
172-
[4.253134],
173+
[13.925313],
173174
[4.2576841e+03, 8.458062e-01],
174175
]
175176

@@ -202,7 +203,7 @@ def test_pix_4():
202203
p_true = [1.5, GOOD, 1.047105, 0.02727273, 1.0691562]
203204

204205
# Set truth values for OPTIONAL results:
205-
o_true = [1.5, 0., 0.02727273, 1.0691562, 0., 0., 0., 0.8318386]
206+
o_true = [1.5, 0., 0.02727273, 1.0691562, 0., 0., 13.5, 0.8318386]
206207

207208
assert_pri(p_true, new_mod, 0)
208209
assert_opt(o_true, opt_mod, 0)
@@ -241,7 +242,7 @@ def test_pix_5():
241242
[0.10691562, 0.03054732],
242243
[13.537246, 2015.0737],
243244
[35.301933, 67.10882],
244-
[4.2391253],
245+
[13.923912],
245246
[78.34764, 855.78046]
246247
]
247248

@@ -282,7 +283,7 @@ def test_pix_6():
282283
[1.0691562, 0.01909207],
283284
[15., -143.2391],
284285
[56.870003, 58.76999],
285-
[-45.92052],
286+
[8.907948],
286287
[8.4580624e-01, 2.0433204e+03]
287288
]
288289

@@ -315,7 +316,7 @@ def test_pix_7():
315316

316317
# Set truth values for OPTIONAL results:
317318
o_true = [1.0757396, 6.450687, 0.0025974, 0.01272805, 14.504951,
318-
27.842508, 4.2426033, 4257.684]
319+
27.842508, 13.92426, 4257.684]
319320

320321
assert_pri(p_true, new_mod, 0)
321322
assert_opt(o_true, opt_mod, 0)
@@ -347,7 +348,7 @@ def test_pix_8():
347348

348349
# Set truth values for OPTIONAL results:
349350
o_true = [0.98561335, 9.920554, 0.00363636, 0.03054732, 16.508228,
350-
39.383667, 5.1438665, 855.78046]
351+
39.383667, 14.014386, 855.78046]
351352

352353
assert_pri(p_true, new_mod, 0)
353354
assert_opt(o_true, opt_mod, 0)
@@ -385,7 +386,7 @@ def test_pix_9():
385386
[1.0691562, 0.05345781, 1.0691562],
386387
[15., 20.119896, 15.],
387388
[56.870003, 68.618195, 56.870003],
388-
[5.000005],
389+
[14.],
389390
[0.84580624, 297.23172, 0.84580624]
390391
]
391392

@@ -425,7 +426,7 @@ def test_pix_10():
425426
[1.0691562, 0.26728904, 0.05345781],
426427
[15., 17.999956, 15.000029],
427428
[56.870003, 88.40799, 93.73906],
428-
[5.],
429+
[14.],
429430
[0.84580624, 13.091425, 297.23172]
430431
]
431432

@@ -457,7 +458,7 @@ def test_pix_11():
457458
p_true = [1., GOOD, 1.042755, 0.01818182, 1.0691562]
458459

459460
# Set truth values for OPTIONAL results:
460-
o_true = [1., 56.870003, 0.01818182, 1.0691562, 15., 56.870003, 5.,
461+
o_true = [1., 56.870003, 0.01818182, 1.0691562, 15., 56.870003, 14.,
461462
0.84580624]
462463

463464
assert_pri(p_true, new_mod, 0)
@@ -498,7 +499,7 @@ def test_pix_12():
498499
# slope, sig_slope, var_p, var_r, yint, sig_yint, pedestal, weights
499500
# slope = group1 / deltatime = 15 / 10 = 1.5
500501
# sig_slope, yint, sig_yint, and pedestal are all zero, because only 1 good group
501-
o_true = [1.5, 0., 0.027273, 1.069156, 0., 0., 0., 0.831839]
502+
o_true = [1.5, 0., 0.027273, 1.069156, 0., 0., 13.5, 0.831839]
502503

503504
assert_pri(p_true, new_mod, 0)
504505
assert_opt(o_true, opt_mod, 0)
@@ -544,7 +545,7 @@ def test_miri_0():
544545

545546
# Set truth values for OPTIONAL results:
546547
o_true = [1.025854, 6.450687, 0.0025974, 0.01272805, 26.439266, 27.842508,
547-
14.74146, 4257.684]
548+
23.974146, 4257.684]
548549

549550
assert_pri(p_true, new_mod, 0)
550551
assert_opt(o_true, opt_mod, 0)
@@ -576,7 +577,7 @@ def test_miri_1():
576577

577578
# Set truth values for OPTIONAL results:
578579
o_true = [1.1996487, 6.450687, 0.0025974, 0.01272805, 126.110214,
579-
27.842508, 113.00351, 4257.684]
580+
27.842508, 123.800354, 4257.684]
580581

581582
assert_pri(p_true, new_mod, 0)
582583
assert_opt(o_true, opt_mod, 0)
@@ -608,7 +609,7 @@ def test_miri_2():
608609

609610
# Set truth values for OPTIONAL results:
610611
o_true = [1.025854, 6.450687, 0.0025974, 0.01272805, 26.439266, 27.842508,
611-
14.74146, 4257.684]
612+
23.974146, 4257.684]
612613

613614
assert_pri(p_true, new_mod, 0)
614615
assert_opt(o_true, opt_mod, 0)
@@ -640,7 +641,7 @@ def test_miri_3():
640641

641642
# Set truth values for OPTIONAL results:
642643
o_true = [1.025854, 6.450687, 0.0025974, 0.01272805, 26.439266,
643-
27.842508, 14.74146, 4257.684]
644+
27.842508, 23.974146, 4257.684]
644645

645646
assert_pri(p_true, new_mod, 0)
646647
assert_opt(o_true, opt_mod, 0)

jwst/ramp_fitting/tests/test_ramp_fit_step.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def test_one_group_not_suppressed_one_integration(setup_inputs):
330330
tol = 1e-5
331331

332332
# Check slopes information
333-
check = np.array([[np.nan, 1., 1.0000002]])
333+
check = np.array([[np.nan, .2, 0.2]])
334334
np.testing.assert_allclose(slopes.data, check, tol)
335335

336336
check = np.array([[DNU | SAT, GOOD, GOOD]])
@@ -346,7 +346,7 @@ def test_one_group_not_suppressed_one_integration(setup_inputs):
346346
np.testing.assert_allclose(slopes.err, check, tol)
347347

348348
# Check slopes information
349-
check = np.array([[[np.nan, 1., 1.0000001]]])
349+
check = np.array([[[np.nan, .2, .2]]])
350350
np.testing.assert_allclose(cube.data, check, tol)
351351

352352
check = np.array([[[DNU | SAT, GOOD, GOOD]]])
@@ -377,7 +377,7 @@ def test_one_group_suppressed_one_integration(setup_inputs):
377377
tol = 1e-5
378378

379379
# Check slopes information
380-
check = np.array([[np.nan, np.nan, 1.0000002]])
380+
check = np.array([[np.nan, np.nan, .2]])
381381
np.testing.assert_allclose(slopes.data, check, tol)
382382

383383
check = np.array([[DNU | SAT, DNU, GOOD]])
@@ -393,7 +393,7 @@ def test_one_group_suppressed_one_integration(setup_inputs):
393393
np.testing.assert_allclose(slopes.err, check, tol)
394394

395395
# Check slopes information
396-
check = np.array([[[np.nan, np.nan, 1.0000001]]])
396+
check = np.array([[[np.nan, np.nan, .2]]])
397397
np.testing.assert_allclose(cube.data, check, tol)
398398

399399
check = np.array([[[DNU | SAT, DNU, 0]]])
@@ -426,7 +426,7 @@ def test_one_group_not_suppressed_two_integrations(setup_inputs):
426426
tol = 1e-5
427427

428428
# Check slopes information
429-
check = np.array([[1.0000001, 1.0000002, 1.0000002]])
429+
check = np.array([[.2, .2, .2]])
430430
np.testing.assert_allclose(slopes.data, check, tol)
431431

432432
check = np.array([[GOOD, GOOD, GOOD]])
@@ -442,8 +442,8 @@ def test_one_group_not_suppressed_two_integrations(setup_inputs):
442442
np.testing.assert_allclose(slopes.err, check, tol)
443443

444444
# Check slopes information
445-
check = np.array([[[np.nan, 1., 1.0000001]],
446-
[[1.0000001, 1.0000001, 1.0000001]]])
445+
check = np.array([[[np.nan, .2, .2]],
446+
[[.2, .2, .2]]])
447447
np.testing.assert_allclose(cube.data, check, tol)
448448

449449
check = np.array([[[SAT | DNU, GOOD, GOOD]],
@@ -480,7 +480,7 @@ def test_one_group_suppressed_two_integrations(setup_inputs):
480480
tol = 1e-5
481481

482482
# Check slopes information
483-
check = np.array([[1.0000001, 1.0000001, 1.0000002]])
483+
check = np.array([[.2, .2, .2]])
484484
np.testing.assert_allclose(slopes.data, check, tol)
485485

486486
check = np.array([[GOOD, GOOD, GOOD]])
@@ -496,8 +496,8 @@ def test_one_group_suppressed_two_integrations(setup_inputs):
496496
np.testing.assert_allclose(slopes.err, check, tol)
497497

498498
# Check slopes information
499-
check = np.array([[[np.nan, np.nan, 1.0000001]],
500-
[[1.0000001, 1.0000001, 1.0000001]]])
499+
check = np.array([[[np.nan, np.nan, .2]],
500+
[[.2, .2, .2]]])
501501
np.testing.assert_allclose(cube.data, check, tol)
502502

503503
check = np.array([[[DNU | SAT, DNU, GOOD]],

0 commit comments

Comments
 (0)