Wasatch.NET 2.4.14
.NET application driver for Wasatch Photonics spectrometers
Loading...
Searching...
No Matches
Static Public Member Functions | Static Private Attributes | List of all members
WasatchNET.Util Class Reference

A collection of static functions provided to automate common algorithms and post-processing steps in spectroscopy applications. More...

Collaboration diagram for WasatchNET.Util:
[legend]

Static Public Member Functions

static double[] applyBoxcar (uint halfWidth, double[] spectrum)
 Remove high-frequency noise by averaging "n" (halfWidth) pixels to either side of each measured sample pixel. Note: this implementation does not average any pixels for which the full boxcar can not be computed (leaving noise on both ends of the spectrum).
 
static double[] applyRamanCorrection (double[] spectrum, float[] correctionCoeffs, int roiStart, int roiEnd)
 Performs SRM correction on the given spectrum using the proivided ROI and coefficients. Non-ROI pixels are not corrected.
 
static double[] cleanNan (double[] a, double replacement=0)
 Remove any "not a number" (sqrt(-1)) or "infinity" (1/0) values from an array, replacing them with the specified alternative.
 
static float[] cleanNan (float[] a, float replacement=0)
 
static double[] computeAbsorbance (double[] dark, double[] reference, double[] sample)
 Given dark, reference and sample spectra, compute the absorbance in AU (Absorbance Units) per Beer's Law.
 
static double[] computeAbsorbance (double[] darkCorrectedReference, double[] darkCorrectedSample)
 Same as computeAbsorbance(dark, reference, sample), but assumes that both reference and sample have been previously dark-corrected.
 
static double[] computeTransmission (double[] dark, double[] reference, double[] sample)
 Given a dark spectrum, a reference spectrum and a sample spectrum, computes the transmission or reflectance spectrum. All arguments must be non-null and of equal length.
 
static double[] computeTransmission (double[] darkCorrectedReference, double[] darkCorrectedSample)
 Same as computeTransmission(dark, reference, sample), but assumes that both reference and sample spectra have already been dark-corrected.
 
static void fixOrder< T > (ref T lo, ref T hi)
 
static double[] generateWavelengths (uint pixels, float[] coeffs)
 Given a 4th-order wavelength calibration, generates the array of wavelengths.
 
static byte[] truncateArray (byte[] src, int len)
 
static bool validTECCal (Spectrometer spec)
 
static double[] wavelengthsToWavenumbers (double laserWavelengthNM, double[] wavelengths)
 Given the center wavelength of a narrowband excitation source such as a laser, converts the passed x-axis of wavelengths (nm) into Raman shifts expressed in wavenumbers (1/cm).
 

Static Private Attributes

static Logger logger = Logger.getInstance()
 

Detailed Description

A collection of static functions provided to automate common algorithms and post-processing steps in spectroscopy applications.

Member Function Documentation

◆ applyBoxcar()

static double[] WasatchNET.Util.applyBoxcar ( uint  halfWidth,
double[]  spectrum 
)
inlinestatic

Remove high-frequency noise by averaging "n" (halfWidth) pixels to either side of each measured sample pixel. Note: this implementation does not average any pixels for which the full boxcar can not be computed (leaving noise on both ends of the spectrum).

Parameters
halfWidthHow many pixels to average to either side of each sample pixel; higher values yield increased smoothing with commensurate loss of detail (zero disables)
spectrumInput spectrum (unmodified)
Returns
de-noised, smoothed spectrum

◆ applyRamanCorrection()

static double[] WasatchNET.Util.applyRamanCorrection ( double[]  spectrum,
float[]  correctionCoeffs,
int  roiStart,
int  roiEnd 
)
inlinestatic

Performs SRM correction on the given spectrum using the proivided ROI and coefficients. Non-ROI pixels are not corrected.

This is kind of ridiculously inefficient...we should generate and cache the scaling factors when we first load the EEPROM.

Returns
The given spectrum, with ROI srm-corrected, as an array of doubles

◆ cleanNan() [1/2]

static double[] WasatchNET.Util.cleanNan ( double[]  a,
double  replacement = 0 
)
inlinestatic

Remove any "not a number" (sqrt(-1)) or "infinity" (1/0) values from an array, replacing them with the specified alternative.

