ERIS Pipeline Reference Manual 1.8.15
Functions
Utilities for NIX LSS calibration

Functions

cpl_error_code enlu_divide_slit_response (located_imagelist *jitters)
 Divide LSS 2d-spectra by the slit response.
 
cpl_error_code enlu_divide_slit_response_worker (hdrl_image *himage_2d, cpl_image *response_1d)
 Worker function to divide a 2d image by a 1d response.
 
cpl_matrix * enlu_linepos_2d (const hdrl_image *spectrum2d, const cpl_size slice_index, const cpl_vector *guess_pos)
 Fit the line peaks of a wave calibration spectrum.
 
double enlu_linepos_1d (const cpl_vector *spectrum1d, const double guess_pos, const cpl_size half_width)
 Fit line peak.
 
cpl_error_code enlu_trace_save (const char *pro_catg, const hdrl_image *image, const cpl_image *confidence, const cpl_size ntraces, const cpl_polynomial *traces[ntraces], const cpl_size nspectra, const cpl_vector *spectra[nspectra], const cpl_size nlines, const cpl_polynomial *lines[nlines], cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *filename, const char *recipe_name)
 Save a trace result.
 
cpl_polynomial * enlu_warp_poly_load_from_table (const cpl_table *table)
 Load a LSS warp polynomial from a cpl_table.
 
cpl_table * enlu_warp_poly_save_to_table (const cpl_polynomial *poly)
 Save an LSS polynomial to a cpl_table.
 

Detailed Description

Function Documentation

◆ enlu_divide_slit_response()

cpl_error_code enlu_divide_slit_response ( located_imagelist *  jitters)

Divide LSS 2d-spectra by the slit response.

Parameters
jittersThe list of LSS 2d-spectra to be processed.
Returns
CPL_ERROR_NONE if all goes well, otherwise an error code.

The routine iterates throug the jitter images to be processed. For each, it calculates the response value along the slit by collapsing the background spectrum in the dispersion direction (usually all jitters will have the same background but possibly not always). The routine normalises the slit response and then divides the jitter image and error arrays by it. This works because all slit offsets should see the same sky background spectrum.

Definition at line 63 of file eris_nix_lss_utils.c.

References enlu_divide_slit_response_worker(), and hdrl_image_get_image().

◆ enlu_divide_slit_response_worker()

cpl_error_code enlu_divide_slit_response_worker ( hdrl_image *  himage_2d,
cpl_image *  response_1d 
)

Worker function to divide a 2d image by a 1d response.

Parameters
hdrl_imageThe image whose x-vectors are to be divided.
cpl_imageThe 1-d image to be the divisor.
Returns
CPL_ERROR_NONE if all goes well, otherwise an error code

Definition at line 157 of file eris_nix_lss_utils.c.

References hdrl_image_get_pixel(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), hdrl_image_reject(), and hdrl_image_set_pixel().

Referenced by enlu_divide_slit_response().

◆ enlu_linepos_1d()

double enlu_linepos_1d ( const cpl_vector *  spectrum1d,
const double  guess_pos,
const cpl_size  half_width 
)

Fit line peak.

Returns
The line peak position.

This routine is given a 1d spectrum with a guess at the position of a line in it. A section between +2 and -2 pixels of the guess position is cut out of the spectrum, and a parabola fitted to the flux values. The position of the parabola maximum is returned as the fitted line position.

The routine will return NaN if entered with the CPL error code set. The routine will return NaN, and set CPL error code to CPL_ERROR_NULL_INPUT if called with spectrum1d NULL. The routine will return NaN if any of the spectral elements in the fitted section is NaN. The routine will return NaN if the fitted peak lies outside the range of the fitted section.

Definition at line 343 of file eris_nix_lss_utils.c.

Referenced by enlu_linepos_2d().

◆ enlu_linepos_2d()

cpl_matrix * enlu_linepos_2d ( const hdrl_image *  spectrum2d,
const cpl_size  slice_index,
const cpl_vector *  guess_pos 
)

