Skip to content

Commit

Permalink
Final draft commit of C code for ramp fitting.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmacdonald-stsci committed Mar 1, 2024
1 parent 0fe770c commit 480cec0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/stcal/ramp_fitting/ols_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .slope_fitter import ols_slope_fitter # c extension
from . import ramp_fit_class, utils


log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)

Expand Down Expand Up @@ -658,8 +659,8 @@ 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
use_c = False
# use_c = True
# use_c = ramp_data.dbg_run_c_code
if use_c:
print(" ")
Expand Down
18 changes: 8 additions & 10 deletions src/stcal/ramp_fitting/src/slope_fitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,6 @@ median_rate_default(
if (median_rate_integration(&mrate, int_data, int_dq, rd, pr)) {
goto END;
}
// dbg_ols_print("integ = %ld, mrate = %f\n", integ, mrate);
}
if (isnan(mrate)) {
mrate = 0.;
Expand Down Expand Up @@ -2295,7 +2294,7 @@ ramp_fit_pixel(
goto END;
}
#if 0
// print_delim();
print_delim();
dbg_ols_print("Pixel (%ld, %ld)\n", pr->row, pr->col);
dbg_ols_print("Median Rate = %.10f\n", pr->median_rate);
print_delim();
Expand All @@ -2307,8 +2306,7 @@ ramp_fit_pixel(
/* Compute the ramp fit per each integration. */
for (integ=0; integ < pr->nints; ++integ) {
current_integration = integ;
// print_delim();
// dbg_ols_print("Integration: %ld\n", integ);

if (ramp_fit_pixel_integration(rd, pr, integ)) {
ret = 1;
goto END;
Expand Down Expand Up @@ -2398,7 +2396,7 @@ ramp_fit_pixel_integration(
}

#define DBG_SEG_ID do {\
dbg_ols_print(" *** [%ld] (%ld, %ld) Seg: %d, Length: %ld, Start: %ld, End: %ld\n", \
dbg_ols_print(" *** [Integ: %ld] (%ld, %ld) Seg: %d, Length: %ld, Start: %ld, End: %ld\n", \
integ, pr->row, pr->col, segcnt, current->length, current->start, current->end); \
} while(0)

Expand All @@ -2410,10 +2408,10 @@ ramp_fit_pixel_integration(
} while(0)

#define DBG_DEFAULT_SEG do {\
dbg_ols_print("current->slope = %f.10\n", current->slope); \
dbg_ols_print("current->var_p = %f.10\n", current->var_p); \
dbg_ols_print("current->var_r = %f.10\n", current->var_r); \
dbg_ols_print("current->var_e = %f.10\n", current->var_e); \
dbg_ols_print("current->slope = %.10f\n", current->slope); \
dbg_ols_print("current->var_p = %.10f\n", current->var_p); \
dbg_ols_print("current->var_r = %.10f\n", current->var_r); \
dbg_ols_print("current->var_e = %.10f\n", current->var_e); \
} while(0)

static int
Expand Down Expand Up @@ -3331,7 +3329,7 @@ print_real_array(char * label, real_t * arr, int len, int ret, int line) {
}
printf("[%f", arr[0]);
for (k=1; k<len; ++k) {
printf(", %f", arr[k]);
printf(", %.10f", arr[k]);
}
printf("]");
if (ret) {
Expand Down

0 comments on commit 480cec0

Please sign in to comment.