Skip to content

Commit

Permalink
Updating median rate check for segment variance computation for a 2 g…
Browse files Browse the repository at this point in the history
…roup ramp.
  • Loading branch information
kmacdonald-stsci committed Jan 26, 2024
1 parent 6e48cd0 commit 9222a66
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions src/stcal/ramp_fitting/src/slope_fitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; k<len; ++k) {
Expand Down Expand Up @@ -2266,6 +2268,13 @@ ramp_fit_pixel(
ret = 1;
goto END;
}
#if 0
if (is_pix_in_list(pr)) {
print_delim();
dbg_ols_print("Pixel (%ld, %ld)\n", pr->row, 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);
Expand Down Expand Up @@ -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 */

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 9222a66

Please sign in to comment.