GRAVI Pipeline Reference Manual 1.8.0
Loading...
Searching...
No Matches
Macros | Functions
Spectral calibration

Macros

#define PLOT_WAVE_PHASE_VS_OPD   0
 
#define WAVE_TO_PLOT   5
 

Functions

cpl_table * gravi_opds_compute_guess (cpl_table *spectrumsc_table, cpl_table *ft_table, cpl_table *vismet_table, double dit_sc, double lbd_met)
 Compute a guess of the OPD modulation of SC from FT and MET.
 
cpl_table * gravi_opds_calibration (cpl_table *spectrum_table, cpl_table *detector_table, cpl_table *guess_table)
 Compute the mean opd of each baseline from spectrum.
 
cpl_error_code gravi_opds_correct_closures (cpl_table *phase_table, const char *name)
 Correct the input table to ensure constant closure phase.
 
cpl_vector * gravi_opds_fit_opdmet (cpl_table *ft_table, double lbd_met)
 Compute the absolute scaling coefficients of SC and FT OPDs.
 
cpl_table * gravi_wave_fibre (cpl_table *spectrum_table, cpl_table *detector_table, cpl_table *opd_table)
 Compute the wavelength of each channel for each 6 baselines.
 
cpl_table * gravi_wave_fit_2d (cpl_table *wavefibre_table, cpl_table *detector_table, gravi_data *wave_param, cpl_size fullstartx, int spatial_order, int spectral_order, double *rms_residuals)
 Compute the WAVE_DATA table (1 wavelength per region) from the WAVE_FIBRE table (1 wavelength per baseline)
 
cpl_table * gravi_wave_fit_individual (cpl_table *wave_individual_table, cpl_table *weight_individual_table, cpl_table *wave_fitted_table, cpl_table *opd_table, cpl_table *spectrum_table, cpl_table *detector_table, double n0, double n1, double n2)
 
cpl_error_code gravi_wave_correct_dispersion (cpl_table *wave_fibre, double n0, double n1, double n2)
 Correct the WAVE_FIBRE table from a harcoded dispersion model.
 
cpl_imagelist * gravi_wave_test_image (cpl_table *wavedata_table, cpl_table *wavefibre_table, cpl_table *profile_table, cpl_table *detector_table)
 Compute the (useless) TEST_WAVE table from the WAVE_FIBRE and the PROFILE maps.
 
cpl_table * gravi_compute_argon_wave (cpl_table *spectrum_table)
 Compute a WAVE calibration from the ARGON data (SC only)
 
cpl_error_code gravi_wave_compute_opds (gravi_data *spectrum_data, cpl_table *met_table, const cpl_parameterlist *parlist)
 Recover the OPD modulation from a spectrum_data and vismet_table.
 
cpl_error_code gravi_wave_correct_color (gravi_data *vis_data)
 Create a OI_WAVELENGTH_CORR table with color corrected wavelength.
 
cpl_error_code gravi_wave_qc (gravi_data *wave_map, gravi_data *profile_map)
 Compute the QC parameters of the WAVE product.
 
cpl_error_code gravi_compute_wave (gravi_data *wave_map, gravi_data *spectrum_data, int type_data, const cpl_parameterlist *parlist, gravi_data *wave_param)
 Create the WAVE calibration map.
 

Detailed Description

This module implements functions involved in the spectral calibration. The function gravi_compute_wave() do the calibration itself :

The wavelength of each spectral element is computed by comparing the measured phases of this spectral element with the realized OPD: OPDFT or OPDSC. The measured phases are computed from the A, B, C and D measurements with ellipse methode (see module Phase and OPD estimation with ellipse).

For each computed phase we know the expected OPD, OPDFT or OPD_SC from the metrology (gravi_compute_opds()). The slope of the phase versus OPD gives us the wavelength of the spectral element.

When all spectral element wavelengths are computed we have two sets of calibrated points, one for each polarization. On each of these two sets, a model of lambda versus position on the detector is fitted. And from this the wavelength of each spectral element of each spectrum is computed and put in the wavelength map.

Macro Definition Documentation

◆ PLOT_WAVE_PHASE_VS_OPD

#define PLOT_WAVE_PHASE_VS_OPD   0

Definition at line 78 of file gravi_wave.c.

◆ WAVE_TO_PLOT

#define WAVE_TO_PLOT   5

Definition at line 79 of file gravi_wave.c.

Function Documentation

◆ gravi_compute_argon_wave()

cpl_table * gravi_compute_argon_wave ( cpl_table *  spectrum_table)

