Recipe to reduce arc lamp data

Functions

int sinfo_new_wave_cal_slit2 (const char *plugin_id, cpl_parameterlist *config, cpl_frameset *sof, cpl_frameset *ref_set)
int cpl_plugin_get_info (cpl_pluginlist *list)
 Build the list of available plugins, for this module.

sinfo_new_fit_params()

allocates memory for a new array of FitParams data structures

Parameters:
n_params number of spectral lines that will be fitted
Returns:
allocated array of FitParams data structures


FitParams ** sinfo_new_fit_params (int n_params)

sinfo_new_destroy_fit_params()

frees memory of an array of FitParams data structures

Parameters:
params fit params to destroy
Returns:
nothing


void sinfo_new_destroy_fit_params (FitParams ***params)

sinfo_new_dump_fit_params_to_ascii()

dumps the fit parameters to an ASCII file

Parameters:
params,: fit params to dump
filename 
Returns:
filled ASCII file


void sinfo_new_dump_fit_params_to_ascii (FitParams **params, const char *filename)

dump_ascii_to_fit_params()

dumps ASCII information to an allocated FitParams data structure

Parameters:
params allocated dummy for the fit params
filename 
Returns:
params: filled FitParams object


void sinfo_new_dump_ascii_to_fit_params (FitParams **params, char *filename)

sinfo_new_find_lines()

determines the pixel shift between the line list and the real image

Parameters:
lineImage,: merged emission line image,
wave_position,: wavelength list in Angstroems
wave_intensity,: corresponding intensity list
n_lines,: number of lines in list
row_clean,: resulting list of the row indices but without the lines that are too close to each other for the fit
wavelength_clean,: corrected wavelength list corresponding to the row_clean array
beginWave,: beginning wavelength on detector in microns
dispersion,: dispersion of the grating on the detector (microns per pixel, attention: merged image).
mindiff,: minimal difference of mean and median column intensity to do the correlation. This is done to avoid correlations in columns without emission line intensity.
halfWidth,: half width of the box where the line must sit,
n_found_lines,: number of found and correlated emission lines in a column.
sigma,: sigma of Gaussian that is convolved with the artificial spectrum
Returns:
0 if all went o.k. # row: resulting list of the row indices of the line positions # row_clean: resulting list of the row indices but without the lines that are too close to each other for the fit # wavelength: wavelength from the list corresponding to the found row positions # wavelength_clean: corrected wavelength list corresponding to the row_clean array # n_found_lines: number of found and correlated emission lines in a column. # sum_lines: total sum of found and correlated emission lines -1 if something has gone wrong determines the pixel shift between the line list and the real image by using the beginning wavelength on the detector and the dispersion estimate.


int sinfo_new_find_lines (cpl_image *lineImage, float *wave_position, float *wave_intensity, int n_lines, int **row_clean, float **wavelength_clean, float beginWave, float dispersion1, float dispersion2, float mindiff, int halfWidth, int *n_found_lines, float sigma, int *sum_lines)

sinfo_new_read_list()

reads the line data of the calibration lamps

Parameters:
listname name of the list file, arrays to store the wavelength and the intensities of the emission lines
lineCenter 
lineIntensity 


int sinfo_new_read_list (char *listname, float *lineCenter, float *lineIntensity)

sinfo_new_line_fit()

fits a Gaussian to a 1-dimensional slice of an image

Parameters:
mergedImage,: image of a calibration emission lamp,
par,: dummys for the resulting fitting parameters,
fwhm,: guess value for full width of half maximum of Gaussian
lineInd,: index of the emission line,
column,: present index of the image column,
halfWidth,: half width of the box where the line must sit,
lineRow,: row index where the line is expected,
min_amplitude,: minimum line amplitude with respect to the background to do the fit
Returns:
the fitting parameter data structure containing the resulting parameters. # integers: number of iterations if all was ok, # -8 if no input image was given, # -9 if no dummy for the fit parameters is given, # -10 if the wrong column index was given, # -11 if the wrong box width was given, # -12 if the wrong row index was given, # -13 if a wrong minimum amplitude factor was given # -14 if the spectral sinfo_vector data structure memory could not be allocated # -15 wrong row index or box width was given, # -16 signal too low to fit, # -17 least squares fit failed fits a Gaussian to a 1-dimensional slice of an image, this routine uses the routine sinfo_new_lsqfit_c as a non-linear least square fit method (Levenberg-Marquardt).


