public void SampleAverageAndSquare([NotNull] ISpectrum spec, double[] resultContainer)
        {
            var lo = GetIndexFromFreq(StartFreqInMHz, SampleRateInMHz, spec.Length());
            var hi = GetIndexFromFreq(EndFreqInMHz, SampleRateInMHz, spec.Length());



            var interval = (hi - lo) / (double)(DispPointsCnt - 1);

            /*if (interval < 1) {
             *  while (interval < 1) {
             *      var broader = (EndFreqInMHz - StartFreqInMHz)*0.05;
             *      SetStartFreq(StartFreqInMHz - broader);
             *      SetEndFreq(EndFreqInMHz + broader);
             *      lo = GetIndexFromFreq(StartFreqInMHz, SampleRateInMHz, spec.Length());
             *      hi = GetIndexFromFreq(EndFreqInMHz, SampleRateInMHz, spec.Length());
             *      interval = (hi - lo)/ (double)(DispPointsCnt - 1);
             *  }
             *  StartFreqInMHz = StartFreqInMHz;
             *  EndFreqInMHz = EndFreqInMHz;
             * }*/

            var    divider = spec.PulseCount * spec.PulseCount;
            double j       = lo;

            for (int i = 0; i < DispPointsCnt; i++, j += interval)
            {
                resultContainer[i] = spec.Intensity((int)Math.Round(j)) / divider;
            }
        }
Exemple #2
0
        private static double Average([NotNull] ISpectrum array)
        {
            double sum = 0;

            for (var i = 0; i < array.Length() / 2; i++)
            {
                sum += array.Intensity(i);
            }
            return(sum / array.PulseCount / array.PulseCount);
        }
        public static GasRefTuple EitherAndOther([NotNull] ISpectrum either, ISpectrum other)
        {
            double eitherSum = 0, otherSum = 0;

            for (var i = 0; i < either.Length(); i++)
            {
                eitherSum += either.Intensity(i);
                otherSum  += other.Intensity(i);
            }
            return(eitherSum >= otherSum
                ? SourceAndRef(either, other)
                : SourceAndRef(other, either));
        }
 public static string ToStringIntensity([NotNull] this ISpectrum spectrum, int index)
 {
     return(spectrum.Intensity(index).ToString());
 }
 /// <summary>
 ///     Get the intensity of the accumulated data at a specified index.
 /// </summary>
 /// <param name="index">The index of the data</param>
 /// <returns>The intensity at the input index</returns>
 public double Intensity(int index)
 {
     return(_spectrum.Intensity(index));
 }