function identifylines

This function attempts to find the reference pattern LINES in a list of observed positions PEAKS. In the following documentation a terminology drawn from the context of arc lamp spectra calibration is used for simplicity: the reference pattern is then a list of wavelengths corresponding to a set of reference arc lamp emission lines - the so-called line catalog; while the observed positions are the positions (in pixel) on the CCD, measured along the dispersion direction, of any significant peak of the signal. To identify the observed peaks means to associate them with the right reference wavelength. This is attempted here with a point-pattern matching technique, where the pattern is contained in the vector LINES, and is searched in the vector PEAKS. In order to work, this method just requires a rough expectation value of the spectral dispersion (in Angstrom/pixel), and a line catalog. The line catalog LINES should just include lines that are expected somewhere in the CCD exposure of the calibration lamp (note, however, that a catalog including extra lines at its blue and/or red ends is still allowed). Typically, the arc lamp lines candidates PEAKS will include light contaminations, hot pixels, and other unwanted signal, but only in extreme cases this prevents the pattern-recognition algorithm from identifying all the spectral lines. The pattern is detected even in the case PEAKS contained more arc lamp lines than actually listed in the input line catalog. This method is based on the assumption that the relation between wavelengths and CCD positions is with good approximation locally linear (this is always true, for any modern spectrograph). The ratio between consecutive intervals pairs in wavelength and in pixel is invariant to linear transformations, and therefore this quantity can be used in the recognition of local portions of the searched pattern. All the examined sub-patterns will overlap, leading to the final identification of the whole pattern, notwithstanding the overall non-linearity of the relation between pixels and wavelengths. Ambiguous cases, caused by exceptional regularities in the pattern, or by a number of undetected (but expected) peaks that disrupt the pattern on the data, are recovered by linear interpolation and extrapolation of the safely identified peaks.

Syntax
result = identifylines(PEAKS, LINES, MIN_DISP, MAX_DISP, TOLERANCE)

Arguments
PEAKS:   A 1D-Fits, List of observed positions (e.g., of emission peaks)
LINES:   A 1D-Fits, List of positions in searched pattern (e.g., wavelengths)
MIN_DISP:   Min expected scale (e.g., spectral dispersion in A/pixel)
MAX_DISP:   Max expected scale (e.g., spectral dispersion in A/pixel)
TOLERANCE:   Tolerance for interval ratio comparison