public bool CheckSpectraSaturatedOrNone(out SAPPHIRE_ANALYZER_RESULT result) { bool crPeaksPresent = false; bool saturated = true; result = SAPPHIRE_ANALYZER_RESULT.ERROR; try { for (int i = 0; i < _spectra.Count; i++) { if (!crPeaksPresent) { crPeaksPresent = CheckForCrPeaks(_spectra[i]); } if (saturated) { saturated = _spectra[i].IsSaturated(_sapphireAnalysisSettings.CR_SATURATION_START_WAVELEN, _sapphireAnalysisSettings.CR_SATURATION_END_WAVELEN); } } if (!crPeaksPresent) { result = SAPPHIRE_ANALYZER_RESULT.NONE; return(true); } if (saturated) { result = SAPPHIRE_ANALYZER_RESULT.SATURATED; return(true); } } catch (Exception ex) { } return(false); }
public SAPPHIRE_ANALYZER_RESULT TestNatural(out bool crPeaksPresentInAtLeaseOneSpectra, out bool noisyInAtLeastOneSpectra, out bool tiBandPresentInAllSpectra, out bool?crSaturated, out bool?_620_750_pass, out List <double> _620_750_ratios, out List <double> tiSlopeList) { SAPPHIRE_ANALYZER_RESULT result = SAPPHIRE_ANALYZER_RESULT.REFER; crSaturated = null; tiBandPresentInAllSpectra = true; tiSlopeList = new List <double>(); noisyInAtLeastOneSpectra = false; crPeaksPresentInAtLeaseOneSpectra = false; _620_750_pass = null; _620_750_ratios = new List <double>(); try { for (int i = 0; i < _spectra.Count; i++) { bool crPeaksPresentInThisSpectra = CheckForCrPeaks(_spectra[i]); if (!crPeaksPresentInAtLeaseOneSpectra) { crPeaksPresentInAtLeaseOneSpectra = crPeaksPresentInThisSpectra; } var line = new StraightLine(_spectra[i]); double tiSlope; bool badfit; var straightLine = line.Test(_sapphireAnalysisSettings.TI_BAND_START_WAVELEN, _sapphireAnalysisSettings.TI_BAND_END_WAVELEN, Math.Tan(_sapphireAnalysisSettings.TI_BAND_MAX_SLOPE_DEGREES * Math.PI / 180), Math.Tan(_sapphireAnalysisSettings.TI_BAND_MIN_SLOPE_DEGREES * Math.PI / 180), _sapphireAnalysisSettings.TI_BAND_MAX_STD_ERROR, out badfit, out tiSlope); if (!badfit && straightLine) { tiBandPresentInAllSpectra = false; if (crPeaksPresentInThisSpectra)//No Ti Band + Cr Peaks { return(SAPPHIRE_ANALYZER_RESULT.NATURAL_SAPPHIRE); } } else if (badfit) { noisyInAtLeastOneSpectra = true; } tiSlopeList.Add(Math.Atan(tiSlope) * 180 / Math.PI); _620_750_ratios.Add(GetYValue(_spectra[i].SpectrumData, _sapphireAnalysisSettings._620_WAVELEN) / GetYValue(_spectra[i].SpectrumData, _sapphireAnalysisSettings._750_WAVELEN)); } if (!crPeaksPresentInAtLeaseOneSpectra) { return(SAPPHIRE_ANALYZER_RESULT.REFER); } if (tiBandPresentInAllSpectra) { int _500msIndex = _integrationTimes.FindIndex(d => d == 500); if (_500msIndex == -1) { _500msIndex = 0; } crSaturated = _spectra[_500msIndex].IsSaturated(_sapphireAnalysisSettings.CR_SATURATION_START_WAVELEN, _sapphireAnalysisSettings.CR_SATURATION_END_WAVELEN); if (crSaturated == false) { result = SAPPHIRE_ANALYZER_RESULT.NATURAL_SAPPHIRE; } else { _620_750_pass = _620_750_ratios.Count(r => r > _sapphireAnalysisSettings._620_750_RATIO) == _620_750_ratios.Count; if (_620_750_pass == true) { result = SAPPHIRE_ANALYZER_RESULT.NATURAL_SAPPHIRE; } } } } catch (Exception ex) { result = SAPPHIRE_ANALYZER_RESULT.ERROR; } return(result); }