int sinfo_new_line_fit (cpl_image *mergedImage, FitParams *par, float fwhm, int lineInd, int column, int halfWidth, int lineRow, float min_amplitude, Vector *line, int *mpar, float *xdat, float *wdat)

sinfo_new_fit_lines

calculates and stores the fit parameters of the neon emission lines of a neon frame by using the linefit routine.

Parameters:
line_image,: merged image of a calibration lamp ,
allParams,: allocated sinfo_vector of FitParams data structures,
fwhm,: guess value for full width of half maximum of Gaussian
n_lines,: number of neon lines that will be fitted in one column ,
row,: list of the rows of the fitted lines
wavelength,: list of wavelength corresponding to the found line rows
width,: half width of a box around the found rows within the line is fitted
min_amplitude,: minimum line amplitude with respect to the background to do the fit
Returns:
filled FitParams data structure sinfo_vector, number of successfully fitted lines, # errors: negative integers resulting from the linefit routine and: # -18: no image given, # -19: number of emission lines or number of slitlets is wrong, # -20: sinfo_vector of the slitlet boundaries or of the line rows or of the half width are empty. # -21: no wavelength array given.


int sinfo_new_fit_lines (cpl_image *line_image, FitParams **allParams, float fwhm, int *n_lines, int **row, float **wavelength, int width, float min_amplitude)

sinfo_new_polyfit()

fits a polynomial to determine the connection between the listed wavelength values and the gauss-fitted positions for each image column using the singular value decomposition method.

Parameters:
par,: filled array of fit parameter structure
column,: image column index
n_lines,: number of found lines in column
n_rows,: number of image rows
dispersion,: microns per pixel
max_residual,: maximum residual value, beyond that value the fit is rejected.
acoefs,: array of the 3 coefficients of the fitted parabola
dacoefs,: array of standard deviations of the 3 coefficients
n_reject,: rejected number of fits due to high residuals
n_fitcoefs,: number of polynomial coefficients to fit
Returns:
# chisq, the three fit coefficients acoefs[i] and their standard deviations dacoefs[i], the rejected number of fits due to too high residuals: n_reject # FLT_MAX in case of error fits a polynomial lambda[i] = a1 + a2*pos[i] + a3*pos[i]^2 +... to determine the connection between the listed wavelength values and the gauss-fitted positions for each image column using the singular value decomposition method.


float sinfo_new_polyfit (FitParams **par, int column, int n_lines, int n_rows, float dispersion, float max_residual, float *acoefs, float *dacoefs, int *n_reject, int n_fitcoefs)

sinfo_new_coefs_cross_fit()

Fits each single polnomial coefficient acoefs resulting from sinfo_polyfit across the image columns

Parameters:
n_columns,: number of image columns
acoefs,: coeffs fitted in sinfo_polyfit
note,: this is a sinfo_vector of coefficients with the same index for all columns
dacoefs,: fit errors of the corresponding acoefs
bcoefs,: the fitted coefs
n_fitcoefs,: number of fit coefficients
sigma_factor,: factor of sigma beyond which the column coefficients are discarded for the fit
Returns:
chisq, the found fit coefficients


float sinfo_new_coefs_cross_fit (int n_columns, float *acoefs, float *dacoefs, float *bcoefs, int n_fitcoefs, float sigma_factor)

sinfo_new_wave_map()

determines a wavelength calibration map

Parameters:
lineImage,: image from a calibration emission lamp,
bcoefs,: transformed fit coefficients
n_a_fitcoefs,: number of fit coefficients for the single column fits lambda-position
n_b_fitcoefs,: number of fit coefficients for the fits of the single a coefficients across the columns
wavelength,: wavelength list from lamp file
intensity,: corresponding line intensity from line list
n_lines,: number of lines in the list
magFactor,: magnifying factor of the image for FFT
Returns:
wavelength calibration map image. this routine determines a wavelength calibration map frame associating a wavelength value to each pixel by using the fit coefficients determined before.


