GRAVI Pipeline Reference Manual 1.9.0
Loading...
Searching...
No Matches
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, const cpl_parameterlist *parlist)
 Extract FT spectrum from PIX column.
 
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.
 
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, int type_data)
 Re-interpolate in-place a spectrum table.
 
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.
 
cpl_error_code gravi_remove_badpixel_sc (cpl_imagelist *imglist_sc, cpl_image *bad_img)
 Remove the badpixel of the SC.
 
gravi_datagravi_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.
 
cpl_error_code gravi_subtract_met_dark (gravi_data *preproc_data, gravi_data *dark_map)
 Substract metrology dark.
 
cpl_error_code gravi_align_spectrum (gravi_data *spectrum_data, gravi_data *wave_map, gravi_data *p2vm_map, enum gravi_detector_type det_type)
 Regrid the regions into a common wavelength (in-place)
 

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

◆ gravi_align_spectrum()

cpl_error_code gravi_align_spectrum ( gravi_data spectrum_data,
gravi_data wave_map,
gravi_data p2vm_map,
enum gravi_detector_type  det_type 
)

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 1510 of file gravi_preproc.c.

References cpl_msg_info(), cpl_propertylist_update_double(), CPLCHECK_MSG, FREE, gravi_data_copy_ext(), gravi_data_get_header, gravi_data_get_imaging_detector, gravi_data_get_oiwave_tables(), gravi_data_get_spectrum_data, gravi_data_get_spectrum_data_plist, gravi_data_get_table(), gravi_data_get_wave_data, gravi_data_has_spectrum, GRAVI_DET_ALL, GRAVI_DET_FT, GRAVI_DET_SC, gravi_interpolate_spectrum_table(), gravi_msg_function_exit, gravi_msg_function_start, GRAVI_OI_WAVELENGTH_EXT, GRAVI_SC, gravi_spectrum_get_flux(), gravi_spectrum_get_npol, gravi_spectrum_get_nwave(), GRAVI_SPECTRUMFLAT_DATA_SC_EXT, GRAVI_TYPE, PROFILE_FULLSTARTX, PROFILE_NX, and PROFILE_STARTX.

Referenced by gravity_disp(), gravity_p2vm(), gravity_vis(), and gravity_wavelamp().

◆ gravi_extract_spectrum()

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 612 of file gravi_preproc.c.

References cpl_image_delete(), cpl_msg_info(), cpl_propertylist_update_double(), CPLCHECK_NUL, FREE, GRAVI_DATA, gravi_data_add_table(), gravi_data_copy_ext(), gravi_data_get_cube(), gravi_data_get_header, gravi_data_get_img, gravi_data_get_plist(), gravi_data_get_table(), gravi_data_has_detector, gravi_data_is_internal, gravi_data_new(), GRAVI_DATAERR, GRAVI_DET_ALL, GRAVI_DET_FT, GRAVI_DET_SC, GRAVI_FT, gravi_imagelist_get_flux(), GRAVI_IMAGING_DATA_FT_EXT, GRAVI_IMAGING_DATA_SC_EXT, GRAVI_IMAGING_DETECTOR_FT_EXT, GRAVI_IMAGING_DETECTOR_SC_EXT, GRAVI_IMAGING_ERR_FT_EXT, GRAVI_IMAGING_ERR_SC_EXT, gravi_imglist_sc_collapse(), gravi_msg_function_exit, gravi_msg_function_start, gravi_msg_warning(), gravi_param_get_int_default(), gravi_pfits_add_check(), gravi_pfits_get_dit_sc(), gravi_pfits_get_ft_gain(), gravi_pfits_get_pola_mode(), gravi_pfits_get_sc_gain(), gravi_pfits_get_spec_res(), gravi_pfits_get_startx(), gravi_pfits_get_time_sc(), GRAVI_PROFILE_DATA_EXT, gravi_remove_badpixel_sc(), GRAVI_SC, GRAVI_SPECTRUM_DATA_FT_EXT, GRAVI_SPECTRUM_DATA_SC_EXT, gravi_spectrum_get_flux(), gravi_spectrum_get_nwave(), GRAVI_SPECTRUMFLAT_DATA_SC_EXT, gravi_table_ft_format(), PROFILE_FULLSTARTX, PROFILE_NX, and PROFILE_STARTX.

Referenced by gravi_fit_argon(), gravity_disp(), gravity_p2vm(), gravity_vis(), and gravity_wavelamp().

◆ gravi_imglist_sc_collapse()

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 458 of file gravi_preproc.c.

References cpl_image_delete(), cpl_image_multiply(), cpl_msg_debug(), CPLCHECK_NUL, FREE, GRAVI_DATA, GRAVI_DATAERR, gravi_imagelist_unwrap_images(), gravi_imagelist_wrap_column(), gravi_msg_function_exit, gravi_msg_function_start, and gravi_spectrum_get_nregion().

Referenced by gravi_extract_spectrum().

◆ gravi_interpolate_spectrum_table()

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,
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 1038 of file gravi_preproc.c.

References cpl_msg_debug(), cpl_msg_info(), CPLCHECK_MSG, FREE, GRAVI_DATA, GRAVI_DATAERR, gravi_msg_function_exit, gravi_msg_function_start, gravi_region_get_pol(), GRAVI_SC, gravi_spectrum_get_npol, gravi_spectrum_get_nregion(), gravi_spectrum_get_nwave(), and gravi_table_get_value.

Referenced by gravi_align_spectrum().

◆ gravi_pixel_is_good()

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 98 of file gravi_preproc.c.

References BADPIX_DARK, BADPIX_FLAT, and BADPIX_RMS.

◆ gravi_remove_badpixel_sc()

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 124 of file gravi_preproc.c.

References CPLCHECK_MSG, gravi_msg_function_exit, and gravi_msg_function_start.

Referenced by gravi_compute_profile(), and gravi_extract_spectrum().

◆ gravi_subtract_met_dark()

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 978 of file gravi_preproc.c.

References cpl_msg_info(), CPLCHECK_MSG, gravi_data_get_table(), gravi_data_has_extension(), GRAVI_METROLOGY_EXT, gravi_msg_function_exit, and gravi_msg_function_start.

Referenced by gravity_vis().

◆ gravi_table_ft_format()

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,
const cpl_parameterlist *  parlist 
)

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 283 of file gravi_preproc.c.

References cpl_msg_info(), CPLCHECK_NUL, FREE, GRAVI_DATA, GRAVI_DATAERR, gravi_msg_function_exit, gravi_msg_function_start, gravi_param_get_bool(), and gravi_table_get_value.

Referenced by gravi_extract_spectrum().