UVES Pipeline Reference Manual  5.4.0
Functions
Iterate over an image

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)

Detailed Description

This class exists in order to be able to write

for (uves_iterate_set_first(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


Function Documentation

static bool illegal_position ( const uves_iterate_position *  p)
static

Find out if the current position is valid.

Parameters:
piterator to check
Returns:
true iff the current position is a good pixel and the entire slit is inside the image

Definition at line 347 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.

Parameters:
imagethe image to iterate over
order_locationsorder polynomial
minorderfirst order (inclusive) in image
maxorderlast order (inclusive) in image
slit_geometryextraction slit length and offset
Returns:
newly allocated iterator which must be deallocated using uves_iterate_delete

The iterator, pos, should be used in constructs like

xmin,
xmax,
ordermin, ordermax,
current_image_bpm, true);
{
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 154 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.

Parameters:
piterator to delete

Definition at line 178 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.

Parameters:
piterator to initialize
xminminimum x bin
xmaxmaximum x bin
orderminfirst order to iterate over
ordermaxlast order to iterate over
bpmimage bad pixel map to use for this iteration. If NULL all pixels are considered good
loop_yif 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 203 of file uves_extract_iterate.c.

References illegal_position(), uves_iterate_finished(), uves_iterate_increment(), and uves_polynomial_evaluate_2d().

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)
bool uves_iterate_finished ( const uves_iterate_position *  p)

Finished iterating?

Parameters:
piterator to check
Returns:
false if p contains a valid position, false if the iteration is over

This function should always be checked after calling uves_iterate_increment() and uves_iterate_set_first()

Definition at line 301 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)

Parameters:
piterator to check
streamstream to write to

Definition at line 314 of file uves_extract_iterate.c.