cpl_image * sinfo_new_wave_map (cpl_image *lineImage, float **bcoefs, int n_a_fitcoefs, int n_b_fitcoefs, float *wavelength, float *intensity, int n_lines, int magFactor)

sinfo_new_wavelength_calibration()

Parameters:
image,: merged image from a calibration emission lamp,
wave,: wavelength array read from the wavelength list
n_lines,: number of lines in the wavelength list
row_clean,: resulting list of the row indices but without the lines that are too close to each other for the fit output of sinfo_findLines()
wavelength_clean,: corrected wavelength list corresponding to the row_clean array output of sinfo_findLines()
n_found_lines,: output of sinfo_findLines(): total number of found emission lines
dispersion,: dispersion of spectrum: micron per pixel
halfWidth,: half width of the box where the line must sit
minAmplitude,: minimum amplitude of the Gaussian to do the fit
max_residual,: maximum residual value, beyond that value the polynomial lambda-position fit is rejected.
fwhm,: first guess for the full width of half maximum of the sinfo_gaussian line fit
n_a_fitcoefs,: number of fit coefficients for the single column fits: lambda-position
n_b_fitcoefs,: number of fit coefficients for the fits of the single a coefficients across the columns
sigmaFactor,: factor of the standard deviation of the determined polynomial coefficients of the columns beyond which these coefficients are not used to carry out the polynomial fit across the columns.
pixel_tolerance,: maximum tolerated difference between estimated and fitted line positions.
Returns:
0 if all went o.k., -1 if something went wrong. # bcoefs: array of cooefficients of the polynomial fit across the columns. # par: array of the resulting FitParams data structure this routine takes an image from a calibration emission lamp and delivers the fit coefficients of a polynomial fit across the columns of the coefficients of the polynomial line position fits as output. Furthermore it delivers an array of the fit parameters as output. This routine expects Nyquist sampled spectra (either an interleaved image or an image convolved with an appropriate function in spectral direction)


int sinfo_new_wavelength_calibration (cpl_image *image, FitParams **par, float **bcoefs, float *wave, int n_lines, int **row_clean, float **wavelength_clean, int *n_found_lines, float dispersion, int halfWidth, float minAmplitude, float max_residual, float fwhm, int n_a_fitcoefs, int n_b_fitcoefs, float sigmaFactor, float pixel_tolerance)

sinfo_new_convolve_image_by_gauss()

Parameters:
lineImage,: emission line image
hw,: kernel half width of the sinfo_gaussian response function
Returns:
emission line image convolved with a Gaussian convolves an emission line image with a Gaussian with user given integer half width by using the eclipse routine sinfo_function1d_filter_lowpass().


cpl_image * sinfo_new_convolve_image_by_gauss (cpl_image *lineImage, int hw)

sinfo_new_defined_resampling()

Given a source image and a corresponding wavelength calibration file this routine produces an image in which elements in a given row are associated with a single wavelength.

Parameters:
image,: source image to be calibrated
calimage,: wavelength map image
n_params,: number of fit parameters for the polynomial interpolation standard should be 3 that means order of polynom + 1
n_rows,: desired number of rows for the final image, this will be the final number of spectral pixels in the final data cube.
dispersion,: dummy for the resulting dispersion
minval,: dummy for minimal wavelength value,
maxval,: dummy for maximal wavelength value
centralLambda,: dummy for the final central wavelength
Returns:
# wavelength calibrated source image, # dispersion: resulting spectral dispersion (microns/pixel) is chosen as the minimum dispersion found in the wavelength map - 2% of this value # minval: minimal wavelength value, # maxval: maximal wavelength value # centralLambda: final central wavelength value # centralpix: row of central wavelength (in image coordinates!) Given a source image and a corresponding wavelength calibration file this routine produces an image in which elements in a given row are associated with a single wavelength. It thus corrects for the wavelength shifts between adjacent elements in the rows of the input image. The output image is larger in the wavelength domain than the input image with pixels in each column corresponding to undefined (blank, ZERO) values. The distribution of these undefined values varies from column to column. The input image is resampled at discrete wavelength intervals using a polynomial interpolation routine. The wavelength intervals (dispersion) and the central wavelength are defined and stable for each used grating. Thus, each row has a defined wavelength for each grating. Only the number of rows can be changed by the user.