Compute a WAVE calibration from the ARGON data (SC only)

Parameters
spectrum_tableThe input spectrum of each region
Returns
wave_table The output WAVE table of each region

The spectra of each region are adjusted independently with an argon lines and a slit model.

Definition at line 148 of file gravi_wave.c.

References cpl_msg_info(), CPLCHECK_NUL, FREE, GRAVI_DATA, gravi_msg_function_exit, gravi_msg_function_start, gravi_spectrum_get_nregion(), gravi_table_new_column_array(), wave_data, and wave_data_sc.

◆ gravi_compute_wave()

cpl_error_code gravi_compute_wave ( gravi_data wave_map,
gravi_data spectrum_data,
int  type_data,
const cpl_parameterlist *  parlist,
gravi_data wave_param 
)

Create the WAVE calibration map.

Parameters
wave_mapOutput wave_map, already allocated.
spectrum_dataInput spectrum_data
type_dataGRAVI_SC or GRAVI_FT
parlistInput parameter list with :
  • force-wave-ft-equal : Force the spatial order of the wavelength 2D fit for FT to zero (so all region share the same calibration). This is used to build the P2VM calibration of the TAC real-time code running on the instrument ifself.

The output WAVE map is filled with WAVE_FIBRE and WAVE_DATA tables, as well as QC parameters in the main header.

The input spectrum_data shall contain the IMAGING_DATA_FT, IMAGING_DETECTOR_FT and OPD_FT tables if type_data is GRAVI_FT (respectively SC). The latter table corresponds to the OPD modulation computed with gravi_wave_compute_opds.

The function first compute the WAVE_FIBRE table by fitting the modulation for each baseline and spectral channel.

Then the 6 baselines of WAVE_FIBRE are converted into a wavelength map for each 24 output, by the mean of a spatial fit over the detector.

Definition at line 2060 of file gravi_wave.c.

References cpl_msg_info(), cpl_propertylist_update_double(), CPLCHECK_MSG, gravi_data_add_table(), gravi_data_copy_ext(), gravi_data_get_header, gravi_data_get_imaging_detector, gravi_data_get_spectrum_data, gravi_data_get_spectrum_data_plist, gravi_data_get_table(), GRAVI_FT, GRAVI_IMAGING_DETECTOR_FT_EXT, GRAVI_IMAGING_DETECTOR_SC_EXT, gravi_msg_function_exit, gravi_msg_function_start, gravi_param_get_bool(), gravi_pfits_get_fullstartx(), gravi_pfits_get_spec_res(), GRAVI_SC, GRAVI_TYPE, gravi_wave_correct_dispersion(), GRAVI_WAVE_DATA_EXT, gravi_wave_fibre(), GRAVI_WAVE_FIBRE_EXT, gravi_wave_fit_2d(), gravi_wave_fit_individual(), QC_CHI2WAVE, QC_PHASECHI2, QC_RMS_RESIDUALS, and QC_RMS_RESIDUALS_UM.

Referenced by gravity_p2vm().

◆ gravi_opds_calibration()

cpl_table * gravi_opds_calibration ( cpl_table *  spectrum_table,
cpl_table *  detector_table,
cpl_table *  guess_table 
)

Compute the mean opd of each baseline from spectrum.

Parameters
spectrum_tableInput spectrum table
detector_tableCorresponding IMAGING_DETECTOR
guess_tableTable with a guess of OPD [m], or NULL

For each baseline, the routine compute the mean opd over the spectral channels and polarisation using the routine gravi_ellipse_meanopd_create.

The results are saved in the column OPD [m] of the output table, which has NDIT * NBASE rows, where NDIT in the size of the input spectrum table. The output table also contains a TIME columns in integer [us].

The guess_table shall be of size NDIT * NBASE and contains a column OPD [m], filled with expected opd modulation in the spectrum table. If provided, this tables is used to unwrap the computed phase before averaging the spectral channels.

Note that the routine uses a static wavelength calibration to compute the OPDs, hence the resulting value are to-a-scaling-factor.

Definition at line 698 of file gravi_wave.c.

References cpl_msg_info(), CPLCHECK_NUL, FREE, FREELOOP, gravi_ellipse_meanopd_create(), gravi_msg_function_exit, gravi_msg_function_start, gravi_spectrum_get_npol, gravi_spectrum_get_nwave(), gravi_table_new_column(), and USE_LINEAR_ELLIPSE.

Referenced by gravi_wave_compute_opds().

◆ gravi_opds_compute_guess()

