HAWKI Pipeline Reference Manual 1.8.12
Data Structures | Functions
Distortion correction

Data Structures

struct  _hawki_distortion_obj_function_args_

Functions

int hawki_distortion_apply_maps (cpl_imagelist *ilist, cpl_image **dist_x, cpl_image **dist_y)
 Apply the distortion correction.
double hawki_distortion_compute_rms (const cpl_table **ref_catalogues, const cpl_bivector *cat_offsets, const cpl_table *matching_sets, int ncats, hawki_distortion *distortion)
 This private function computes the rms, which is the objective function of the minimization algorithm.
int hawki_distortion_correct_alldetectors (cpl_image **ilist, const cpl_frame *frame_dist_x, const cpl_frame *frame_dist_y)
 Apply the distortion correction.
int hawki_distortion_correct_coords (const hawki_distortion *distortion, double x_pos, double y_pos, double *x_pos_distcorr, double *y_pos_distcorr)
 Apply the distortion correction to one detector position.
cpl_image * hawki_distortion_correct_detector (cpl_image *image, cpl_image *dist_x, cpl_image *dist_y)
 Apply the distortion correction to one chip.
void hawki_distortion_delete (hawki_distortion *distortion)
 Deallocates a hawki_distortion structure.
void hawki_distortion_get_flag_vars (double *x_val, double *y_val, int *pos_flag, int nvals, int *nvalid, double *var_x, double *var_y)
 Compute the standard deviation of two vectors, not using flagged values.
int hawki_distortion_get_size_x (const hawki_distortion *distortion)
 Gives the dimension in X of the distortion solution.
int hawki_distortion_get_size_y (const hawki_distortion *distortion)
 Gives the dimension in Y of the distortion solution.
hawki_distortion * hawki_distortion_grid_new (int detector_nx, int detector_ny, int grid_size)
 Allocate a new distortion solution.
int hawki_distortion_interpolate_distortion (const hawki_distortion *distortion, double x_pos, double y_pos, double *x_dist, double *y_dist)
 Interpolates the distortion solution at a given position.
int hawki_distortion_inverse_correct_coords (const hawki_distortion *distortion, double x_pos, double y_pos, double *x_pos_distinvcorr, double *y_pos_distinvcorr)
 Apply the inverse distortion correction to one detector position.
hawki_distortion * hawki_distortion_load (const cpl_frame *dist_x, const cpl_frame *dist_y, int idet)
 Loads the distortion solution for one detector.

Function Documentation

int hawki_distortion_apply_maps ( cpl_imagelist *  ilist,
cpl_image **  dist_x,
cpl_image **  dist_y 
)

Apply the distortion correction.

Parameters:
ilistthe input image list (chips 1 2 3 4)
distthe distortion file
Returns:
0 if everything is ok, -1 otherwise

Definition at line 617 of file hawki_distortion.c.

References hawki_distortion_correct_detector().

double hawki_distortion_compute_rms ( const cpl_table **  ref_catalogues,
const cpl_bivector *  cat_offsets,
const cpl_table *  matching_sets,
int  ncats,
hawki_distortion *  distortion 
)

This private function computes the rms, which is the objective function of the minimization algorithm.

See also:
hawki_distortion_compute_solution

Definition at line 930 of file hawki_distortion.c.

References hawki_distortion_get_flag_vars(), and hawki_distortion_interpolate_distortion().

int hawki_distortion_correct_alldetectors ( cpl_image **  ilist,
const cpl_frame *  frame_dist_x,
const cpl_frame *  frame_dist_y 
)

Apply the distortion correction.

Parameters:
ilistthe input image list (chips 1 2 3 4)
distthe distortion file
Returns:
0 if everything is ok, -1 otherwise

Definition at line 287 of file hawki_distortion.c.

References hawki_distortion_correct_detector(), hawki_distortion_delete(), and hawki_distortion_load().

int hawki_distortion_correct_coords ( const hawki_distortion *  distortion,
double  x_pos,
double  y_pos,
double *  x_pos_distcorr,
double *  y_pos_distcorr 
)

Apply the distortion correction to one detector position.

Parameters:
distortionthe distortion solution
x_posthe X position in detector that we want to correct.
y_posthe Y position in detector that we want to correct.
x_pos_distcorrthe X position in detector corrected from distortion
y_pos_distcorrthe Y position in detector corrected from distortion
Returns:
0 if everything is ok, -1 otherwise

This function will interpolate the distortion solution (given in variable distortion,

See also:
hawki_distortion_new)

Definition at line 423 of file hawki_distortion.c.

References hawki_distortion_interpolate_distortion().

cpl_image* hawki_distortion_correct_detector ( cpl_image *  image,
cpl_image *  dist_x,
cpl_image *  dist_y 
)

Apply the distortion correction to one chip.