cpl_image * sinfo_new_defined_resampling (cpl_image *image, cpl_image *calimage, int n_params, int *n_rows, double *dispersion, float *minval, float *maxval, double *centralLambda, int *centralpix)

parse_wave_ini_file

Parse a ini_name.ini file and create a blackboard.

Parameters:
ini_name Name of the ASCII file to parse.
Returns:
1 newly allocated wave_config blackboard structure.

The requested ini file is parsed and a blackboard object is created, then updated accordingly. Returns NULL in case of error.



wave_config * sinfo_parse_cpl_input_wave (cpl_parameterlist *cpl_cfg, cpl_frameset *sof, cpl_frameset **raw)
void sinfo_wavecal_free (wave_config **cfg)

Detailed Description

TBD


Function Documentation

int cpl_plugin_get_info ( cpl_pluginlist *  list  ) 

Build the list of available plugins, for this module.

Parameters:
list the plugin list
Returns:
0 if everything is ok, -1 otherwise

Create the recipe instance and make it available to the application using the interface. This function is exported.

Definition at line 146 of file sinfo_rec_wavecal.c.

References sinfo_get_license().

int sinfo_new_wave_cal_slit2 ( const char *  plugin_id,
cpl_parameterlist *  config,
cpl_frameset *  sof,
cpl_frameset *  ref_set 
)

RESAMPLE ThAr frame for QC double dis=0; float mi=0; float ma=0; double cwav=0; int cpix=0; const cpl_frame* frm=NULL; char wstk_name[80]; char map_name[80]; cpl_image* res_ima=NULL; int ncoeffs=3; int nrows=SINFO_RESAMP_NROWS;

check_nomsg(p = cpl_parameterlist_find(config, "sinfoni.wavecal.n_coeffs"));

check_nomsg(ncoeffs=cpl_parameter_get_int(p));

check_nomsg(frm=cpl_frameset_find_const(sof,PRO_WAVE_LAMP_STACKED)); check_nomsg(strcpy(wstk_name,cpl_frame_get_filename(frm))); check_nomsg(wstk_img=cpl_image_load(wstk_name,CPL_TYPE_FLOAT,0,0));

check_nomsg(frm=cpl_frameset_find_const(sof,PRO_WAVE_MAP)); check_nomsg(strcpy(map_name,cpl_frame_get_filename(frm))); check_nomsg(map_img=cpl_image_load(map_name,CPL_TYPE_FLOAT,0,0));

cknull(res_ima = sinfo_new_defined_resampling(wstk_img, map_img, ncoeffs, &nrows, &dis, &mi, &ma, &cwav, &cpix), " sinfo_definedResampling() failed" ) ;

ck0(sinfo_pro_save_ima(res_ima,ref_set,sof,WAVECAL_RESAMPLED_OUT_FILENAME, PRO_RESAMPLED_WAVE,NULL,plugin_id,config), "cannot save ima %s",WAVECAL_RESAMPLED_OUT_FILENAME);

sinfo_free_image(&map_img); sinfo_free_image(&res_ima); sinfo_free_image(&wstk_img);

sinfo_qc_wcal_delete(&qc);

Definition at line 116 of file sinfo_new_wave_cal_slit2.c.

References sinfo_free_frameset(), sinfo_free_image(), sinfo_free_table(), sinfo_msg_error, sinfo_new_fit_slits_boltz(), sinfo_new_fit_slits_boltz_with_estimate(), sinfo_pro_save_ima(), and sinfo_pro_save_tbl().


Generated on 8 Mar 2011 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1