Skip to content

Commit 0084443

Browse files
committed
WIP [ci skip]
1 parent 95a3d97 commit 0084443

File tree

2 files changed

+33
-29
lines changed

2 files changed

+33
-29
lines changed

src/stcal/ramp_fitting/src/slope_fitter.c

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ lists all extensions, then run:
2121
2222
python setup.py build_ext --inplace
2323
24-
or
24+
or
2525
2626
pip install -e .
2727
*/
@@ -30,7 +30,7 @@ pip install -e .
3030
/* TYPEDEFs */
3131
/* ------------------------------------------------------------------------- */
3232

33-
/*
33+
/*
3434
* Toggle internal arrays from float to doubles. The REAL_IS_DOUBLE is used
3535
* for preprocessor switches in the code. If a developer prefers to use a
3636
* float for internal arrays, this macro can be set to zero to switch from
@@ -61,7 +61,7 @@ static pid_t g_pid;
6161
char g_log_name[PATH_MAX];
6262
FILE * g_log = NULL;
6363

64-
/*
64+
/*
6565
* Deals with invalid data. This is one of the ways the python code dealt with
6666
* the limitations of numpy that aren't necessary in this code. The LARGE_VARIANCE
6767
* variable has been removed from use in this code, but due to some strange,
@@ -91,7 +91,7 @@ const real_t LARGE_VARIANCE_THRESHOLD = 1.e6;
9191
#define SET_FREE(X) if (X) {free(X); (X) = NULL;}
9292
#define FCLOSE(FD) if (FD) {fclose(FD); (FD) = NULL;}
9393

94-
/*
94+
/*
9595
* Wraps the clean_ramp_data function. Ensure all allocated
9696
* memory gets deallocated properly for the ramp_data data
9797
* structure, as well as the allocation allocation for the
@@ -104,7 +104,7 @@ const real_t LARGE_VARIANCE_THRESHOLD = 1.e6;
104104
(RD) = NULL; \
105105
}
106106

107-
/*
107+
/*
108108
* Wraps the clean_pixel_ramp function. Ensure all allocated
109109
* memory gets deallocated properly for the pixel_ramp data
110110
* structure, as well as the allocation allocation for the
@@ -116,7 +116,7 @@ const real_t LARGE_VARIANCE_THRESHOLD = 1.e6;
116116
SET_FREE(PR); \
117117
}
118118

119-
/*
119+
/*
120120
* Wraps the clean_segment_list function. Ensure all allocated
121121
* memory gets deallocated properly for the segment_list data
122122
* structure, as well as the allocation allocation for the
@@ -209,13 +209,13 @@ struct ramp_data {
209209
int special2; /* Count of segments of length 2 */
210210

211211
/*
212-
* Group and Pixel flags:
212+
* Group and Pixel flags:
213213
* DO_NOT USE, JUMP_DET, SATURATED, NO_GAIN_VALUE, UNRELIABLE_SLOPE,
214214
* CHARGELOSS, and a user defined "invalid" flag.
215215
*/
216216
uint32_t dnu, jump, sat, ngval, uslope, chargeloss, invalid;
217217

