Alignspectra: Difference between revisions
imported>Jeremy (Importing text file) |
imported>Neal |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Line 11: | Line 10: | ||
===Description=== | ===Description=== | ||
ALIGNSPECTRA calibrates a wavelength scale using a standard spectrum and a piece-wise shifting that maximizes correlation between windows on the standard spectrum to windows on the test spectrum. Ideally, the axis scale would be the same for all time and all instruments, however it can be necessary to calibrate the axis scale. This calibration is often done somewhat manually using known standard peak positions (see ALIGNPEAKS). In the ALIGNSPECTRA function a standard is measured on both the standard instrument with spectrum y0 and the field instrument with spectrum y1. The transform is based on a polynomial fit of the center channel of a window of channels | ALIGNSPECTRA calibrates a wavelength scale using a standard spectrum and a piece-wise shifting that maximizes correlation between windows on the standard spectrum to windows on the test spectrum. Ideally, the axis scale would be the same for all time and all instruments, however it can be necessary to calibrate the axis scale. This calibration is often done somewhat manually using known standard peak positions (see ALIGNPEAKS). In the ALIGNSPECTRA function a standard is measured on both the standard instrument with spectrum (y0) and the field instrument with spectrum (y1). The transform is based on a polynomial fit of the center channel of a window of channels [window size (win)] on the field instrument that best correlates with a similar sized window of channels on the standard instrument. The window on the field instrument is allowed to shift a maximum of (mx2) channels. | ||
The inputs to ALIGNSPECTRA are x0 a 1x''N'' vector containing the axis scale of the standard instrument at ''t'' = 0 (e.g., the true wavelengths), y0 a 1x''N'' spectrum measured on the standard instrument at ''t'' = 0, y1 a 1x''N'' spectrum measured on the field instrument at ''t'' > 0, a window width of channels on the axis scale win, and the maximum number of channels to shift mx2. | The inputs to ALIGNSPECTRA are (x0) a 1x''N'' vector containing the axis scale of the standard instrument at ''t'' = 0 (e.g., the true wavelengths), (y0) a 1x''N'' spectrum measured on the standard instrument at ''t'' = 0, (y1) a 1x''N'' spectrum measured on the field instrument at ''t'' > 0, a window width of channels on the axis scale win, and the maximum number of channels to shift (mx2). | ||
===Options=== | ===Options=== | ||
Optional input options is a structure array with the following fields: | Optional input (options) is a structure array with the following fields: | ||
* '''name''': 'options', name indicating that this is an options structure. | * '''name''': 'options', name indicating that this is an options structure. | ||
Line 23: | Line 22: | ||
* '''plots''': [ 'none' | {'final'} ] governs level of plotting. | * '''plots''': [ 'none' | {'final'} ] governs level of plotting. | ||
* '''interpolate''': [ 'none' | {'linear'} | 'cubic'] dictates the interpolation scheme used when shifting the window. 'none' uses the coarse scale given by x0. Using other interpolation schemes can significantly increase the time required for computation (the algorithm calls the function INTERP1). | * '''interpolate''': [ 'none' | {'linear'} | 'cubic'] dictates the interpolation scheme used when shifting the window. 'none' uses the coarse scale given by (x0). Using other interpolation schemes can significantly increase the time required for computation (the algorithm calls the function INTERP1). | ||
* '''order''': [ {2} ] integer giving the polynomial order. | * '''order''': [ {2} ] integer giving the polynomial order. |
Latest revision as of 09:24, 25 September 2008
Purpose
Calibrates wavelength scale using a standard spectrum.
Synopsis
- [s,y] = alignspectra(x0,y0,y1,win,mx2,options)
- y = alignspectra(s,y1);
Description
ALIGNSPECTRA calibrates a wavelength scale using a standard spectrum and a piece-wise shifting that maximizes correlation between windows on the standard spectrum to windows on the test spectrum. Ideally, the axis scale would be the same for all time and all instruments, however it can be necessary to calibrate the axis scale. This calibration is often done somewhat manually using known standard peak positions (see ALIGNPEAKS). In the ALIGNSPECTRA function a standard is measured on both the standard instrument with spectrum (y0) and the field instrument with spectrum (y1). The transform is based on a polynomial fit of the center channel of a window of channels [window size (win)] on the field instrument that best correlates with a similar sized window of channels on the standard instrument. The window on the field instrument is allowed to shift a maximum of (mx2) channels.
The inputs to ALIGNSPECTRA are (x0) a 1xN vector containing the axis scale of the standard instrument at t = 0 (e.g., the true wavelengths), (y0) a 1xN spectrum measured on the standard instrument at t = 0, (y1) a 1xN spectrum measured on the field instrument at t > 0, a window width of channels on the axis scale win, and the maximum number of channels to shift (mx2).
Options
Optional input (options) is a structure array with the following fields:
- name: 'options', name indicating that this is an options structure.
- plots: [ 'none' | {'final'} ] governs level of plotting.
- interpolate: [ 'none' | {'linear'} | 'cubic'] dictates the interpolation scheme used when shifting the window. 'none' uses the coarse scale given by (x0). Using other interpolation schemes can significantly increase the time required for computation (the algorithm calls the function INTERP1).
- order: [ {2} ] integer giving the polynomial order.
Executing options = alignspectra('options'); gives an empty options structure.
Example
A measurements at t = 0 gives a spectrum y0 with axis ax, and measurements at t > 0 of the same sample yields a spectrum y1 with the same axis ax but with peaks shifted. Therefore
- plot(ax,y0,'b',ax,y1,'r')
shows a shift in the peaks. The peak positions at t = 0 are listed in x0 and the peak positions at t > 0 are listed in x1. The polynomial fit is given by
- s = alignspectra(x0,y0,y1,25,7); %or
- [s,y10] = alignspectra(x0,y0,y1,25,7);
and the transformed spectrum is obtained with
- y10 = alignspectra(s,y1);
so that
- plot(ax,y0,'b',ax,y1,'r')
shows less of a peak shift. See alignspectrademo.