Alignspectra: Difference between revisions
imported>Jeremy (Importing text file) |
imported>Neal |
||
(11 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Calibrates wavelength scale using a standard spectrum. | Calibrates wavelength scale using a standard spectrum. | ||
===Synopsis=== | ===Synopsis=== | ||
:[s,y] = alignspectra(x0,y0,y1,win,mx2,options) | :[s,y] = alignspectra(x0,y0,y1,win,mx2,options) | ||
:y = alignspectra(s,y1); | :y = alignspectra(s,y1); | ||
===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 | |||
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. | 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). | |||
===Options=== | ===Options=== | ||
Optional input options is a structure array with the following fields: | |||
* name: 'options', name indicating that this is an options structure. | Optional input (options) is a structure array with the following fields: | ||
* 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). | * '''name''': 'options', name indicating that this is an options structure. | ||
* order: [ {2} ] integer giving the polynomial order. | |||
* '''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. | Executing options = alignspectra('options'); gives an empty options structure. | ||
===Example=== | ===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 | 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') | :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 | 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 = alignspectra(x0,y0,y1,25,7); %or | ||
:[s,y10] = alignspectra(x0,y0,y1,25,7); | :[s,y10] = alignspectra(x0,y0,y1,25,7); | ||
and the transformed spectrum is obtained with | and the transformed spectrum is obtained with | ||
:y10 = alignspectra(s,y1); | :y10 = alignspectra(s,y1); | ||
so that | so that | ||
:plot(ax,y0,'b',ax,y1,'r') | :plot(ax,y0,'b',ax,y1,'r') | ||
shows less of a peak shift. See alignspectrademo. | shows less of a peak shift. See alignspectrademo. | ||
===See Also=== | ===See Also=== | ||
[[alignmat]], [[alignpeaks]], [[registerspec]], [[stdgen]] | [[alignmat]], [[alignpeaks]], [[registerspec]], [[stdgen]] |
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.