Parameters:
imagethe input image
distthe distortion table
Returns:
0 if everything is ok, -1 otherwise

Definition at line 371 of file hawki_distortion.c.

Referenced by hawki_distortion_apply_maps(), and hawki_distortion_correct_alldetectors().

void hawki_distortion_delete ( hawki_distortion *  distortion)

Deallocates a hawki_distortion structure.

Parameters:
distortionThe distortion to allocate

Definition at line 163 of file hawki_distortion.c.

Referenced by hawki_distortion_correct_alldetectors().

void hawki_distortion_get_flag_vars ( double *  x_val,
double *  y_val,
int *  pos_flag,
int  nvals,
int *  nvalid,
double *  var_x,
double *  var_y 
)

Compute the standard deviation of two vectors, not using flagged values.

Returns:
The standard deviation

Definition at line 1198 of file hawki_distortion.c.

Referenced by hawki_distortion_compute_rms().

int hawki_distortion_get_size_x ( const hawki_distortion *  distortion)

Gives the dimension in X of the distortion solution.

Parameters:
distthe distortion solution
Returns:
The dimension in X

Definition at line 252 of file hawki_distortion.c.

int hawki_distortion_get_size_y ( const hawki_distortion *  distortion)

Gives the dimension in Y of the distortion solution.

Parameters:
distthe distortion solution
Returns:
The dimension in Y

Definition at line 269 of file hawki_distortion.c.

hawki_distortion* hawki_distortion_grid_new ( int  detector_nx,
int  detector_ny,
int  grid_size 
)

Allocate a new distortion solution.

Parameters:
detector_nxThe dimensions in X of a HAWK-I detector
detector_nxThe dimensions in Y of a HAWK-I detector
grid_sizeThe number of points in the distortion grid
Returns:
The allocated distortion if everything is ok , NULL otherwise

Definition at line 132 of file hawki_distortion.c.

int hawki_distortion_interpolate_distortion ( const hawki_distortion *  distortion,
double  x_pos,
double  y_pos,
double *  x_dist,
double *  y_dist 
)

Interpolates the distortion solution at a given position.

Parameters:
distortionthe distortion solution
x_posthe X position in detector that we want to correct.
y_posthe Y position in detector that we want to correct.
x_distthe distortion in X at position x_pos, y_pos
y_distthe distortion in Y at position x_pos, y_pos
Returns:
0 if everything is ok, -1 otherwise

This private function uses the four reference points found in distortion closer to x_pos, y_pos. Then it weights each point with the 3rd power of the distance to the target pixel and uses a linear interpolation.

If this function is used in a multithread environment with a CPL version not thread-safe, there is no risk as long as these two premises are hold: -The caller must check if distortion->dist_x and distortion->dist_y are not null before calling this function, because this is check by cpl_image_get_size_x and cpl_image_get. -The caller must check in advance that the mask has all the points valid, because cpl_image_get checks for the validity of the pixel in the mask, if it is not valid, enters the error handling of CPL, which is not thread-safe, at least before CPL 5.2. The rest of the calls are read-only, so it should be safe.

Definition at line 526 of file hawki_distortion.c.

Referenced by hawki_distortion_compute_rms(), hawki_distortion_correct_coords(), and hawki_distortion_inverse_correct_coords().

int hawki_distortion_inverse_correct_coords ( const hawki_distortion *  distortion,
double  x_pos,
double  y_pos,
double *  x_pos_distinvcorr,
double *  y_pos_distinvcorr 
)

Apply the inverse distortion correction to one detector position.

Parameters:
distortionthe distortion solution
x_posthe X position in detector that we want to decorrect.
y_posthe Y position in detector that we want to decorrect.
x_pos_distcorrthe X position in detector decorrected from distortion
y_pos_distcorrthe Y position in detector decorrected from distortion
Returns:
0 if everything is ok, -1 otherwise

This function is the inverse function of hawki_distortion_correct_coords. WARNING: Although this is the "inverse" of hawki_distortion_correct_coords, applying this function to positions delivered by hawki_distortion_correct_coords will not provide the original positions back. We are simply not using the same position to interpolate the distortion table.

Definition at line 467 of file hawki_distortion.c.

References hawki_distortion_interpolate_distortion().

hawki_distortion* hawki_distortion_load ( const cpl_frame *  dist_x,
const cpl_frame *  dist_y,
int  idet 
)

Loads the distortion solution for one detector.

Parameters:
dist_xthe image with distortion in X
dist_ythe image with distortion in Y
idetthe detector to read.
Returns:
The allocated distortion if everything is ok , NULL otherwise

Definition at line 182 of file hawki_distortion.c.

References hawki_get_ext_from_detector(), and hawki_load_frame_detector().

Referenced by hawki_distortion_correct_alldetectors().