GRAVI Pipeline Reference Manual  1.2.3
Functions
Preprocessing functions

Functions

cpl_table * gravi_table_ft_format (cpl_table *pix_table, cpl_table *skystd_table, cpl_table *skyavg_table, cpl_table *badft_table, int n_region, double gain)
 Extract FT spectrum from PIX column. More...
 
cpl_table * gravi_imglist_sc_collapse (cpl_table *profile_table, cpl_imagelist *raw_imglist, cpl_imagelist *rawVar_imglist, cpl_size startx)
 Extract the SC spectrum with profile. More...
 
cpl_error_code gravi_interpolate_spectrum_table (cpl_table *spectrum_table, cpl_table *wave_table, cpl_table **oiwave_tables, cpl_table *detector_table, cpl_table *specflat_table, const cpl_parameterlist *parlist, int type_data)
 Re-interpolate in-place a spectrum table. More...
 
int gravi_pixel_is_good (cpl_image *bad_img, int x, int y)
 Check if the pixel in the BADPIX map is a good pixel. More...
 
cpl_error_code gravi_remove_badpixel_sc (cpl_imagelist *imglist_sc, cpl_image *bad_img)
 Remove the badpixel of the SC. More...
 
gravi_data * gravi_extract_spectrum (gravi_data *raw_data, gravi_data *profile_map, gravi_data *dark_map, gravi_data *bad_map, gravi_data *sky_map, const cpl_parameterlist *parlist, enum gravi_detector_type det_type)
 Create the SPECTRUM gravi_data with extracted spectrum per region. More...
 
cpl_error_code gravi_subtract_met_dark (gravi_data *preproc_data, gravi_data *dark_map)
 Substract metrology dark. More...
 
cpl_error_code gravi_align_spectrum (gravi_data *spectrum_data, gravi_data *wave_map, gravi_data *p2vm_map, enum gravi_detector_type det_type, const cpl_parameterlist *parlist)
 Regrid the regions into a common wavelength (in-place) More...
 

Detailed Description

This module implements the preprocessing of the data, which is mainly to convert raw data into spectra. The main function gravi_extract_spectrum() is used at several place in the pipeline. And the steps of the preprocessing are description in the sections :

Function Documentation

cpl_error_code gravi_align_spectrum ( gravi_data *  spectrum_data,
gravi_data *  wave_map,
gravi_data *  p2vm_map,
enum gravi_detector_type  det_type,
const cpl_parameterlist *  parlist 
)

Regrid the regions into a common wavelength (in-place)

Parameters
spectrum_dataThe SPECTRUM data to regrid
wave_mapThe WAVE calibration map (current grid)
p2vm_mapor NULL The P2VM calibration map (target grid)
det_typeThe detector to align. If GRAVI_DET_SC, then only the science detector extensions will be processed. GRAVI_DET_FT will do the same for FT detector and GRAVI_DET_ALL will do it for both.
parlistInput parameter list (no parameter used).

It re-samples the spectral element according to the wavelength calibration. The SPECTRUM are re-interpolated into the OI_WAVELENGTH of this P2VM map. The target wavelength are the one of the OI_WAVELENGTH from the P2VM map (assumed to be the same for both polarisation!!)

This is done in-place to save enormous time, especially on FT.

Definition at line 1358 of file gravi_preproc.c.

References gravi_data_copy_ext(), gravi_data_get_oiwave_tables(), gravi_data_get_table(), gravi_interpolate_spectrum_table(), and gravi_spectrum_get_flux().

gravi_data* gravi_extract_spectrum ( gravi_data *  raw_data,
gravi_data *  profile_map,
gravi_data *  dark_map,
gravi_data *  bad_map,
gravi_data *  sky_map,
const cpl_parameterlist *  parlist,
enum gravi_detector_type  det_type 
)

Create the SPECTRUM gravi_data with extracted spectrum per region.

Parameters
raw_dataInput RAW gravi_data
profile_dataFLAT calibration map, with profiles
dark_dataDARK calibration map
bad_mapBAD calibration map
sky_mapSKY calibration map
parlistInput parameter list with :
  • ditshift-sc : Shift the time of SC DITs by an integer value to account for lost frames in exposure (issue on the instrument side, report to instrument team). The time of all DITs in exposure are increased by ditshift x PERIOD. ditshift can be 0, positive (system has lost one SC DIT), or negative (SC desynchronized).
det_typeThe detector to extract GRAVI_DET_SC, GRAVI_DET_FT or GRAVI_DET_ALL
Returns
The output gravi data contenning all the spectrums
Exceptions
CPL_ERROR_NULL_INPUTinput data is missing

It substrates the dark map. It converts data into photoelectrons using the gain map and identify the bad pixels for a correction. Finally it extracts the spectra with the calibrated spatial profile (for SC data)

Definition at line 590 of file gravi_preproc.c.

