GRAVI Pipeline Reference Manual  1.2.3
Functions
Detector calibration

Functions

cpl_error_code gravi_fit_profile (cpl_vector *values_x0, cpl_vector *values_y0, cpl_vector *values_sigma, cpl_image *mean_img, int ref_x, int ref_y, int size_profile, const char *resolution)
 Fit the profile parameters in an image. More...
 
cpl_image * gravi_create_profile_image (cpl_image *mean_img, cpl_vector *values_x0, cpl_vector *values_y0, cpl_vector *values_sigma, cpl_size iy_min, cpl_size iy_max, const char *mode)
 Create the profile image from image and/or fitted params. More...
 
gravi_data * gravi_compute_dark (gravi_data *raw_data)
 Compute the DARK calibration map. More...
 
gravi_data * gravi_average_dark (gravi_data **data, cpl_size ndata)
 Average several DARK calibration map. More...
 
gravi_data * gravi_compute_profile (gravi_data **flats_data, gravi_data *dark_map, gravi_data *bad_map, int nflat, const cpl_parameterlist *params)
 Computes the spatial profile of each spectrum for optimal extraction purpose. More...
 
cpl_propertylist * gravi_compute_gain (gravi_data **flats_data, int nrawgain, gravi_data *dark_map)
 Compute mean detector gain. More...
 
gravi_data * gravi_compute_badpix (gravi_data *dark_map, gravi_data **flats_data, int nflat, const cpl_parameterlist *params)
 Identify the bad pixels in the DARK map and create the BAD map. More...
 
gravi_data * gravi_compute_biasmask (gravi_data *dark_map, gravi_data **flats_data, int nflat, const cpl_parameterlist *params)
 Create BIASMASK for SC from raw FLATs and raw DARK. More...
 
gravi_data * gravi_compute_piezotf (gravi_data *data, const cpl_parameterlist *params)
 Create piezo transfer function for Kalman Calibration & monitoring. More...
 

Detailed Description

This module contains the functions that are used to calibrate the detector. These functions characterize the pixels of the detectors. They are call by the recipe gravity_dark or gravity_p2vm.

Function Documentation

gravi_data* gravi_average_dark ( gravi_data **  data,
cpl_size  ndata 
)

Average several DARK calibration map.

Parameters
dataList of input DARK map
ndataNumber of DARK in the list
Returns
A newly allocated DARK calibration map
Exceptions
CPL_ERROR_NULL_INPUTno data as input

Definition at line 440 of file gravi_calib.c.

References gravi_data_duplicate(), and gravi_data_get_table().

gravi_data* gravi_compute_badpix ( gravi_data *  dark_map,
gravi_data **  flats_data,
int  nflat,
const cpl_parameterlist *  params 
)

Identify the bad pixels in the DARK map and create the BAD map.

Parameters
dark_mapThe input dark map calibration
flats_dataThe input raw flats (optional)
nflatThe number of input flats (shall be 4)
paramsInput parameter list with :
  • bad-dark-threshold : the rms factor for dark bad pixel threshold.
Returns
The BAD map with the detected bad pixels.
Exceptions
CPL_ERROR_NULL_INPUTinput data is missing
CPL_ERROR_ILLEGAL_INPUTThe number of input flats is not 4

Pixel with dark value or read-out-noise out of a specified range are declared as bad pixels.

If the flats_data are provided, they are collapsed together. Pixel with mean flat value lower than a horizontal median filtering are declared as bad pixels. Only pixel with a mean flat value higher than 100 adu are inspected. The mask of inspected pixels is saved in IMAGING_MASK_SC. This can be applied with normal or defocused FLATs. Still to be validated in LOW.

FIXME: in term of implementation, this function is weird as some of the computation are somehow done in-place after duplication of the data...

Definition at line 1760 of file gravi_calib.c.

References gravi_data_add_img(), gravi_data_add_table(), gravi_data_copy_ext(), gravi_data_get_cube(), gravi_data_get_table(), gravi_data_has_extension(), gravi_data_new(), and gravi_image_get_quantile().

gravi_data* gravi_compute_biasmask ( gravi_data *  dark_map,
gravi_data **  flats_data,
int  nflat,
const cpl_parameterlist *  params 
)