Fit the line peaks of a wave calibration spectrum.

Returns
A cpl_matrix with dimensions [nx, nlines], where nx is the number of columns in the 2d spectrum, nlines the size of guess_pos.

The function fits line peaks across the 2d wave calibration spectrum from a slit spectrograph.

Starting in the middle x position, and iterating upward in x across the right hand side of the 2d image, the routine looks at y-slices in turn.

For each slice the 1d spectrum and the current guess vector are passed to enlu_linepos_1d, which returns a vector of fitted positions. Successful fits in that vector are stored in the return matrix, and used as the 'guess' for the next slice. In this way, the routine can follow the curve of lines with x if the movement is gentle.

Unsuccessful fits in the vector are not stored in the return matrix and do not propagate to the next 'guess', instead the current 'guess'is carried over. This is intended to make the 'guess' more robust against noisy pixels which can throw the fit off in isolated cases, and once the guess goes wrong the algorithm fails.

The process is repeated for the left side of the 2d spectrum, starting in the middle and iterating downward in x.

The routine will return NULL if entered with the CPL error code set.

The routine will return NULL, and set CPL error code to CPL_ERROR_NULL_INPUT if called with spectrum2d or guess_pos NULL.

The routine will return NULL, and set CPL error code to CPL_ERROR_ILLEGAL_INPUT if guess_pos has 0 elements.

Elements of the return matrix for which the fit failed will be set to NaN.

Definition at line 241 of file eris_nix_lss_utils.c.

References enlu_linepos_1d(), hdrl_image_get_image_const(), and hdrl_image_get_size_x().

◆ enlu_trace_save()

cpl_error_code enlu_trace_save ( const char *  pro_catg,
const hdrl_image *  image,
const cpl_image *  confidence,
const cpl_size  ntraces,
const cpl_polynomial *  traces[ntraces],
const cpl_size  nspectra,
const cpl_vector *  spectra[nspectra],
const cpl_size  nlines,
const cpl_polynomial *  lines[nlines],
cpl_frameset *  frameset,
const cpl_parameterlist *  parlist,
const char *  filename,
const char *  recipe_name 
)

Save a trace result.

Parameters
pro_catgThe value of the ESO.PRO.CATG keyword
imageThe trace data
confidenceThe confidence array
spectrumThe trace spectrum
framesetThe list of input frames for the recipe
parlistThe list of input parameters
filenameThe name of the output file
recipe_nameThe recipe name
Returns
CPL_ERROR_NONE if all goes well, otherwise an error code

Definition at line 432 of file eris_nix_lss_utils.c.

References enlu_warp_poly_save_to_table(), enu_dfs_save_himage(), enu_mef_extension_list_delete(), enu_mef_extension_list_new(), enu_mef_new_image(), enu_mef_new_table(), and enu_mef_new_vector().

◆ enlu_warp_poly_load_from_table()

cpl_polynomial * enlu_warp_poly_load_from_table ( const cpl_table *  table)

Load a LSS warp polynomial from a cpl_table.

Parameters
tableThe cpl_table with the informaion.
Returns
The cpl_polynomial required, or NULL on error.

Loads a cpl_polynomial used for warping the LSS 2d-spectrum that has been previously saved to a cpl_table by enlu_warp_poly_save_to_table.

The polynomial is expected to be of degree 2 but can have entries for any number of powers.

Definition at line 537 of file eris_nix_lss_utils.c.

◆ enlu_warp_poly_save_to_table()

cpl_table * enlu_warp_poly_save_to_table ( const cpl_polynomial *  poly)

Save an LSS polynomial to a cpl_table.

Parameters
polyThe cpl_polynomial to save.
Returns
A table with the polynomial, or NULL on error.

Saves a 1 or 2-d cpl_polynomial to a cpl_table.

The polynomial is expected to be 1 or 2d but can have entries for any number of powers.

Definition at line 599 of file eris_nix_lss_utils.c.

Referenced by enlu_trace_save().