cpl_table * gravi_opds_compute_guess ( cpl_table *  spectrumsc_table,
cpl_table *  ft_table,
cpl_table *  vismet_table,
double  dit_sc,
double  lbd_met 
)

Compute a guess of the OPD modulation of SC from FT and MET.

Parameters
spectrumsc_tableInput SC spectrum table (for DITs)
ft_tableThe opd from FT
vismet_tableThe retuced MET signal

For each baseline and each row of spectrum, the routine compute

guess = OPD_FT - LBD_MET * PHASE_MET / 2pi [m]

The result is saved in the column OPD of the output table, which has NDIT_SC * NBASE rows. Note that the FT and FT are averaged over each SC DIT.

All tables shall contain a TIME columns in integer [us]. The ft_table shall have a OPD column [m] and be of size NDIT_FT * NBASE. The vismet_table shall have a PHASE_FC column [rad] and be of size NDIT_MET * NTEL.

FIXME: this routine can be replaced by manipulation of columns created with the gravi_signal package.

Definition at line 566 of file gravi_wave.c.

References cpl_msg_info(), CPLCHECK_NUL, GRAVI_BASE_TEL, gravi_msg_function_exit, gravi_msg_function_start, gravi_table_add_scalar(), gravi_table_get_column_mean(), gravi_table_new_column(), and ntel.

Referenced by gravi_wave_compute_opds().

◆ gravi_opds_correct_closures()

cpl_error_code gravi_opds_correct_closures ( cpl_table *  phase_table,
const char *  name 
)

Correct the input table to ensure constant closure phase.

Parameters
phase_tableThe table to be corrected in-place
nameThe column to correct (PHASE or OPD)

The raw broad-band phase from gravi_opds_calibration doesn't necessarely form a closing system (constant closure phase versus modulation), if the the effective broad-band wavelength of the baselines are differents. For instance because of detector distortion. This routine determines the scaling coefficients and reconstructs a closing system.

The routine find the 4 k and 5 coefficients solving the following linear system of closure phase:

B0 + B3 - B1  =  f0 B0 + f3 B3 - f1 B1 + k0
B0 + B4 - B2  =  f0 B0 + f4 B3 - f2 B2 + k1
B1 + B5 - B2  =  f1 B1             - f2 B2 + k2
B3 + B5 - B4  =  f3 B3             - f4 B4 + k3

Then it re-scales the first 5 baselines: B0' = (1-f0).B0 B1' = (1-f1).B1 B2' = (1-f2).B2 B3' = (1-f3).B3 B4' = (1-f4).B4

The 'name' column shall be a scalar colum, and have NDIT * NBASE rows.

Definition at line 353 of file gravi_wave.c.

References cpl_msg_info(), CPLCHECK_MSG, FREE, GRAVI_CLO_BASE, gravi_msg_function_exit, and gravi_msg_function_start.

Referenced by gravi_wave_compute_opds().

◆ gravi_opds_fit_opdmet()

cpl_vector * gravi_opds_fit_opdmet ( cpl_table *  ft_table,
double  lbd_met 
)

Compute the absolute scaling coefficients of SC and FT OPDs.

Parameters
ft_tableInput table at the sampling rate of FT
Returns
coef A new cpl_vector with the coeficients and the chi2 of the fit {a,b,chi2} in [m]

The routine determine the absolute scaling of SC (a) and FT (b) OPDs by solving the linear system:

2pi./LBD_MET * PHASE_MET_ijt = a.OPD_SC_ijt - b.OPD_FT_ijt + c_ij

The routine discards samples that are outside the SC DITs (defined with OPD_SC==0). Then it solves the systems and compute residuals.

Since the routine uses a single coefficient (a) for all 6 baselines, the 6 corresponding OPDs shall form a system with constant closure phase versus modulation.

The ft_table shall contain a column OPD with the FT OPDs, a column OPD_SC with the corresponding SC OPD (correctly resampled), and a column PHASE_MET_FC with the correscponding FC phase (also resampled). It shall have NDIT_SC * NBASE rows.

Definition at line 458 of file gravi_wave.c.

References cpl_msg_info(), CPLCHECK_NUL, FREE, GRAVI_FT, gravi_msg_function_exit, gravi_msg_function_start, and GRAVI_SC.

Referenced by gravi_wave_compute_opds().

◆ gravi_wave_compute_opds()

cpl_error_code gravi_wave_compute_opds ( gravi_data spectrum_data,
cpl_table *  met_table,
const cpl_parameterlist *  parlist 
)

Recover the OPD modulation from a spectrum_data and vismet_table.

Parameters
spectrum_tableThe input spectrum, with region DATA#
met_tableThe corresponding METROLOGY table.
plistThe plist where to dump QC parameters
Returns
Two allocated table containing the OPDs of SC and FT [m]

The routine first reduces the METROLOGY table into metrology OPDs. Then it computes the mean opd of each baseline for the FT, averaged over spectral channels and polarisation, by fitting the ellipses.

It uses these OPDs from MET and FT to guess the opd modulation on the SC, in order to unwrap it properly. Then it computes the mean OPD of each baseline of the SC (averaged over spectral channels), using this guess, and fitting the ellipses.

The routine then solves the linear system:

\f$\lambda_{MET}.OPD_{MET}  / 2\pi = a.OPD_{SC} - b.OPD_{FT} + c\f$

in order to determine the true scaling of the SC (a) and of the SC (b). A special care is taken to only consider the samples inside the SC DIT, to have a proper phase relation.

The return tables are of size NDIT_SC * NBASE, and NDIT_SC * NBASE, where NDIT in the size of the input spectrum tables. They contain a TIME column [us] and a OPD table [m]. These tables are added to the input spectrum_data with EXTNAME OPD_FT and OPD_SC.

Definition at line 822 of file gravi_wave.c.

References cpl_msg_info(), cpl_propertylist_update_double(), CPLCHECK_MSG, FREE, gravi_data_add_table(), gravi_data_get_header, gravi_data_get_imaging_detector, gravi_data_get_spectrum_data, GRAVI_FT, gravi_metrology_create(), gravi_metrology_drs(), gravi_metrology_tac(), gravi_msg_function_exit, gravi_msg_function_start, GRAVI_OI_VIS_MET_EXT, gravi_opds_calibration(), gravi_opds_compute_guess(), gravi_opds_correct_closures(), gravi_opds_fit_opdmet(), gravi_pfits_add_check(), gravi_pfits_get_dit_sc(), gravi_pfits_get_met_wavelength_mean(), GRAVI_SC, gravi_vis_create_met_ft(), gravi_vis_create_opdsc_ft(), OPD_COEFF_SIGN, and QC_PHASECHI2.

Referenced by gravity_p2vm().

◆ gravi_wave_correct_color()

cpl_error_code gravi_wave_correct_color ( gravi_data vis_data)

Create a OI_WAVELENGTH_CORR table with color corrected wavelength.

Parameters
vis_dataInput gravi_data, modified inplace

Definition at line 1755 of file gravi_wave.c.

References CPLCHECK_MSG, gravi_data_add_table(), gravi_data_get_header, gravi_data_get_oi_wave, gravi_data_get_oi_wave_plist, gravi_msg_function_exit, gravi_msg_function_start, and gravi_pfits_get_pola_num().

Referenced by gravity_vis().

◆ gravi_wave_correct_dispersion()

cpl_error_code gravi_wave_correct_dispersion ( cpl_table *  wave_fibre,
double  n0,
double  n1,
double  n2 
)

Correct the WAVE_FIBRE table from a harcoded dispersion model.

Parameters
wave_fibreInput table, modified inplace
n0,n1,n2Dispersion parameter

Definition at line 1709 of file gravi_wave.c.

References CPLCHECK_MSG, GRAVI_BASE_NAME, gravi_msg_function_exit, gravi_msg_function_start, GRAVI_POLAR, and LAMBDA_MET.

Referenced by gravi_compute_wave().

◆ gravi_wave_fibre()

cpl_table * gravi_wave_fibre ( cpl_table *  spectrum_table,
cpl_table *  detector_table,
cpl_table *  opd_table 
)

Compute the wavelength of each channel for each 6 baselines.

Parameters
spectrum_tableThe input spectrum, with region DATA#
detector_tableThe corresponding detector table
opd_tableThe corresponding OPD modulation [m]
Returns
A allocated table WAVE_FIBRE [m]

For each baseline/polar, the phase of each channel is computed by fitting the ellipse, using the opd_table modulation to unwrap the results. Then the effective wavelength of this channel is computed by fitting the relation:

OPD = lbd . PHASE / 2pi

The results are stored into 6 (or 12) columns of the form DATA_12_S in the returned table.

The opd_table shall be of size nrow * nbase, where nrow is the size of the spectrum_table (number of DITs). It shall contains a column OPD [m], filled with the opd modulation in the spectrum table.

Definition at line 991 of file gravi_wave.c.

