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;
            }
        }
        public ISpectrum Transmit(ISpectrum gas, ISpectrum reference)
        {
            var transmit = new Complex[gas.Length()];

            for (var i = 0; i < gas.Length(); i++)
            {
                transmit[i] = gas.Array[i] / gas.PulseCount / (reference.Array[i] / reference.PulseCount);
            }
            return(new Spectrum(transmit, 1));
        }
Example #3
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 string[] ToStringArray([NotNull] this ISpectrum spectrum,
                                             Func <ISpectrum, int, string> toStringFunc)
        {
            var array = new string[spectrum.Length()];

            for (var i = 0; i < array.Length; i++)
            {
                array[i] = toStringFunc(spectrum, i);
            }
            return(array);
        }
Example #5
0
        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));
        }
 /// <summary>
 ///     Get the size of the data container
 /// </summary>
 /// <returns>The size of the data container</returns>
 public int Length()
 {
     return(_spectrum.Length());
 }