public LinearWavelengthRegressionCalibration(SpectraCalibration props) { LoadPixels(props); m_A = props.A; m_B = props.B; EnsureResiduals(); m_RMS = props.RMS; }
public CubicWavelengthRegressionCalibration(SpectraCalibration props) { LoadPixels(props); m_A = props.A; m_B = props.B; m_C = props.C; m_D = props.D; EnsureResiduals(); m_RMS = props.RMS; }
protected void LoadPixels(SpectraCalibration props) { float[] pixelsArr = new float[] { props.Pixel1, props.Pixel2, props.Pixel3, props.Pixel4, props.Pixel5, props.Pixel6, props.Pixel7, props.Pixel8 }; float[] wavelengthsArr = new float[] { props.Wavelength1, props.Wavelength2, props.Wavelength3, props.Wavelength4, props.Wavelength5, props.Wavelength6, props.Wavelength7, props.Wavelength8 }; for (int i = 0; i < 8; i++) { if (!float.IsNaN(pixelsArr[i]) && !float.IsNaN(wavelengthsArr[i])) { m_PixelPos.Add(pixelsArr[i]); m_Wavelengths.Add(wavelengthsArr[i]); } } }
public SpectraCalibration GetSpectraCalibration() { var rv = new SpectraCalibration() { Dispersion = CalculateDispersion(), ZeroPixel = m_B, RMS = GetCalibrationRMS(), PolynomialOrder = GetCalibrationOrder(), FitType = this.GetType().Name, A = m_A, B = m_B }; base.SavePixels(rv); return(rv); }
private void LoadPoints(SpectraCalibration props) { float[] pixelsArr = new float[] { props.Pixel1, props.Pixel2, props.Pixel3, props.Pixel4, props.Pixel5, props.Pixel6, props.Pixel7, props.Pixel8 }; float[] wavelengthsArr = new float[] { props.Wavelength1, props.Wavelength2, props.Wavelength3, props.Wavelength4, props.Wavelength5, props.Wavelength6, props.Wavelength7, props.Wavelength8 }; for (int i = 0; i < 8; i++) { if (!float.IsNaN(pixelsArr[i]) && !float.IsNaN(wavelengthsArr[i])) { m_PixelPos[i] = pixelsArr[i]; m_Wavelengths[i] = wavelengthsArr[i]; } else { m_PixelPos[i] = float.NaN; m_Wavelengths[i] = float.NaN; } } }
public bool LoadCalibration(SpectraCalibration calibration) { LoadPoints(calibration); switch (calibration.FitType) { case "LinearWavelengthCalibration": m_WavelengthCalibration = new LinearWavelengthCalibration(calibration); return(true); case "QuadraticWavelengthCalibration": m_WavelengthCalibration = new QuadraticWavelengthCalibration(calibration); return(true); case "LinearWavelengthRegressionCalibration": m_WavelengthCalibration = new LinearWavelengthRegressionCalibration(calibration); return(true); case "QuadraticWavelengthRegressionCalibration": m_WavelengthCalibration = new QuadraticWavelengthRegressionCalibration(calibration); return(true); case "CubicWavelengthRegressionCalibration": m_WavelengthCalibration = new CubicWavelengthRegressionCalibration(calibration); return(true); case "QuarticWavelengthRegressionCalibration": m_WavelengthCalibration = new QuarticWavelengthRegressionCalibration(calibration); return(true); case "CubicWavelengthCalibration": m_WavelengthCalibration = new CubicWavelengthCalibration(calibration); return(true); } return(false); }
public MasterSpectra(BinaryReader reader) { int version = reader.ReadInt32(); CombinedMeasurements = reader.ReadInt32(); SignalAreaWidth = reader.ReadInt32(); MaxPixelValue = reader.ReadUInt32(); MaxSpectraValue = reader.ReadUInt32(); ZeroOrderPixelNo = reader.ReadInt32(); int pixelsCount = reader.ReadInt32(); Points = new List <SpectraPoint>(); for (int i = 0; i < pixelsCount; i++) { var point = new SpectraPoint(reader); Points.Add(point); } int width = reader.ReadInt32(); int height = reader.ReadInt32(); Pixels = new float[width, height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Pixels[x, y] = reader.ReadSingle(); } } MeasurementInfo = new MeasurementInfo(reader); if (reader.ReadBoolean()) { Calibration = new SpectraCalibration(reader); } int rawFramesCount = reader.ReadInt32(); for (int i = 0; i < rawFramesCount; i++) { var frameMeasurement = new Spectra(); RawMeasurements.Add(frameMeasurement); frameMeasurement.SignalAreaWidth = reader.ReadInt32(); frameMeasurement.MaxPixelValue = reader.ReadUInt32(); frameMeasurement.MaxSpectraValue = reader.ReadUInt32(); frameMeasurement.ZeroOrderPixelNo = reader.ReadInt32(); frameMeasurement.ZeroOrderFWHM = float.NaN; if (version > 1) { frameMeasurement.ZeroOrderFWHM = reader.ReadSingle(); } int frameMeaCount = reader.ReadInt32(); for (int j = 0; j < frameMeaCount; j++) { var point = new SpectraPoint(reader); frameMeasurement.Points.Add(point); } } ProcessingInfo = new ProcessingInfo(reader); ObservationInfo = new ObservationInfo(reader); ZeroOrderFWHM = float.NaN; if (version > 1) { ZeroOrderFWHM = reader.ReadSingle(); } }
public MasterSpectra(BinaryReader reader) { int version = reader.ReadInt32(); CombinedMeasurements = reader.ReadInt32(); SignalAreaWidth = reader.ReadInt32(); MaxPixelValue = reader.ReadUInt32(); MaxSpectraValue = reader.ReadUInt32(); ZeroOrderPixelNo = reader.ReadInt32(); int pixelsCount = reader.ReadInt32(); Points = new List<SpectraPoint>(); for (int i = 0; i < pixelsCount; i++) { var point = new SpectraPoint(reader); Points.Add(point); } int width = reader.ReadInt32(); int height = reader.ReadInt32(); Pixels = new float[width,height]; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) { Pixels[x, y] = reader.ReadSingle(); } MeasurementInfo = new MeasurementInfo(reader); if (reader.ReadBoolean()) Calibration = new SpectraCalibration(reader); int rawFramesCount = reader.ReadInt32(); for (int i = 0; i < rawFramesCount; i++) { var frameMeasurement = new Spectra(); RawMeasurements.Add(frameMeasurement); frameMeasurement.SignalAreaWidth = reader.ReadInt32(); frameMeasurement.MaxPixelValue = reader.ReadUInt32(); frameMeasurement.MaxSpectraValue = reader.ReadUInt32(); frameMeasurement.ZeroOrderPixelNo = reader.ReadInt32(); frameMeasurement.ZeroOrderFWHM = float.NaN; if (version > 1) { frameMeasurement.ZeroOrderFWHM = reader.ReadSingle(); } int frameMeaCount = reader.ReadInt32(); for (int j = 0; j < frameMeaCount; j++) { var point = new SpectraPoint(reader); frameMeasurement.Points.Add(point); } } ProcessingInfo = new ProcessingInfo(reader); ObservationInfo = new ObservationInfo(reader); ZeroOrderFWHM = float.NaN; if (version > 1) { ZeroOrderFWHM = reader.ReadSingle(); } }
protected void SavePixels(SpectraCalibration props) { if (m_PixelPos.Count > 0) { props.Pixel1 = m_PixelPos[0]; props.Wavelength1 = m_Wavelengths[0]; if (m_PixelPos.Count > 1) { props.Pixel2 = m_PixelPos[1]; props.Wavelength2 = m_Wavelengths[1]; if (m_PixelPos.Count > 2) { props.Pixel3 = m_PixelPos[2]; props.Wavelength3 = m_Wavelengths[2]; if (m_PixelPos.Count > 3) { props.Pixel4 = m_PixelPos[3]; props.Wavelength4 = m_Wavelengths[3]; if (m_PixelPos.Count > 4) { props.Pixel5 = m_PixelPos[4]; props.Wavelength5 = m_Wavelengths[4]; if (m_PixelPos.Count > 5) { props.Pixel6 = m_PixelPos[5]; props.Wavelength6 = m_Wavelengths[5]; if (m_PixelPos.Count > 6) { props.Pixel7 = m_PixelPos[6]; props.Wavelength7 = m_Wavelengths[6]; if (m_PixelPos.Count > 7) { props.Pixel8 = m_PixelPos[7]; props.Wavelength8 = m_Wavelengths[7]; } else { props.Pixel8 = 0; props.Wavelength8 = float.NaN; } } else { props.Pixel7 = 0; props.Pixel8 = 0; props.Wavelength7 = float.NaN; props.Wavelength8 = float.NaN; } } else { props.Pixel6 = 0; props.Pixel7 = 0; props.Pixel8 = 0; props.Wavelength6 = float.NaN; props.Wavelength7 = float.NaN; props.Wavelength8 = float.NaN; } } else { props.Pixel5 = 0; props.Pixel6 = 0; props.Pixel7 = 0; props.Pixel8 = 0; props.Wavelength5 = float.NaN; props.Wavelength6 = float.NaN; props.Wavelength7 = float.NaN; props.Wavelength8 = float.NaN; } } else { props.Pixel4 = 0; props.Pixel5 = 0; props.Pixel6 = 0; props.Pixel7 = 0; props.Pixel8 = 0; props.Wavelength4 = float.NaN; props.Wavelength5 = float.NaN; props.Wavelength6 = float.NaN; props.Wavelength7 = float.NaN; props.Wavelength8 = float.NaN; } } else { props.Pixel3 = 0; props.Pixel4 = 0; props.Pixel5 = 0; props.Pixel6 = 0; props.Pixel7 = 0; props.Pixel8 = 0; props.Wavelength3 = float.NaN; props.Wavelength4 = float.NaN; props.Wavelength5 = float.NaN; props.Wavelength6 = float.NaN; props.Wavelength7 = float.NaN; props.Wavelength8 = float.NaN; } } else { props.Pixel2 = 0; props.Pixel3 = 0; props.Pixel4 = 0; props.Pixel5 = 0; props.Pixel6 = 0; props.Pixel7 = 0; props.Pixel8 = 0; props.Wavelength2 = float.NaN; props.Wavelength3 = float.NaN; props.Wavelength4 = float.NaN; props.Wavelength5 = float.NaN; props.Wavelength6 = float.NaN; props.Wavelength7 = float.NaN; props.Wavelength8 = float.NaN; } } }
public LinearWavelengthCalibration(SpectraCalibration props) { Calibrate((int)props.Pixel1, (int)props.Pixel2, props.Wavelength1, props.Wavelength2); }
public QuadraticWavelengthCalibration(SpectraCalibration props) { Calibrate((int)props.Pixel1, (int)props.Pixel2, (int)props.Pixel3, props.Wavelength1, props.Wavelength2, props.Wavelength3); }
public CubicWavelengthCalibration(SpectraCalibration calibration) : this(calibration.A, calibration.B, calibration.C, calibration.D, calibration.RMS) { }