Create BIASMASK for SC from raw FLATs and raw DARK.

Parameters
dark_mapThe input dark map calibration
flats_dataThe input raw flats (optional)
nflatThe number of input flats (shall be 4)
paramsThe parameter list (no parameter used)
Returns
The BIASMASK map with the un-illuminated pixels.
Exceptions
CPL_ERROR_NULL_INPUTinput data is missing
CPL_ERROR_ILLEGAL_INPUTThe number of input flats is not 4

Pixel with values lower than 100 adu in the collapsed FLAT are flag with 1 in the BIASMASK, while illuminated pixels (>100adu) are flag with 0 in BIASMASK.

FIXME: improve the way we define the threshold. Use an 'ouverture' filtering maybe.

Definition at line 2121 of file gravi_calib.c.

References gravi_data_add_img(), gravi_data_copy_ext(), gravi_data_get_cube(), gravi_data_new(), and gravi_image_get_quantile().

gravi_data* gravi_compute_dark ( gravi_data *  raw_data)

Compute the DARK calibration map.

Parameters
raw_dataThe input raw dark
Returns
The output DARK calibration map
Exceptions
CPL_ERROR_NULL_INPUTno raw_data as input

The dark image of the SC is a saved as full image of the mean dark value and mean dark standard deviation (RON). The dark for the FT is saved into PIX array of the mean and dark standard deviation (RON). And the dark of the metrology is save into the METOLOGY table.

Definition at line 122 of file gravi_calib.c.

References gravi_array_wrap_image(), gravi_data_add_img(), gravi_data_add_table(), gravi_data_copy_ext(), gravi_data_get_cube(), gravi_data_get_plist(), gravi_data_get_table(), gravi_data_has_extension(), gravi_data_new(), gravi_imagelist_unwrap_images(), gravi_imagelist_wrap_column(), and gravi_pfits_add_check().

cpl_propertylist* gravi_compute_gain ( gravi_data **  flats_data,
int  nrawgain,
gravi_data *  dark_map 
)

Compute mean detector gain.

Parameters
flats_dataThe input raw FLAT data, one per beam
nrawgain4
dark_mapThe input DARK calibration map
Exceptions
CPL_ERROR_NULL_INPUTinput data is missing
CPL_ERROR_ILLEGAL_INPUTnot all shutter are opened

It returs a propertylist with the QC value of the mean SC and mean FT gain, in [ADU/e].

Definition at line 1505 of file gravi_calib.c.

References gravi_data_get_cube(), gravi_data_get_table(), gravi_data_has_extension(), gravi_image_from_column(), and gravi_imagelist_from_column().

gravi_data* gravi_compute_piezotf ( gravi_data *  data,
const cpl_parameterlist *  params 
)

Create piezo transfer function for Kalman Calibration & monitoring.

Parameters
dataThe input raw data
paramsThe parameter list (no parameter used)
Returns
The table of the OPDC data with the correct QC insrted
Exceptions
CPL_ERROR_NULL_INPUTinput data is missing

1- Read the piezo commands (in volts) from the OPDC table 2- Read the OPD measured by the fringe tracker (in radians) 3- Using an SVD inversion, get the 20 parameters of the transfer function: OPD(n)=a_i*piezo(n-1)+b_i*piezo(n-2)+c_i*piezo(n-3)+d_i*piezo(n-4)+e_i*piezo(n-5) where i is the piezo number (between 1 and 4), and a,b,c,d,e the 5 values of the autoregressive function of degree 5 (AR5). 4- Compute and store the QC parameters: residual errors, delay, gain, etc...

Definition at line 2226 of file gravi_calib.c.

References gravi_data_copy_ext(), gravi_data_get_table(), and gravi_data_new().

gravi_data* gravi_compute_profile ( gravi_data **  flats_data,
gravi_data *  dark_map,
gravi_data *  bad_map,
int  nflat,
const cpl_parameterlist *  params 
)

Computes the spatial profile of each spectrum for optimal extraction purpose.

