Functions | |
static bool | illegal_position (const uves_iterate_position *p) |
Find out if the current position is valid. | |
uves_iterate_position * | uves_iterate_new (int nx, int ny, const polynomial *order_locations, int minorder, int maxorder, slit_geometry sg) |
Allocate iterator. | |
void | uves_iterate_delete (uves_iterate_position **p) |
Deallocate iterator and set pointer to NULL. | |
void | uves_iterate_set_first (uves_iterate_position *p, int xmin, int xmax, int ordermin, int ordermax, const cpl_binary *bpm, bool loop_y) |
Initialize iteration. | |
void | uves_iterate_increment (uves_iterate_position *p) |
Get next position. | |
bool | uves_iterate_finished (const uves_iterate_position *p) |
Finished iterating? | |
void | uves_iterate_dump (const uves_iterate_position *p, FILE *stream) |
dump iterator (for debugging) |
This class exists in order to be able to write
for (uves_iterate_set_first(pos, ...); !uves_iterate_finished(pos); uves_iterate_increment(pos)) { do something }
instead of repeating the same structure of nested loops + selections again and again in the extraction module. I.e. to avoid repetitions of (in pseudocode)
for each order ... for each bin ... calculate limits for this bin for each position on the slit ... if pixel is good ... do something
where only the "do something" part is different
static bool illegal_position | ( | const uves_iterate_position * | p | ) | [static] |
Find out if the current position is valid.
p | iterator to check |
Definition at line 350 of file uves_extract_iterate.c.
Referenced by uves_iterate_increment(), and uves_iterate_set_first().
uves_iterate_position* uves_iterate_new | ( | int | nx, | |
int | ny, | |||
const polynomial * | order_locations, | |||
int | minorder, | |||
int | maxorder, | |||
slit_geometry | sg | |||
) |
Allocate iterator.
image | the image to iterate over | |
order_locations | order polynomial | |
minorder | first order (inclusive) in image | |
maxorder | last order (inclusive) in image | |
slit_geometry | extraction slit length and offset |
The iterator, pos, should be used in constructs like
for (uves_iterate_set_first(pos, xmin, xmax, ordermin, ordermax, current_image_bpm, true); !uves_iterate_finished(pos); uves_iterate_increment(pos)) { flux += image[p->x, p->y]; }
The struct members
int order; int x, y; double ycenter; int ylow; int yhigh;
can be accessed inside the loop.
Definition at line 157 of file uves_extract_iterate.c.
Referenced by create_spectrum(), test_extract(), test_iterate(), and uves_extract().
void uves_iterate_delete | ( | uves_iterate_position ** | p | ) |
Deallocate iterator and set pointer to NULL.
p | iterator to delete |
Definition at line 181 of file uves_extract_iterate.c.
Referenced by create_spectrum(), test_extract(), test_iterate(), and uves_extract().
void uves_iterate_set_first | ( | uves_iterate_position * | p, | |
int | xmin, | |||
int | xmax, | |||
int | ordermin, | |||
int | ordermax, | |||
const cpl_binary * | bpm, | |||
bool | loop_y | |||
) |
Initialize iteration.
p | iterator to initialize | |
xmin | minimum x bin | |
xmax | maximum x bin | |
ordermin | first order to iterate over | |
ordermax | last order to iterate over | |
bpm | image bad pixel map to use for this iteration. If NULL all pixels are considered good | |
loop_y | if true, the iteration is over (order, x, y). If false, the iteration is over (order, x) only, and the bpm is not used |
Definition at line 206 of file uves_extract_iterate.c.
References illegal_position(), uves_iterate_finished(), uves_iterate_increment(), uves_polynomial_evaluate_2d(), and uves_round_double().
Referenced by create_spectrum(), estimate_sn(), opt_extract(), opt_measure_profile(), opt_measure_profile_order(), opt_sample_spatial_profile(), opt_subtract_sky(), revise_noise(), test_iterate(), uves_create_image(), and uves_extract().
void uves_iterate_increment | ( | uves_iterate_position * | p | ) |
Get next position.
p | iterator to increment |
p is changed to contain the next position
Definition at line 249 of file uves_extract_iterate.c.
References illegal_position(), uves_iterate_finished(), uves_polynomial_evaluate_2d(), and uves_round_double().
Referenced by create_spectrum(), estimate_sn(), opt_extract(), opt_measure_profile(), opt_measure_profile_order(), opt_sample_spatial_profile(), opt_subtract_sky(), revise_noise(), test_iterate(), uves_create_image(), uves_extract(), and uves_iterate_set_first().
bool uves_iterate_finished | ( | const uves_iterate_position * | p | ) |
Finished iterating?
p | iterator to check |
This function should always be checked after calling uves_iterate_increment() and uves_iterate_set_first()
Definition at line 304 of file uves_extract_iterate.c.
Referenced by create_spectrum(), estimate_sn(), opt_extract(), opt_measure_profile(), opt_measure_profile_order(), opt_sample_spatial_profile(), opt_subtract_sky(), revise_noise(), test_iterate(), uves_create_image(), uves_extract(), uves_iterate_increment(), and uves_iterate_set_first().
void uves_iterate_dump | ( | const uves_iterate_position * | p, | |
FILE * | stream | |||
) |
dump iterator (for debugging)
p | iterator to check | |
stream | stream to write to |
Definition at line 317 of file uves_extract_iterate.c.