diff --git a/CHANGES.rst b/CHANGES.rst index de16adf1..09f78790 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,7 +14,13 @@ Changes to API Bug Fixes --------- -- + +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) ================== diff --git a/src/stcal/ramp_fitting/ols_fit.py b/src/stcal/ramp_fitting/ols_fit.py index f440ba6d..1473dd86 100644 --- a/src/stcal/ramp_fitting/ols_fit.py +++ b/src/stcal/ramp_fitting/ols_fit.py @@ -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 @@ -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 @@ -661,9 +664,7 @@ 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() @@ -671,9 +672,12 @@ def ols_ramp_fit_single(ramp_data, buffsize, save_opt, readnoise_2d, gain_2d, we 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 @@ -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 diff --git a/src/stcal/ramp_fitting/ramp_fit.py b/src/stcal/ramp_fitting/ramp_fit.py index 55d0372c..e1660937 100755 --- a/src/stcal/ramp_fitting/ramp_fit.py +++ b/src/stcal/ramp_fitting/ramp_fit.py @@ -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 diff --git a/src/stcal/ramp_fitting/ramp_fit_class.py b/src/stcal/ramp_fitting/ramp_fit_class.py index 37d4c356..9e2c3bf9 100644 --- a/src/stcal/ramp_fitting/ramp_fit_class.py +++ b/src/stcal/ramp_fitting/ramp_fit_class.py @@ -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.