References gravi_data_add_table(), gravi_data_copy_ext(), gravi_data_get_cube(), gravi_data_get_plist(), gravi_data_get_table(), gravi_data_new(), gravi_imagelist_get_flux(), gravi_imglist_sc_collapse(), gravi_pfits_add_check(), gravi_pfits_get_ft_gain(), gravi_pfits_get_sc_gain(), gravi_pfits_get_startx(), gravi_pfits_get_time_sc(), gravi_remove_badpixel_sc(), gravi_spectrum_get_flux(), and gravi_table_ft_format().

cpl_table * gravi_imglist_sc_collapse ( cpl_table *  profile_table,
cpl_imagelist *  raw_imglist,
cpl_imagelist *  rawVar_imglist,
cpl_size  startx 
)

Extract the SC spectrum with profile.

Parameters
profile_tableInput table containing the profile images
raw_imagelistInput imagelist of raw data
rawVar_imagelistInput imagelist of variance
startxInput left location of profile in image

Extract all the spectrum using the spectrum extraction method based on the optimal extraction algorithm (Horne, 1986). This algorithm is based on the knowledge of a spatial profile. Note the profile may not be optimal (ex: boxcard) but shall ensure flux-conservation from its normalization.

The profile table shall contains DATA# columns, each containing the image of the profile of this region. The return tables contains DATA# column with flux, and DATAERR# columns with errors (sqrt(variance)).

startx is the left start column of the profile in images, in FITS convention (1 for the first pixel).

Definition at line 436 of file gravi_preproc.c.

References gravi_imagelist_unwrap_images(), and gravi_imagelist_wrap_column().

Referenced by gravi_extract_spectrum().

cpl_error_code gravi_interpolate_spectrum_table ( cpl_table *  spectrum_table,
cpl_table *  wave_table,
cpl_table **  oiwave_tables,
cpl_table *  detector_table,
cpl_table *  specflat_table,
const cpl_parameterlist *  parlist,
int  type_data 
)

Re-interpolate in-place a spectrum table.

Parameters
spectrum_tableThe table to manipulate
wave_tableThe input wave_table (one map per region)
oiwave_tablesThe output OI_WAVEs table (same for all regions)
detector_rableThe input IMAGING DETECTOR table
specflat_tableThe SPECTRUMFLAT, to allow unbiased effective wave
parlistInput parameter list (no parameter used)

All regions are re-interpolated into a common wavelength grid, defined by the oiwave_table (OIFITS format). The input wave_table contains the the initial wavelength grid of each region.

The wavelength bins in wave_table shall be monotonic incresing. All wavelength bins of oiwave_table shall be within the min/max of wave_table (not extrapolation is allowed).

Definition at line 920 of file gravi_preproc.c.

References gravi_region_get_pol().

Referenced by gravi_align_spectrum().

int gravi_pixel_is_good ( cpl_image *  bad_img,
int  x,
int  y 
)

Check if the pixel in the BADPIX map is a good pixel.

Parameters
bad_imgbadpix as img
xxpos
yypos
Returns
int 0/1

Definition at line 99 of file gravi_preproc.c.

cpl_error_code gravi_remove_badpixel_sc ( cpl_imagelist *  imglist_sc,
cpl_image *  bad_img 
)

Remove the badpixel of the SC.

Parameters
imglist_scinput data as imglist, remove inplace
bad_imgbadpixel image

The bad pixels of imglist_sc, identified by the map bad_img, are re-interpolated from neighboring values with a special care of the spatial / spectral directions since the spectra are almost 1D.

Definition at line 125 of file gravi_preproc.c.

Referenced by gravi_compute_profile(), and gravi_extract_spectrum().

cpl_error_code gravi_subtract_met_dark ( gravi_data *  preproc_data,
gravi_data *  dark_map 
)

Substract metrology dark.

Parameters
preproc_dataThe table to manipulate
dark_dataDARK calibration map

If Metrology dark is present, subtract DARK to METROLOGY data

Definition at line 860 of file gravi_preproc.c.

References gravi_data_get_table(), and gravi_data_has_extension().

cpl_table * gravi_table_ft_format ( cpl_table *  pix_table,
cpl_table *  skystd_table,
cpl_table *  skyavg_table,
cpl_table *  badft_table,
int  n_region,
double  gain 
)

Extract FT spectrum from PIX column.

Parameters
pix_tableInput raw data [adu]
skystd_tableInput SKY std data [adu]
skyavg_tableInput SKY avg data [adu]
n_regionNumber of regions to descramble
gainConversion gain in [ADU/e]
Returns
A cpl_table with TIME, DATA# and DATAERR#

The TIME column is duplicated in output. The pixels from the PIX column are descrambled into DATA# = (RAW-SKY)/gain DATAERR# = sqrt (max(DATA#,0) + (SKYSTD/gain)^2)

Definition at line 271 of file gravi_preproc.c.

Referenced by gravi_extract_spectrum().