Skip to content

Commit

Permalink
Merge branch 'main' into jp3678DRL
Browse files Browse the repository at this point in the history
  • Loading branch information
nden authored Jul 5, 2024
2 parents 8066573 + 8a36bf4 commit c6703f0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ ramp_fitting
- Fix bugs in the C algorithm Poisson variance calculation when provided with
an average dark current. [#269]

=======

ramp_fitting
~~~~~~~~~~~~

- When OLS_C was selected as the ramp fitting algorithm with multiprocessing, the C
extension was not called. The old python code was called. This bug has been fixed,
so the C extension is properly run when selecting multiprocessing. [#268]

1.7.2 (2024-06-12)
==================
Expand Down
12 changes: 9 additions & 3 deletions src/stcal/ramp_fitting/ols_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def ols_ramp_fit_multi(ramp_data, buffsize, save_opt, readnoise_2d, gain_2d, wei
nrows = ramp_data.data.shape[2]
num_available_cores = cpu_count()
number_slices = utils.compute_num_slices(max_cores, nrows, num_available_cores)
log.info(f"Number of multiprocessing slices: {number_slices}")

# For MIRI datasets having >1 group, if all pixels in the final group are
# flagged as DO_NOT_USE, resize the input model arrays to exclude the
Expand Down Expand Up @@ -574,6 +575,8 @@ def slice_ramp_data(ramp_data, start_row, nrows):
ramp_data_slice.start_row = start_row
ramp_data_slice.num_rows = nrows

ramp_data_slice.run_c_code = ramp_data.run_c_code

return ramp_data_slice


Expand Down Expand Up @@ -661,19 +664,20 @@ def ols_ramp_fit_single(ramp_data, buffsize, save_opt, readnoise_2d, gain_2d, we
opt_info : tuple
The tuple of computed optional results arrays for fitting.
"""
# use_c = False
# use_c = True # XXX Change to default as False
use_c = ramp_data.dbg_run_c_code
use_c = ramp_data.run_c_code
if use_c:
c_start = time.time()

ramp_data, gain_2d, readnoise_2d, bswap = endianness_handler(ramp_data, gain_2d, readnoise_2d)

if ramp_data.drop_frames1 is None:
ramp_data.drop_frames1 = 0
log.debug("Entering C extension")
image_info, integ_info, opt_info = ols_slope_fitter(
ramp_data, gain_2d, readnoise_2d, weighting, save_opt)

log.debug("Returning from C extension")

c_end = time.time()

# Read noise is used after STCAL ramp fitting for the CHARGELOSS
Expand All @@ -694,8 +698,10 @@ def ols_ramp_fit_single(ramp_data, buffsize, save_opt, readnoise_2d, gain_2d, we

p_start = time.time()

log.debug("Entering python code")
image_info, integ_info, opt_info = ols_ramp_fit_single_python(
ramp_data, buffsize, save_opt, readnoise_2d, gain_2d, weighting)
log.debug("Returning from python ")

p_end = time.time()
p_diff = p_end - p_start
Expand Down
2 changes: 1 addition & 1 deletion src/stcal/ramp_fitting/ramp_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def ramp_fit(
ramp_data = create_ramp_fit_class(model, dqflags, suppress_one_group)

if algorithm.upper() == "OLS_C":
ramp_data.dbg_run_c_code = True
ramp_data.run_c_code = True

return ramp_fit_data(
ramp_data, buffsize, save_opt, readnoise_2d, gain_2d, algorithm, weighting, max_cores, dqflags
Expand Down
2 changes: 1 addition & 1 deletion src/stcal/ramp_fitting/ramp_fit_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self):
self.suppress_one_group_ramps = False

# C code debugging switch.
self.dbg_run_c_code = False
self.run_c_code = False

self.one_groups_locs = None # One good group locations.
self.one_groups_time = None # Time to use for one good group ramps.
Expand Down

0 comments on commit c6703f0

Please sign in to comment.