public override ReturnCode IngestFile(ChannelCompartment compartment, string fileName) { ReturnCode returnCode = spectrumParser.ParseSpectrumFile(fileName); Spectrum spectrum = spectrumParser.GetSpectrum(); DateTime time = spectrum.GetStartTime(); TimeSpan duration = TimeSpan.FromSeconds(spectrum.GetRealTime()); DataFile dataFile = new DataFile(fileName, time, time + duration); int counts = 0; for (int ch = 0; ch < spectrum.GetNChannels(); ch++) { counts += spectrum.GetCounts()[ch]; } channels[COUNT_RATE].AddDataPoint(compartment, time, counts / spectrum.GetLiveTime(), duration, dataFile); foreach (VirtualChannel chan in virtualChannels) { if (chan is ROIChannel) { ((ROIChannel)chan).AddDataPoint(compartment, time, spectrum, duration, dataFile); } } return(ReturnCode.SUCCESS); }
public ReturnCode Add(Spectrum spectrum) { if (spectrum.GetNChannels() != counts.Length) { return(ReturnCode.FAIL); } int[] otherCounts = spectrum.GetCounts(); for (int i = 0; i < counts.Length; i++) { counts[i] += otherCounts[i]; } realTime += spectrum.GetRealTime(); liveTime += spectrum.GetLiveTime(); return(ReturnCode.SUCCESS); }
public double GetROICounts(Spectrum spec) { int[] counts = spec.GetCounts(); double[] bins = spec.GetBins(); double totalCounts = 0; int roiBins = 0; double bg1Counts = 0; int bg1Bins = 0; double bg2Counts = 0; int bg2Bins = 0; for (int i = 0; i < bins.Length; i++) { if (bins[i] >= roiStart && bins[i] <= roiEnd) { totalCounts += counts[i]; roiBins++; } if (bins[i] >= bg1Start && bins[i] <= bg1End) { bg1Counts += counts[i]; bg1Bins++; } if (bins[i] >= bg2Start && bins[i] <= bg2End) { bg2Counts += counts[i]; bg2Bins++; } } switch (bgType) { case BG_Type.NONE: return(totalCounts); case BG_Type.FLAT: return(totalCounts - (bg1Counts * roiBins / bg1Bins)); case BG_Type.LINEAR: return(totalCounts - roiBins * ((bg1Counts / bg1Bins) + (bg2Counts / bg2Bins)) / 2); } return(0); }