Parameters
spectruminput array
replacementvalue to replace any NaN/INF entries (default zero)
Returns
cleansed array with no invalid values

◆ cleanNan() [2/2]

static float[] WasatchNET.Util.cleanNan ( float[]  a,
float  replacement = 0 
)
inlinestatic

◆ computeAbsorbance() [1/2]

static double[] WasatchNET.Util.computeAbsorbance ( double[]  dark,
double[]  reference,
double[]  sample 
)
inlinestatic

Given dark, reference and sample spectra, compute the absorbance in AU (Absorbance Units) per Beer's Law.

Parameters
darkcollected with the light source disabled or blocked by shutter
referencecollected with the light source shining through the reference medium (e.g. cuvette filled with air or water)
samplecollected with the light source shining through the sample
Returns
absorbance spectrum in AU

https://en.wikipedia.org/wiki/Beer–Lambert_law

◆ computeAbsorbance() [2/2]

static double[] WasatchNET.Util.computeAbsorbance ( double[]  darkCorrectedReference,
double[]  darkCorrectedSample 
)
inlinestatic

Same as computeAbsorbance(dark, reference, sample), but assumes that both reference and sample have been previously dark-corrected.

Parameters
darkCorrectedReferencedark-corrected reference spectrum of the light source shining through the reference medium (e.g. cuvette filled with air or water)
darkCorrectedSampledark-corrected sample spectrum light source shining through the sample
Returns
absorbance spectrum in AU

https://en.wikipedia.org/wiki/Beer–Lambert_law

◆ computeTransmission() [1/2]

static double[] WasatchNET.Util.computeTransmission ( double[]  dark,
double[]  reference,
double[]  sample 
)
inlinestatic

Given a dark spectrum, a reference spectrum and a sample spectrum, computes the transmission or reflectance spectrum. All arguments must be non-null and of equal length.

Parameters
darkcollected with the light source disabled or blocked by shutter
referencea direct spectrum of the light source (transmission) or of the illuminated reference medium (reflectance)
samplecollected with the light source passing through the sample (transmission) or reflected directly from the sample (reflectance)
Returns
transmission or reflectance spectrum

◆ computeTransmission() [2/2]

static double[] WasatchNET.Util.computeTransmission ( double[]  darkCorrectedReference,
double[]  darkCorrectedSample 
)
inlinestatic

Same as computeTransmission(dark, reference, sample), but assumes that both reference and sample spectra have already been dark-corrected.

Parameters
darkCorrectedReferencedark-corrected reference spectrum
darkCorrectedSampledark-corrected sample spectrum
Returns
transmission or reflectance spectrum

◆ fixOrder< T >()

static void WasatchNET.Util.fixOrder< T > ( ref T  lo,
ref T  hi 
)
inlinestatic
Type Constraints
T :IComparable 

◆ generateWavelengths()

static double[] WasatchNET.Util.generateWavelengths ( uint  pixels,
float[]  coeffs 
)
inlinestatic

Given a 4th-order wavelength calibration, generates the array of wavelengths.

Parameters
pixelsNumber of wavelengths to generate
coeffs4th-order polynomial coefficients (offset, x^1, x^2 and x^3)
Returns
array of 'pixel' wavalengths

◆ truncateArray()

static byte[] WasatchNET.Util.truncateArray ( byte[]  src,
int  len 
)
inlinestatic

◆ validTECCal()

static bool WasatchNET.Util.validTECCal ( Spectrometer  spec)
inlinestatic

◆ wavelengthsToWavenumbers()

static double[] WasatchNET.Util.wavelengthsToWavenumbers ( double  laserWavelengthNM,
double[]  wavelengths 
)
inlinestatic

Given the center wavelength of a narrowband excitation source such as a laser, converts the passed x-axis of wavelengths (nm) into Raman shifts expressed in wavenumbers (1/cm).

Parameters
laserWavelengthNMcenter wavelength of the excitation laser (nm)
wavelengthsarray of calibrated wavelength values for each pixel
Returns
an array of the same length as the input wavelengths, with each element representing the corresponding Raman shift in wavenumbers from the excitation laser

Member Data Documentation

◆ logger

Logger WasatchNET.Util.logger = Logger.getInstance()
staticprivate

The documentation for this class was generated from the following file: