CR2RE Pipeline Reference Manual 1.6.7
Functions
Extraction routines (Slit Decomposition,...)

Functions

int cr2res_extract_traces (const hdrl_image *img, const cpl_table *traces, const cpl_table *slit_func_in, const cpl_table *blaze_table_in, float blaze_norm, int reduce_order, int reduce_trace, cr2res_extr_method extr_method, int extr_height, int swath_width, int oversample, double smooth_slit, double smooth_spec, int niter, double kappa, double error_factor, int display, int disp_order_idx, int disp_trace, cpl_table **extracted, cpl_table **slit_func, hdrl_image **model_master)
 Extracts all the passed traces at once.
 
int cr2res_extract_sum_vert (const hdrl_image *hdrl_in, const cpl_table *trace_tab, int order, int trace_id, int height, cpl_vector **slit_func, cpl_bivector **spec, hdrl_image **model)
 Simple extraction function.
 
int cr2res_extract_median (const hdrl_image *hdrl_in, const cpl_table *trace_tab, int order, int trace_id, int height, cpl_vector **slit_func, cpl_bivector **spec, hdrl_image **model)
 Simple extraction function with the median.
 
int cr2res_extract_sum_tilt (const hdrl_image *hdrl_in, const cpl_table *trace_tab, int order, int trace_id, int height, cpl_vector **slit_func, cpl_bivector **spec, hdrl_image **model)
 Simple extraction function with curvature correction.
 
cpl_table * cr2res_extract_EXTRACT1D_create (cpl_bivector **spectrum, const cpl_table *trace_table)
 Create the extract 1D table to be saved.
 
cpl_table * cr2res_extract_SLITFUNC_create (cpl_vector **slit_func, const cpl_table *trace_table)
 Create the slit functions table to be saved.
 
int cr2res_extract_EXTRACT1D_get_spectrum (const cpl_table *tab, int order, int trace_nb, cpl_bivector **spec, cpl_bivector **spec_err)
 Get a Spectrum and its error from the EXTRACT_1D table.
 
int cr2res_extract_SLIT_FUNC_get_vector (const cpl_table *tab, int order, int trace_nb, cpl_vector **vec)
 Get a vector from the SLIT_FUNC table.
 
int cr2res_extract_slitdec_curved (const hdrl_image *img_hdrl, const cpl_table *trace_tab, const cpl_vector *slit_func_vec_in, int order, int trace_id, int height, int swath, int oversample, double smooth_slit, double smooth_spec, int niter, double kappa, double error_factor, cpl_vector **slit_func, cpl_bivector **spec, hdrl_image **model)
 Extract optimally (slit-decomposition) with polynomial slit.
 
int cr2res_extract2d_traces (const hdrl_image *img, const cpl_table *traces, int reduce_order, int reduce_trace, cpl_table **extracted)
 Extract2d all the passed traces at once.
 
int cr2res_extract2d_trace (const hdrl_image *in, const cpl_table *trace_tab, int order, int trace_id, int npoints, const cpl_image *wavemap, const cpl_image *slitmap, cpl_bivector **spectrum, cpl_bivector **position, cpl_vector **wavelength, cpl_vector **slit_fraction)
 Extraction2d function.
 
cpl_table * cr2res_extract_EXTRACT2D_create (cpl_bivector **spectrum, cpl_bivector **position, cpl_vector **wavelength, cpl_vector **slit_fraction, const cpl_table *trace_table)
 Create the extract 2D table to be saved.
 

Detailed Description

Function Documentation

◆ cr2res_extract2d_trace()

int cr2res_extract2d_trace ( const hdrl_image *  in,
const cpl_table *  trace_tab,
int  order,
int  trace_id,
int  npoints,
const cpl_image *  wavemap,
const cpl_image *  slitmap,
cpl_bivector **  spectrum,
cpl_bivector **  position,
cpl_vector **  wavelength,
cpl_vector **  slit_fraction 
)

Extraction2d function.

Parameters
img_infull detector image
trace_tabThe traces table
orderThe order to extract
trace_idThe Trace to extract
wavemapMap of the wavelength for each pixel
slitmapMap of the slit fraction for each pixel
spectrum[out] the spectrum and error
position[out] the x/y positions
wavelength[out] the wavelength values
slit_fraction[out] the slit_fraction values
Returns
0 if ok, -1 otherwise

Return the position, value, wavelength, and slitfraction of each pixel inside a trace

Definition at line 2180 of file cr2res_extract.c.

References cr2res_convert_array_to_poly(), cr2res_get_trace_table_index(), cr2res_polynomial_eval_vector(), hdrl_image_get_error_const(), and hdrl_image_get_image_const().

Referenced by cr2res_extract2d_traces().

◆ cr2res_extract2d_traces()

int cr2res_extract2d_traces ( const hdrl_image *  img,
const cpl_table *  traces,
int  reduce_order,
int  reduce_trace,
cpl_table **  extracted 
)

Extract2d all the passed traces at once.

Parameters
imgFull detector image
tracesThe traces table
reduce_orderThe order to extract (-1 for all)
reduce_traceThe Trace to extract (-1 for all)
extracted[out] the extracted spectra
Returns
0 if ok, -1 otherwise

This func takes a single image (containing many orders), and a traces table.

Definition at line 2056 of file cr2res_extract.c.

References cr2res_extract2d_trace(), cr2res_extract_EXTRACT2D_create(), and cr2res_slit_pos_image().

◆ cr2res_extract_EXTRACT1D_create()

cpl_table * cr2res_extract_EXTRACT1D_create ( cpl_bivector **  spectrum,
const cpl_table *  trace_table 
)

Create the extract 1D table to be saved.

Parameters
spectrumThe extracted spectra of the different orders
trace_tableThe trace table
Returns
the extract_1D table or NULL

Definition at line 1049 of file cr2res_extract.c.

References cr2res_dfs_SPEC_colname(), cr2res_dfs_SPEC_ERR_colname(), cr2res_dfs_WAVELENGTH_colname(), and cr2res_trace_get_wl().

Referenced by cr2res_extract_traces().

◆ cr2res_extract_EXTRACT1D_get_spectrum()

int cr2res_extract_EXTRACT1D_get_spectrum ( const cpl_table *  tab,
int  order,
int  trace_nb,
cpl_bivector **  spec,
cpl_bivector **  spec_err 
)

Get a Spectrum and its error from the EXTRACT_1D table.

Parameters
tabthe EXTRACT_1D table
orderthe order
trace_nbthe wished trace
spec[out] The wavelength/spectrum bivector
spec_err[out] The wavelength/spectrum error bivector
Returns
O if ok, -1 otherwise

Definition at line 1221 of file cr2res_extract.c.

References cr2res_dfs_SPEC_colname(), cr2res_dfs_SPEC_ERR_colname(), and cr2res_dfs_WAVELENGTH_colname().

Referenced by cr2res_extract_traces(), cr2res_photom_engine(), cr2res_qc_der_snr(), cr2res_qc_snr(), and cr2res_wave_apply().

◆ cr2res_extract_EXTRACT2D_create()

cpl_table * cr2res_extract_EXTRACT2D_create ( cpl_bivector **  spectrum,
cpl_bivector **  position,
cpl_vector **  wavelength,
cpl_vector **  slit_fraction,
const cpl_table *  trace_table 
)

Create the extract 2D table to be saved.

Parameters
spectrumvalue and error of the spectrum
positionx and y positions
wavelengthWL value
slit_fractionslit fraction
tracesTrace wave file used for extraction
Returns
the extract_2D table or NULL

Definition at line 2310 of file cr2res_extract.c.

References cr2res_dfs_POSITIONX_colname(), cr2res_dfs_POSITIONY_colname(), cr2res_dfs_SLIT_FRACTION_colname(), cr2res_dfs_SPEC_colname(), cr2res_dfs_SPEC_ERR_colname(), and cr2res_dfs_WAVELENGTH_colname().

Referenced by cr2res_extract2d_traces().

◆ cr2res_extract_median()

int cr2res_extract_median ( const hdrl_image *  hdrl_in,
const cpl_table *  trace_tab,
int  order,
int  trace_id,
int  height,
cpl_vector **  slit_func,
cpl_bivector **  spec,
hdrl_image **  model 
)

Simple extraction function with the median.

Parameters
img_infull detector image
trace_tabThe traces table
orderThe order to extract
trace_idThe Trace to extract
heightnumber of pix above and below mid-line or -1
slit_functhe returned slit function, normalized to sum=1
specthe returned spectrum, sum of rows
modelthe reconstructed image
Returns
0 if ok, -1 otherwise

This func takes a single image (containing many orders), a trace table, the order and trace numbers to extract (one each), and the extraction height. It uses the trace to shift the image columns by integer values, thereby straightening the order. The output spectra and slit function are then the collapsed (with the median) image in x and y, respectively. Also returned is the "model", i.e. an image reconstruction from the two extracted vectors.

Definition at line 655 of file cr2res_extract.c.

References cr2res_image_cut_rectify(), cr2res_trace_get_height(), cr2res_trace_get_ycen(), cr2res_vector_get_int(), hdrl_image_create(), hdrl_image_get_error_const(), and hdrl_image_get_image_const().

Referenced by cr2res_extract_traces().

◆ cr2res_extract_SLIT_FUNC_get_vector()

int cr2res_extract_SLIT_FUNC_get_vector ( const cpl_table *  tab,
int  order,
int  trace_nb,
cpl_vector **  vec 
)

Get a vector from the SLIT_FUNC table.

Parameters
tabthe SLIT_FUNC table
orderthe order
trace_nbthe wished trace
vec[out] The SLIT_FUNC vector
Returns
O if ok, -1 otherwise

Definition at line 1298 of file cr2res_extract.c.

References cr2res_dfs_SLIT_FUNC_colname().

Referenced by cr2res_extract_traces().

◆ cr2res_extract_slitdec_curved()

int cr2res_extract_slitdec_curved ( const hdrl_image *  img_hdrl,
const cpl_table *  trace_tab,
const cpl_vector *  slit_func_vec_in,
int  order,
int  trace_id,
int  height,
int  swath,
int  oversample,
double  smooth_slit,
double  smooth_spec,
int  niter,
double  kappa,
double  error_factor,
cpl_vector **  slit_func,
cpl_bivector **  spec,
hdrl_image **  model 
)

Extract optimally (slit-decomposition) with polynomial slit.

Parameters
img_infull detector image
trace_tabThe traces table
slit_func_vec_inThe input slit_func vector or NULL
orderThe order to extract
trace_idThe Trace to extract
heightnumber of pix above and below mid-line or -1
swathwidth per swath
oversamplefactor for oversampling
smooth_slitsmoothing along slit
smooth_specsmoothing along spectrum
error_factorerror_factor
slit_functhe returned slit function
specthe returned spectrum
modelthe returned model
Returns
0 if ok, -1 otherwise

This func takes a single image (containing many orders), and a single order definition in the form of central y-coords., plus the height. Swath width and oversampling are passed through.

The task of this function then is to

-cut out the relevant pixels of the order -shift im in y integers, so that nrows becomes minimal, adapt ycen accordingly -loop over swaths, in half-steps -derive a good starting guess for the spectrum, by median-filter average along slit, beware of cosmics -run cr2res_extract_slit_func_vert() -merge overlapping swath results by linear weights from swath-width to edge. -return re-assembled model image, slit-fu, spectrum, new mask. -calculate the errors and return them. This is done by comparing the variance of (im-model) to the poisson-statistics of the spectrum.

Definition at line 1370 of file cr2res_extract.c.

References cr2res_get_trace_wave_poly(), cr2res_image_cut_rectify(), cr2res_image_insert_rect(), cr2res_trace_get_height(), cr2res_trace_get_ycen(), cr2res_vector_get_rest(), hdrl_image_delete(), hdrl_image_get_error_const(), hdrl_image_get_image(), hdrl_image_get_image_const(), and hdrl_image_new().

Referenced by cr2res_extract_traces().

◆ cr2res_extract_SLITFUNC_create()

cpl_table * cr2res_extract_SLITFUNC_create ( cpl_vector **  slit_func,
const cpl_table *  trace_table 
)

Create the slit functions table to be saved.

Parameters
slit_funcThe slit functions of the different orders
trace_tableThe trace table
Returns
the slit_func table or NULL

Definition at line 1159 of file cr2res_extract.c.

References cr2res_dfs_SLIT_FUNC_colname().

Referenced by cr2res_extract_traces().

◆ cr2res_extract_sum_tilt()

int cr2res_extract_sum_tilt ( const hdrl_image *  hdrl_in,
const cpl_table *  trace_tab,
int  order,
int  trace_id,
int  height,
cpl_vector **  slit_func,
cpl_bivector **  spec,
hdrl_image **  model 
)

Simple extraction function with curvature correction.

Parameters
img_infull detector image
trace_tabThe traces table
orderThe order to extract
trace_idThe Trace to extract
heightnumber of pix above and below mid-line or -1
slit_functhe returned slit function, normalized to sum=1
specthe returned spectrum, sum of rows
modelthe reconstructed image
Returns
0 if ok, -1 otherwise

This func takes a single image (containing many orders), a trace table, the order and trace numbers to extract (one each), and the extraction height. It uses the trace to shift the image columns by integer values, thereby straightening the order. Additionally the image is corrected for the curvature by linear interpolation. The output spectra and slit function are then the collapsed image in x and y, respectively. Also returned is the "model", i.e. an image reconstruction from the two extracted vectors.

Definition at line 798 of file cr2res_extract.c.

References cr2res_get_trace_wave_poly(), cr2res_image_cut_rectify(), cr2res_trace_get_height(), cr2res_trace_get_ycen(), cr2res_vector_get_int(), hdrl_image_create(), hdrl_image_get_error_const(), and hdrl_image_get_image_const().

Referenced by cr2res_extract_traces().

◆ cr2res_extract_sum_vert()

int cr2res_extract_sum_vert ( const hdrl_image *  hdrl_in,
const cpl_table *  trace_tab,
int  order,
int  trace_id,
int  height,
cpl_vector **  slit_func,
cpl_bivector **  spec,
hdrl_image **  model 
)

Simple extraction function.

Parameters
img_infull detector image
trace_tabThe traces table
orderThe order to extract
trace_idThe Trace to extract
heightnumber of pix above and below mid-line or -1
slit_functhe returned slit function, normalized to sum=1
specthe returned spectrum, sum of rows
modelthe reconstructed image
Returns
0 if ok, -1 otherwise

This func takes a single image (containing many orders), a trace table, the order and trace numbers to extract (one each), and the extraction height. It uses the trace to shift the image columns by integer values, thereby straightening the order. The output spectra and slit function are then the collapsed image in x and y, respectively. Also returned is the "model", i.e. an image reconstruction from the two extracted vectors.

Definition at line 507 of file cr2res_extract.c.

References cr2res_image_cut_rectify(), cr2res_trace_get_height(), cr2res_trace_get_ycen(), cr2res_vector_get_int(), hdrl_image_create(), hdrl_image_get_error_const(), and hdrl_image_get_image_const().

Referenced by cr2res_extract_traces(), and cr2res_slit_curv_compute_order_trace().

◆ cr2res_extract_traces()

int cr2res_extract_traces ( const hdrl_image *  img,
const cpl_table *  traces,
const cpl_table *  slit_func_in,
const cpl_table *  blaze_table_in,
float  blaze_norm,
int  reduce_order,
int  reduce_trace,
cr2res_extr_method  extr_method,
int  extr_height,
int  swath_width,
int  oversample,
double  smooth_slit,
double  smooth_spec,
int  niter,
double  kappa,
double  error_factor,
int  display,
int  disp_order_idx,
int  disp_trace,
cpl_table **  extracted,
cpl_table **  slit_func,
hdrl_image **  model_master 
)

Extracts all the passed traces at once.

Parameters
imgFull detector image
tracesThe traces table
slit_func_inThe input slit_func or NULL
blaze_table_inThe input blaze or NULL
blaze_normThe blaze normalization or 0
reduce_orderThe order to extract (-1 for all)
reduce_traceThe Trace to extract (-1 for all)
extr_methodThe wished extraction method
extr_heightnumber of pix above and below mid-line or -1
swath_widthwidth per swath
oversamplefactor for oversampling
smooth_slitsmoothing along slit
smooth_specsmoothing along spectrum
error_factorFactor to get errors scale correctly
displayFlag to allow display
disp_order_idxThe order index to display
disp_traceThe trace number to display
extracted[out] the extracted spectra
slit_func[out] the slit functions
model_master[out] the model
Returns
0 if ok, -1 otherwise

This func takes a single image (containing many orders), and a traces table.

Definition at line 183 of file cr2res_extract.c.

References cr2res_extract_EXTRACT1D_create(), cr2res_extract_EXTRACT1D_get_spectrum(), cr2res_extract_median(), cr2res_extract_SLIT_FUNC_get_vector(), cr2res_extract_slitdec_curved(), cr2res_extract_SLITFUNC_create(), cr2res_extract_sum_tilt(), cr2res_extract_sum_vert(), hdrl_image_delete(), hdrl_image_duplicate(), hdrl_image_get_pixel(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), hdrl_image_mul_scalar(), and hdrl_image_set_pixel().