Exemplo n.º 1
0
        public PhaseResult GetPhase(double[] pulseSequence)
        {
            var crestIndices = _finder.Find(pulseSequence);

            if (crestIndices.IsEmpty())
            {
                return(PhaseResult.FromException(ProcessException.NoPeakFound));
            }
            var sliceInfos = _slicer.Slice(pulseSequence, crestIndices);

            if (sliceInfos.IsEmpty())
            {
                return(PhaseResult.FromException(ProcessException.NoSliceValid));
            }
            var example = sliceInfos.First();
            var pulse   = _preprocessor.RetrievePulse(pulseSequence, example.StartIndex, example.CrestOffset,
                                                      example.Length);

            _rotator.TrySymmetrize(pulse, example.CrestOffset);
            double[] phase;
            try {
                phase = _phaseExtractor.GetPhase(pulse, null);
            } catch (PhaseFitException) {
                return(PhaseResult.FromException(ProcessException.NoFlatPhaseIntervalFound));
            }

            var unwrap = Functions.Unwrap(phase);

            return(PhaseResult.WithoutException(unwrap));
        }
Exemplo n.º 2
0
        public Complex[] Correct(double[] symmetryPulse)
        {
            if (_spectrumArray == null || _outputArray == null)
            {
                _spectrumArray = new Complex[symmetryPulse.Length];
                _outputArray   = new Complex[symmetryPulse.Length / 2];
            }

            _apodizer.Apodize(symmetryPulse);

            _rotator.Rotate(symmetryPulse);

            symmetryPulse.ToComplex(_spectrumArray);
            Fourier.Forward(_spectrumArray, FourierOptions.Matlab);

            double[] phaseArray;
            try {
                phaseArray = _phaseExtractor.GetPhase(symmetryPulse, _spectrumArray);
            } catch (PhaseFitException) {
                throw new CorrectFailException();
            }

            _synthesizer.Synthesize(_spectrumArray, phaseArray, _outputArray);


            return(_outputArray);
        }