Parameters
flats_dataThe FLAT_RAW datas
dark_mapThe DARK calibration map
bad_mapBAD calibration map
nflatThe number of FLAT file inputs
paramsInput parameter list with :
  • profile-width : Width of the detector window extracted around the default position of each spectrum, and on which the profile will be applied to perform the extraction.
  • force-badpix-to-zero : Force the badpixel to zero in profile.
  • profile-mode : Method to compute the extraction profile. PROFILE corresponds to the pixel intensities measured in the FLAT files (Gaussian like with FWHM of approx 1.5 pixel). This is the AUTO option for the Low and Med spectral resolution. GAUSS corresponds to a Gaussian fit of the (non-zero) pixel intensities measured in the FLAT files. BOX corresponds to a box-card of 6 pixels centered on the spectra measured in the FLAT files. This is the AUTO option for High spectral resolution.
Returns
The gravi_data with FLATs and PROFILE maps
Exceptions
CPL_ERROR_NULL_INPUTinput data is missing
CPL_ERROR_ILLEGAL_INPUTnot all shutter are opened or profile_width option not > 0 or missing table in the input data

For each region defined in the IMAGING_DETECTOR_SC table this function retrieves the profile of the spectrum passing by the reference point defined in the table IMAGING_DETECTOR_SC. The FT data have no profile.

Definition at line 976 of file gravi_calib.c.

References gravi_array_wrap_image(), gravi_create_profile_image(), gravi_data_add_img(), gravi_data_add_table(), gravi_data_copy_ext(), gravi_data_get_cube(), gravi_data_get_table(), gravi_data_has_extension(), gravi_data_new(), gravi_fit_profile(), gravi_image_extract_dimension(), gravi_image_from_column(), gravi_imagelist_unwrap_images(), gravi_imagelist_wrap_column(), gravi_region_get_tel(), and gravi_remove_badpixel_sc().

cpl_image * gravi_create_profile_image ( cpl_image *  mean_img,
cpl_vector *  values_x0,
cpl_vector *  values_y0,
cpl_vector *  values_sigma,
cpl_size  iy_min,
cpl_size  iy_max,
const char *  mode 
)

Create the profile image from image and/or fitted params.

Parameters
mean_imgInput image (nx,ny)
values_x0Input vector of spectral channels (0..nx-1)
values_y0Input vector of profile center in spatial direction
values_sigmaInput vector of profile width in spatial direction
iy_minMin coordinate where to fill the profile (0..ny-1)
iy_maxMax coordinate where to fill the profile (0..ny-1)
mode"BOX", "PROFILE", "GAUSS"
Returns
The image of the profile
Exceptions
CPL_ERROR_NULL_INPUTinput data is missing
CPL_ERROR_ILLEGAL_INPUTiy_min or iy_max are outside boundaries

The vectors values_x0, values_y0, values_sigma are first smoothed (duplicated) with a polynomial interpolation before being used. The image of the profile is built either from mean_img (LOW, MED) or is a boxcard of 5 pixels (HIGH).

Definition at line 797 of file gravi_calib.c.

Referenced by gravi_compute_profile().

cpl_error_code gravi_fit_profile ( cpl_vector *  values_x0,
cpl_vector *  values_y0,
cpl_vector *  values_sigma,
cpl_image *  mean_img,
int  ref_x,
int  ref_y,
int  size_profile,
const char *  resolution 
)

Fit the profile parameters in an image.

Parameters
values_x0Output vector of spectral channels (0..nx-1)
values_y0Output vector of profile center in spatial direction
values_sigmaOutput vector of profile width in spatial direction
mean_imgInput image (nx,ny)
ref_x,ref_yCoordinate of a known pixel inside the spectra
size_profileSpatial extend of the data to extract and fit
resolutionSpectral resolution (LOW, MED, HIGH)
Exceptions
CPL_ERROR_NULL_INPUTinput data is missing
CPL_ERROR_ILLEGAL_INPUTref_x or ref_y are outside boundaries

values_x0, values_y0, values_sigma are of size nx and unit [pixel] in the FITS convention (1..nx). The function starts to fit the profile toward the right from ref_x, then toward the left from ref_x. In resolution HIGH, the ref_y is updated at each spectral channel to follow the curvature when extracting the data.

Definition at line 519 of file gravi_calib.c.

Referenced by gravi_compute_profile().