CR2RE Pipeline Reference Manual 1.7.0
Cr2res_calib

Functions

hdrl_imagelist * cr2res_calib_imagelist (const hdrl_imagelist *in, int chip, int clean_bad, int subtract_nolight_rows, int subtract_interorder_column, int cosmics_corr, const cpl_frame *flat, const cpl_frame *dark, const cpl_frame *bpm, const cpl_frame *detlin, const cpl_vector *dits, const cpl_vector *ndits, const cpl_vector *ndsamples)
 The images calibration routine for a given chip on a list.
 
hdrl_image * cr2res_calib_image (const hdrl_image *in, int chip, int clean_bad, int subtract_nolight_rows, int subtract_interorder_column, int cosmics_corr, const cpl_frame *flat, const cpl_frame *dark, const cpl_frame *bpm, const cpl_frame *detlin, double dit, int ndit, int ndsamples)
 The images calibration routine for a given chip.
 
int cr2res_add_shotnoise (hdrl_image *in, double dit, int ndit, int ndsamples, int chip)
 Add shot- and read-noise to errors in HDRL-image.
 
int cr2res_calib_subtract_interorder_column (hdrl_image *in, const hdrl_image *flat, cpl_size degree)
 Remove background column by column.
 
void cr2res_calib_add_var (hdrl_image *ima, const cpl_image *var)
 Add a variance image to the error of an HDRL image.
 
cpl_image * cr2res_calib_flat_relerr2 (const hdrl_image *mflat)
 Squared relative error of a master flat, (sigma_F/F)^2.
 
void cr2res_calib_flat_var (hdrl_image *ima, const cpl_image *relerr2, double sign)
 Add or remove the flat-field variance term of an image.
 
int cr2res_calib_dark_var (hdrl_imagelist *list, const cpl_frame *master_dark_frame, int chip, const hdrl_image *mflat, const cpl_vector *dits, double sign)
 Add or remove the master dark variance of cr2res_calib_image()
 

Detailed Description

Function Documentation

◆ cr2res_add_shotnoise()

int cr2res_add_shotnoise ( hdrl_image * in,
double dit,
int ndit,
int ndsamples,
int chip )

Add shot- and read-noise to errors in HDRL-image.

Parameters
inthe input hdrl image, gets modified
ditthe DIT, used for the read-noise model
nditthe NDIT the frame is averaged over
ndsamplesthe up-the-ramp reads per DIT, or < 2 if unknown
chipthe chip (1 to CR2RES_NB_DETECTORS)
Returns
0 if ok, -1 in error case

sigma_out^2 = sigma_in^2 + alpha_n max(S,0) / (g NDIT) + RN^2 / (g^2 NDIT)

Definition at line 376 of file cr2res_calib.c.

References hdrl_image_get_error(), and hdrl_image_get_image_const().

Referenced by cr2res_calib_image().

◆ cr2res_calib_add_var()

void cr2res_calib_add_var ( hdrl_image * ima,
const cpl_image * var )

Add a variance image to the error of an HDRL image.

Parameters
imathe image, its error gets modified
varthe variance to add (may be negative to remove a term)

err = sqrt(max(err^2 + var, 0))

Definition at line 578 of file cr2res_calib.c.

References hdrl_image_get_error().

Referenced by cr2res_calib_dark_var(), and cr2res_calib_flat_var().

◆ cr2res_calib_dark_var()

int cr2res_calib_dark_var ( hdrl_imagelist * list,
const cpl_frame * master_dark_frame,
int chip,
const hdrl_image * mflat,
const cpl_vector * dits,
double sign )

Add or remove the master dark variance of cr2res_calib_image()

Parameters
listthe calibrated images, errors get modified
master_dark_framethe master dark used for the calibration
chipthe chip (1 to CR2RES_NB_DETECTORS)
mflatthe master flat used, or NULL
ditsthe DITs of the images in list
sign+1 to add, -1 to remove
Returns
0 if ok, -1 in error case

var += sign * (dit/dark_dit * sigma_D / F)^2

Definition at line 645 of file cr2res_calib.c.

References cr2res_calib_add_var(), cr2res_io_load_MASTER_DARK(), cr2res_pfits_get_dit(), hdrl_image_delete(), hdrl_image_get_error_const(), hdrl_image_get_image_const(), hdrl_imagelist_get(), and hdrl_imagelist_get_size().

◆ cr2res_calib_flat_relerr2()

cpl_image * cr2res_calib_flat_relerr2 ( const hdrl_image * mflat)

Squared relative error of a master flat, (sigma_F/F)^2.

Parameters
mflatthe master flat
Returns
the newly allocated image or NULL in error case

Definition at line 596 of file cr2res_calib.c.

References hdrl_image_get_error_const(), and hdrl_image_get_image_const().

◆ cr2res_calib_flat_var()

void cr2res_calib_flat_var ( hdrl_image * ima,
const cpl_image * relerr2,
double sign )

Add or remove the flat-field variance term of an image.

Parameters
imathe flat-fielded image, its error gets modified
relerr2(sigma_F/F)^2, see cr2res_calib_flat_relerr2()
sign+1 to add, -1 to remove

var += sign * data^2 * relerr2

Definition at line 618 of file cr2res_calib.c.

References cr2res_calib_add_var(), and hdrl_image_get_image_const().

◆ cr2res_calib_image()

hdrl_image * cr2res_calib_image ( const hdrl_image * in,
int chip,
int clean_bad,
int subtract_nolight_rows,
int subtract_interorder_column,
int cosmics_corr,
const cpl_frame * flat,
const cpl_frame * dark,
const cpl_frame * bpm,
const cpl_frame * detlin,
double dit,
int ndit,
int ndsamples )

The images calibration routine for a given chip.

Parameters
inthe input hdrl image
chipthe chip to calibrate (1 to CR2RES_NB_DETECTORS)
clean_badFlag to activate the cleaning of the bad pixels
subtract_nolight_rows
cosmics_corrFlag to correct for cosmics
flatthe flat frame or NULL
darkthe dark frame or NULL
bpmthe bpm frame or NULL
detlinthe detlin frame or NULL
ditthe DIT for the dark correction
nditthe NDIT of the image
ndsamplesthe up-the-ramp reads per DIT, or < 2 if unknown The flat, dark and bpm must have the same size as the input in. In the case of detlin, data are only taken in normal mode.
Returns
the newly allocated image or NULL in error case

Definition at line 158 of file cr2res_calib.c.

References cr2res_add_shotnoise(), cr2res_bpm_set_and_correct_image(), cr2res_calib_subtract_interorder_column(), cr2res_detlin_correct(), cr2res_io_load_DETLIN_COEFFS(), cr2res_io_load_MASTER_DARK(), cr2res_io_load_MASTER_FLAT(), cr2res_pfits_get_dit(), hdrl_image_delete(), hdrl_image_div_image(), hdrl_image_duplicate(), hdrl_image_get_image(), hdrl_image_get_mask(), hdrl_image_insert(), hdrl_image_mul_scalar(), hdrl_image_new(), hdrl_image_sub_image(), hdrl_imagelist_delete(), hdrl_lacosmic_edgedetect(), hdrl_lacosmic_parameter_create(), hdrl_lacosmic_parameter_verify(), and hdrl_parameter_delete().

Referenced by cr2res_calib_imagelist().

◆ cr2res_calib_imagelist()

hdrl_imagelist * cr2res_calib_imagelist ( const hdrl_imagelist * in,
int chip,
int clean_bad,
int subtract_nolight_rows,
int subtract_interorder_column,
int cosmics_corr,
const cpl_frame * flat,
const cpl_frame * dark,
const cpl_frame * bpm,
const cpl_frame * detlin,
const cpl_vector * dits,
const cpl_vector * ndits,
const cpl_vector * ndsamples )

The images calibration routine for a given chip on a list.

Parameters
inthe input hdrl image list
chipthe chip to calibrate (1 to CR2RES_NB_DETECTORS)
clean_badFlag to activate the cleaning of the bad pixels
subtract_nolight_rows
cosmics_corrFlag to correct for cosmics
flatthe flat frame or NULL
darkthe dark frame or NULL
bpmthe bpm frame or NULL
detlinthe detlin frame or NULL
ditsthe DITs of the images for the dark correction
nditsthe NDITs of the images, or NULL (NDIT=1)
ndsamplesthe NDSAMPLES of the images, or NULL (unknown) The flat, dark and bpm must have the same size as the input in. In the case of detlin, data are only taken in normal mode.
Returns
the newly allocated imagelist or NULL in error case

Definition at line 75 of file cr2res_calib.c.

References cr2res_calib_image(), hdrl_imagelist_delete(), hdrl_imagelist_get(), hdrl_imagelist_get_size(), hdrl_imagelist_new(), and hdrl_imagelist_set().

◆ cr2res_calib_subtract_interorder_column()

int cr2res_calib_subtract_interorder_column ( hdrl_image * in,
const hdrl_image * flat,
cpl_size degree )

Remove background column by column.

Parameters
inthe input hdrl image, gets modified
Returns
0 if ok, -1 in error case

Fits the background in each column, using a 1d polynomial with given degree to the out of order pixels.

Here the orders are defined by the flat-field.

Definition at line 452 of file cr2res_calib.c.

References cr2res_vector_get_mad(), hdrl_image_get_image(), hdrl_image_get_image_const(), hdrl_image_get_size_x(), and hdrl_image_get_size_y().

Referenced by cr2res_calib_image().