References cpl_msg_info(), CPLCHECK_NUL, FREE, GRAVI_BASE_NAME, gravi_compute_envelope(), GRAVI_DATA, gravi_ellipse_phase_create(), gravi_get_region(), gravi_msg_function_exit, gravi_msg_function_start, GRAVI_POLAR, gravi_region_get_base_sign(), gravi_table_get_vector(), gravi_vector_unwrap_with_guess(), PLOT_WAVE_PHASE_VS_OPD, and WAVE_TO_PLOT.

Referenced by gravi_compute_wave().

◆ gravi_wave_fit_2d()

cpl_table * gravi_wave_fit_2d ( cpl_table *  wavefibre_table,
cpl_table *  detector_table,
gravi_data wave_param,
cpl_size  fullstartx,
int  spatial_order,
int  spectral_order,
double *  rms_residuals 
)

Compute the WAVE_DATA table (1 wavelength per region) from the WAVE_FIBRE table (1 wavelength per baseline)

Parameters
wavefibre_tableInput WAVE_FIBRE table
detector_tableInput IMAGING_DETECTOR table
fullstartxFULLSTARTX of the spectrum
Returns
The WAVE_DATA table, with interpolated DATA# column.

The input wavefibre_table shall have columns of form BASE_12_S. The rountine interpolate the wavelegength of these baseline as a 2d map on pixel space, using the pixel position of each baseline from detector_table. Then this polynomial fit it evaluated from each region individually in order to build the DATA# column of the wave_data output table.

Definition at line 1182 of file gravi_wave.c.

References cpl_msg_info(), CPLCHECK_NUL, FREE, FREELOOP, GRAVI_BASE_NAME, GRAVI_DATA, gravi_data_get_plist(), gravi_get_region(), GRAVI_LBD_FTSC, gravi_msg_function_exit, gravi_msg_function_start, gravi_pfits_get_double_default(), GRAVI_POLAR, GRAVI_PRIMARY_HDR_EXT, and gravi_region_get_pol().

Referenced by gravi_compute_wave().

◆ gravi_wave_fit_individual()

cpl_table * gravi_wave_fit_individual ( cpl_table *  wave_individual_table,
cpl_table *  weight_individual_table,
cpl_table *  wave_fitted_table,
cpl_table *  opd_table,
cpl_table *  spectrum_table,
cpl_table *  detector_table,
double  n0,
double  n1,
double  n2 
)

◆ gravi_wave_qc()

cpl_error_code gravi_wave_qc ( gravi_data wave_map,
gravi_data profile_map 
)

Compute the QC parameters of the WAVE product.

Parameters
wave_mapInput/output gravi_data update
profile_mapInput profile calibration

Compute the QC parameters from the WAVE_DATA of each combiner (SC/FT). Also computes a uselss image of the detector with the wavelength... for visual.

Definition at line 1913 of file gravi_wave.c.

References cpl_msg_info(), cpl_propertylist_update_double(), CPLCHECK_MSG, GRAVI_DATA, gravi_data_add_cube(), gravi_data_get_header, gravi_data_get_imaging_detector, gravi_data_get_plist(), gravi_data_get_table(), gravi_data_get_wave_data, gravi_data_get_wave_data_plist, gravi_data_get_wave_fibre, gravi_msg_function_exit, gravi_msg_function_start, gravi_pfits_get_fullstartx(), GRAVI_PROFILE_DATA_EXT, GRAVI_SC, GRAVI_TYPE, gravi_wave_test_image(), plist, QC_MAXWAVE, QC_MAXWAVE_UM, QC_MINWAVE, QC_MINWAVE_UM, and wave_data.

Referenced by gravity_p2vm().

◆ gravi_wave_test_image()

cpl_imagelist * gravi_wave_test_image ( cpl_table *  wavedata_table,
cpl_table *  wavefibre_table,
cpl_table *  profile_table,
cpl_table *  detector_table 
)

Compute the (useless) TEST_WAVE table from the WAVE_FIBRE and the PROFILE maps.

Parameters
wavedata_tableInput WAVE_DATA table (with DATA# columns)
wavefibre_tableInput WAVE_FIBRE table (with BASE_# columns)
profile_tableInput profile table
detector_tableInput IMAGING_DETECTOR table
Returns
A allocated imagelist with the test images.

Definition at line 1808 of file gravi_wave.c.

References CPLCHECK_NUL, GRAVI_BASE_NAME, GRAVI_DATA, gravi_imagelist_unwrap_images(), gravi_imagelist_wrap_column(), gravi_msg_function_exit, gravi_msg_function_start, GRAVI_POLAR, gravi_region_get_base(), and gravi_region_get_pol().

Referenced by gravi_wave_qc().