From 9222a66e76b7e63325e078a7c60dd465108337b0 Mon Sep 17 00:00:00 2001 From: Ken MacDonald Date: Fri, 26 Jan 2024 10:18:56 -0500 Subject: [PATCH] Updating median rate check for segment variance computation for a 2 group ramp. --- src/stcal/ramp_fitting/src/slope_fitter.c | 46 ++++++++++++++++++----- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/stcal/ramp_fitting/src/slope_fitter.c b/src/stcal/ramp_fitting/src/slope_fitter.c index a748108df..e224c08e9 100644 --- a/src/stcal/ramp_fitting/src/slope_fitter.c +++ b/src/stcal/ramp_fitting/src/slope_fitter.c @@ -675,14 +675,16 @@ print_delim_char(char c, int len) { static inline int is_pix_in_list(struct pixel_ramp * pr) { - // [(37, 737), (11, 964), (19, 283), (3, 1702), (39, 522)] - // const int len = 5; - // npy_intp rows[len] = { 37, 11, 19, 3, 39}; - // npy_intp cols[len] = {737, 964, 283, 1702, 522}; - +#if 0 + // nrs_verify_nrs1... + // [(13, 1446), (279, 1077), (285, 576), (289, 1758), (297, 1447)] + const int len = 5; + npy_intp rows[len] = { 13, 279, 285, 289, 297}; + npy_intp cols[len] = {1446, 1077, 576, 1758, 1447}; +#endif const int len = 1; - npy_intp rows[len] = { 19}; - npy_intp cols[len] = {283}; + npy_intp rows[len] = { 13}; + npy_intp cols[len] = {1446}; int k; for (k=0; krow, pr->col); + dbg_ols_print("Median Rate = %.10f\n", pr->median_rate); + } +#endif /* Clean up any thing from the last pixel ramp */ clean_segment_list(pr->nints, pr->segs); @@ -2437,6 +2446,13 @@ ramp_fit_pixel_integration_fit_slope( pr->rateints[integ].slope = slope_i_num * var_err; pr->rateints[integ].var_err = sqrt(var_err); } +#if 0 + if (is_pix_in_list(pr)) { + dbg_ols_print("invvar_e = %.10f\n", invvar_e); + dbg_ols_print("var_err = %.10f\n", var_err); + dbg_ols_print("[%ld] var_err = %.10f\n", pr->rateints[integ].var_err); + } +#endif // DBG_INTEG_INFO; /* XXX */ @@ -2576,8 +2592,10 @@ ramp_fit_pixel_integration_fit_slope_seg_len2( seg->slope = data_diff / rd->group_time; /* Segment Poisson variance */ - pden = (rd->group_time * pr->gain); - seg->var_p = pr->median_rate / pden; + if (pr->median_rate > 0.) { + pden = (rd->group_time * pr->gain); + seg->var_p = pr->median_rate / pden; + } /* Segment read noise variance */ rnum = pr->rnoise / rd->group_time; @@ -2589,6 +2607,16 @@ ramp_fit_pixel_integration_fit_slope_seg_len2( /* Segment total variance */ // seg->var_e = 2. * pr->rnoise * pr->rnoise; /* XXX Is this right? */ seg->var_e = seg->var_p + seg->var_r; +#if 0 + if (is_pix_in_list(pr)) { + tmp = sqrt2 * pr->rnoise; + dbg_ols_print("rnoise = %.10f\n", pr->rnoise); + dbg_ols_print("seg->var_s = %.10f\n", tmp); + dbg_ols_print("seg->var_p = %.10f\n", seg->var_p); + dbg_ols_print("seg->var_r = %.10f\n", seg->var_r); + dbg_ols_print("seg->var_e = %.10f\n", seg->var_e); + } +#endif if (rd->save_opt) { seg->sigslope = sqrt2 * pr->rnoise;