218-
/*
218+
/*
219219
* This is used only if the save_opt is non-zero, i.e., the option to
220220
* save the optional results product must be turned on.
221221
*
@@ -752,7 +752,7 @@ print_segment_opt_res(
752752
npy_intp integ, int segnum, int line);
753753

754754
static void
755-
print_stats(struct pixel_ramp * pr, npy_intp integ, int line);
755+
print_stats(struct pixel_ramp * pr, npy_intp integ, int line);
756756

757757
static void
758758
print_uint8_array(uint8_t * arr, int len, int ret, int line);
@@ -798,7 +798,7 @@ print_delim_char(char c, int len) {
798798
printf("\n");
799799
}
800800

801-
/*
801+
/*
802802
* Used to determine if a pixel is in a list.
803803
* This is a debugging function.
804804
*/
@@ -861,13 +861,13 @@ print_pid_info(long long prev, int line, char * label) {
861861
* checkers in place such that the logger is simply ignored. Maybe a more intelligent
862862
* system should be put in place to create a logger directory, but for now this
863863
* suffices.
864-
*
864+
*
865865
* I created this to debug multirpocessing. The logger captures process information
866866
* into separate logs, so any failures can be determined on a per process bases.
867867
* Redirection from the command line behaves unexpectedly when multiple processes print
868868
* to the terminal and copy and pasting from the terminal is lacking due to the amount
869869
* of data that possibly needs to be copied.
870-
*
870+
*
871871
* Each process has its own log and each log has a timestamp, so if you have successive
872872
* runs, each can be separated by time, as well as process ID.
873873
*/
@@ -930,7 +930,7 @@ ols_slope_fitter(
930930

931931
/* Allocate, fill, and validate ramp data */
932932
rd = get_ramp_data(args);
933-
if (NULL == rd) {
933+
if (NULL == rd) {
934934
goto ERROR;
935935
}
936936

@@ -1092,7 +1092,7 @@ static void
10921092
clean_pixel_ramp(
10931093
struct pixel_ramp * pr) /* Ramp fitting data for a pixel. */
10941094
{
1095-
npy_intp integ;
1095+
npy_intp integ;
10961096

10971097
if (NULL == pr) {
10981098
return; /* Nothing to do */
@@ -1109,7 +1109,7 @@ clean_pixel_ramp(
11091109

11101110
/* Clean up the allocated memory for the linked lists. */
11111111
FREE_SEGS_LIST(pr->nints, pr->segs);
1112-
1112+
11131113
/* XXX Clean CR list */
11141114
for (integ=0; integ < pr->nints; ++integ) {
11151115
cr_list_clean(&(pr->crs[integ]));
@@ -1223,7 +1223,7 @@ clean_segment_list(
12231223
struct simple_ll_node * current = NULL;
12241224
struct simple_ll_node * next = NULL;
12251225

1226-
/*
1226+
/*
12271227
* Clean each list for each integration. Each integration for
12281228
* each pixel is segmented. For each integration, there is a
12291229
* linked list of segments, so walk the linked lists and free
@@ -1828,7 +1828,7 @@ get_pixel_ramp(
18281828
pr->data[integ_idx] = zframe;
18291829
pr->groupdq[integ_idx] = 0;
18301830
pr->stats[integ].cnt_good = 1;
1831-
pr->stats[integ].cnt_dnu_sat--;
1831+
pr->stats[integ].cnt_dnu_sat--; // REMOVE???
18321832
if (pr->ngroups == pr->stats[integ].cnt_sat) {
18331833
pr->stats[integ].cnt_sat--;
18341834
}
@@ -1840,6 +1840,8 @@ get_pixel_ramp(
18401840
}
18411841
}
18421842

1843+
// ADD???
1844+
18431845
if (pr->stats[integ].jump_det) {
18441846
pr->rateints[integ].dq |= rd->jump;
18451847
pr->rate.dq |= rd->jump;
@@ -2021,7 +2023,7 @@ get_ramp_data(
20212023
err_ols_print("%s\n", msg);
20222024
goto END;
20232025
}
2024-
2026+
20252027
if (get_ramp_data_parse(&Py_ramp_data, rd, args)) {
20262028
FREE_RAMP_DATA(rd);
20272029
goto END;
@@ -2361,7 +2363,7 @@ median_rate_default(
23612363
}
23622364
accum_mrate += mrate;
23632365
}
2364-
2366+
23652367
/* The pixel median rate is the average of the integration median rates. */
23662368
pr->median_rate = accum_mrate /= (float)pr->nints;
23672369

@@ -2447,7 +2449,7 @@ median_rate_integration(
24472449
/* Sort first differences with NaN's based on DQ flags */
24482450
median_rate_integration_sort(loc_integ, int_dq, rd, pr);
24492451

2450-
/*
2452+
/*
24512453
* Get the NaN median using the sorted first differences. Note that the
24522454
* first differences has a length ngroups-1.
24532455
*/
@@ -2610,13 +2612,13 @@ package_results(
26102612
PyObject * opt_res = Py_None;
26112613
PyObject * result = Py_None;
26122614

2613-
image_info = Py_BuildValue("(NNNNN)",
2615+
image_info = Py_BuildValue("(NNNNN)",
26142616
rate->slope, rate->dq, rate->var_poisson, rate->var_rnoise, rate->var_err);
26152617
if (!image_info) {
26162618
goto FAILED_ALLOC;
26172619
}
26182620

2619-
cube_info = Py_BuildValue("(NNNNN)",
2621+
cube_info = Py_BuildValue("(NNNNN)",
26202622
rateints->slope, rateints->dq, rateints->var_poisson, rateints->var_rnoise, rateints->var_err);
26212623
if (!cube_info) {
26222624
goto FAILED_ALLOC;
@@ -2799,7 +2801,7 @@ ramp_fit_pixel(
27992801
ret = 1;
28002802
goto END;
28012803
}
2802-
2804+
28032805
if (pr->rateints[integ].dq & rd->dnu) {
28042806
dnu_cnt++;
28052807
pr->rateints[integ].slope = NAN;
@@ -3005,7 +3007,7 @@ ramp_fit_pixel_integration(
30053007
pr->rateints[integ].dq |= rd->sat;
30063008
}
30073009
return 0;
3008-
}
3010+
}
30093011

30103012
ramp_fit_pixel_integration_fit_slope(rd, pr, integ);
30113013

@@ -3342,7 +3344,7 @@ ramp_fit_pixel_integration_fit_slope_seg_default_weighted(
33423344
real_t power) /* The power of the segment */
33433345
{
33443346
struct ols_calcs ols = {0};
3345-
3347+
33463348
/* Make sure the initial values are zero */
33473349
memset(&ols, 0, sizeof(ols));
33483350
ramp_fit_pixel_integration_fit_slope_seg_default_weighted_ols(
@@ -3369,7 +3371,7 @@ ramp_fit_pixel_integration_fit_slope_seg_default_weighted_ols(
33693371
{
33703372
npy_intp idx, group;
33713373
real_t mid, weight, invrn2, invmid, data, xval, xwt;
3372-
3374+
33733375
/* Find midpoint for weight computation */
33743376
mid = (real_t)(seg->length - 1) / 2.;
33753377
invmid = 1. / mid;
@@ -3878,15 +3880,15 @@ print_segment(
38783880
printf("[%d] - ", line);
38793881
}
38803882
printf("Integration %ld, segment %d, has length %ld.\n", integ, segnum, seg->length);
3881-
3883+
38823884
idx = get_ramp_index(rd, integ, seg->start);
38833885
printf("Science Data\n[%" DBL, pr->data[idx]);
38843886
for (group = seg->start + 1; group < seg->end; ++group) {
38853887
idx = get_ramp_index(rd, integ, group);
38863888
printf(", %" DBL, pr->data[idx]);
38873889
}
38883890
printf("]\n");
3889-
3891+
38903892
idx = get_ramp_index(rd, integ, seg->start);
38913893
printf("Group DQ\n[%02x", pr->groupdq[idx]);
38923894
for (group = seg->start + 1; group < seg->end; ++group) {
@@ -4174,7 +4176,7 @@ print_PyArrayObject_info(PyArrayObject * obj) {
41744176

41754177
printf("flags:\n");
41764178
if (NPY_ARRAY_C_CONTIGUOUS & flags ) {
4177-
printf(" NPY_ARRAY_C_CONTIGUOUS\n");
4179+
printf(" NPY_ARRAY_C_CONTIGUOUS\n");
41784180
}
41794181
if (NPY_ARRAY_F_CONTIGUOUS & flags ) {
41804182
printf(" NPY_ARRAY_F_CONTIGUOUS\n");

src/stcal/ramp_fitting/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def dq_compress_sect(ramp_data, num_int, gdq_sect, pixeldq_sect):
112112
gdq0_sat = np.bitwise_and(gdq_sect[0], sat)
113113
pixeldq_sect[gdq0_sat != 0] = np.bitwise_or(pixeldq_sect[gdq0_sat != 0], sat | dnu)
114114

115+
# ADD???
116+
115117
# If jump occurs mark the appropriate flag.
116118
jump_loc = np.bitwise_and(gdq_sect, jump)
117119
jump_check = np.where(jump_loc.sum(axis=0) > 0)

0 commit comments

Comments
 (0)