/// <summary>
        /// Calculates the Full Width at Half Max related values
        /// </summary>
        /// <param name="fullWidthHalfMaxPercent">(Optional) The threshold of where to measure the FWHM as a percent of the peak current (Default: 50%)</param>
        private void CalculateFullWidthAtHalfMax(double fullWidthHalfMaxPercent = 0.5)
        {
            if (fullWidthHalfMaxPercent <= 0.0 || fullWidthHalfMaxPercent >= 1.0)
            {
                throw new ArgumentOutOfRangeException("The Full Width Half Max Percentage cannot be less than or equal to 0% or greater than or equal to 100%");
            }

            // Calculate what the half-max current value is (default is 50% of max amplitude)
            double fullWidthHalfMaxCurrentSigned   = this.PeakCurrentValue * fullWidthHalfMaxPercent;
            double fullWidthHalfMaxCurrentAbsolute = fullWidthHalfMaxCurrentSigned.InvertValueIfNegativePolarity(this.WaveformIsPositivePolarity);

            // Find the first (interpolated) data point that is on the rising edge of the initial spike (of the absolute value waveform)
            DataPoint?fullWidthHalfMaxRisingAbsoluteDataPoint = this.AbsoluteWaveform.DataPointAtYThreshold(fullWidthHalfMaxCurrentAbsolute, true);

            if (fullWidthHalfMaxRisingAbsoluteDataPoint.HasValue)
            {
                // Convert the rising data point to the signed value
                this.FullWidthHalfMaxStartDataPoint = fullWidthHalfMaxRisingAbsoluteDataPoint.Value.InvertYValueIfNegativePolarity(this.WaveformIsPositivePolarity);

                // Trim the waveform, removing everything before the max peak
                Waveform absoluteWaveformAfterPeakCurrentTime = this.AbsoluteWaveform.TrimStart(this.PeakCurrentDataPoint.X);

                // Find the first (interpolated) data point that is on the falling edge of the initial spike (of the absolute value waveform)
                DataPoint?fullWidthHalfMaxFallingDataPointAbsolute = absoluteWaveformAfterPeakCurrentTime.DataPointAtYThreshold(fullWidthHalfMaxCurrentAbsolute, true);

                if (fullWidthHalfMaxFallingDataPointAbsolute.HasValue)
                {
                    // Convert the falling data point to the signed value
                    this.FullWidthHalfMaxEndDataPoint = fullWidthHalfMaxFallingDataPointAbsolute.Value.InvertYValueIfNegativePolarity(this.WaveformIsPositivePolarity);

                    // Find the full width half max time
                    this.FullWidthHalfMaxValue = this.FullWidthHalfMaxEndDataPoint.X - this.FullWidthHalfMaxStartDataPoint.X;

                    // Determine the min and max values for the Full Width Half Max to be passing
                    Tuple <double, double, double> nomMinMaxFullWidthHalfMax = CDMJS002WaveformCharacteristics.FullWidthHalfMaxNominalMinMax(this.SignedVoltage, this.IsLargeTarget, this.OscilloscopeIsHighBandwidth);
                    this.FullWidthHalfMaxAllowedMinimum = nomMinMaxFullWidthHalfMax.Item2;
                    this.FullWidthHalfMaxAllowedMaximum = nomMinMaxFullWidthHalfMax.Item3;

                    // Determine if the Full Width Half Max is passing
                    this.FullWidthHalfMaxIsPassing = DoubleRangeExtensions.BetweenInclusive(this.FullWidthHalfMaxAllowedMinimum, this.FullWidthHalfMaxAllowedMaximum, this.FullWidthHalfMaxValue);
                }
                else
                {
                    // Full Width Half Max falling data point could not be found, no calculations could be made.
                }
            }
            else
            {
                // Full Width Half Max rising data point could not be found, no calculations could be made.
            }
        }
        /// <summary>
        /// Calculates the Peak Current (Ips) related values
        /// </summary>
        private void CalculatePeakCurrent()
        {
            // Calculate the (absolute) Peak Current DataPoint
            DataPoint absolutePeakCurrentDataPoint = this.AbsoluteWaveform.Maximum();

            // Convert to the signed Peak Current DataPoint
            this.PeakCurrentDataPoint = absolutePeakCurrentDataPoint.InvertYValueIfNegativePolarity(this.WaveformIsPositivePolarity);

            // Extract the Peak Current value
            this.PeakCurrentValue = this.PeakCurrentDataPoint.Y;

            // Determine the min and max allowed values for the Peak Current to be passing
            Tuple <double, double, double> nomMinMaxPeakCurrent = HBM500OhmJS001WaveformCharacteristics.HBMPeakCurrentNominalMinMax(this.SignedVoltage);

            this.PeakCurrentAllowedMinimum = nomMinMaxPeakCurrent.Item2.InvertValueIfNegativePolarity(this.WaveformIsPositivePolarity);
            this.PeakCurrentAllowedMaximum = nomMinMaxPeakCurrent.Item3.InvertValueIfNegativePolarity(this.WaveformIsPositivePolarity);

            // Determine if the Peak Current is passing
            this.PeakCurrentIsPassing = DoubleRangeExtensions.BetweenInclusive(this.PeakCurrentAllowedMinimum, this.PeakCurrentAllowedMaximum, this.PeakCurrentValue);
        }
예제 #3
0
        /// <summary>
        /// Calculates the Peak Current (Ips) related values
        /// </summary>
        private void CalculatePeakCurrent()
        {
            // Calculate the (absolute) Max Current DataPoint
            DataPoint ipsMaxAbsoluteDataPoint = this.IpsMaxDataPoint.InvertYValueIfNegativePolarity(this.WaveformIsPositivePolarity);

            // Determine Ips by evaluating the ips Polynomial at the IpsMax time
            double ipsAbsoluteValue = this.AbsoluteIpsPolynomial.Evaluate(ipsMaxAbsoluteDataPoint.X);

            // Determine the Peak Current (Ips) value
            this.PeakCurrentValue = ipsAbsoluteValue.InvertValueIfNegativePolarity(this.WaveformIsPositivePolarity);

            // Create a DataPoint at the time of Ips with the Ips value
            this.PeakCurrentDataPoint = new DataPoint(ipsMaxAbsoluteDataPoint.X, this.PeakCurrentValue);

            // Determine the min and max allowed values for the Peak Current to be passing
            Tuple <double, double, double> nomMinMaxPeakCurrent = HBM0OhmJS001WaveformCharacteristics.HBMPeakCurrentNominalMinMax(this.SignedVoltage);

            this.PeakCurrentAllowedMinimum = nomMinMaxPeakCurrent.Item2.InvertValueIfNegativePolarity(this.WaveformIsPositivePolarity);
            this.PeakCurrentAllowedMaximum = nomMinMaxPeakCurrent.Item3.InvertValueIfNegativePolarity(this.WaveformIsPositivePolarity);

            // Determine if the Peak Current is passing
            this.PeakCurrentIsPassing = DoubleRangeExtensions.BetweenInclusive(this.PeakCurrentAllowedMinimum, this.PeakCurrentAllowedMaximum, this.PeakCurrentValue);
        }
        /// <summary>
        /// Calculates the Peak Current related values
        /// </summary>
        /// <param name="pointsAroundPeakToAverage">Number of points around the absolute peak to average together (Default: 0)</param>
        private void CalculatePeakCurrent(int pointsAroundPeakToAverage)
        {
            // Calculate the (absolute) Peak Current DataPoint
            DataPoint absolutePeakCurrentDataPoint = this.AbsoluteWaveform.Maximum();

            List <DataPoint> absWfmDataPoints = this.AbsoluteWaveform.DataPoints.ToList();
            int peakIndex      = absWfmDataPoints.IndexOf(absolutePeakCurrentDataPoint);
            int peakStartIndex = Math.Max(0, peakIndex - pointsAroundPeakToAverage);
            int peakStopIndex  = Math.Min(absWfmDataPoints.Count - 1, peakIndex + pointsAroundPeakToAverage);
            List <DataPoint> peakDataPoints = new List <DataPoint>();

            for (int i = peakStartIndex; i <= peakStopIndex; i++)
            {
                peakDataPoints.Add(absWfmDataPoints[i]);
            }

            Waveform peakWaveform = new Waveform(peakDataPoints);
            double   peakCurrent  = peakWaveform.Average();

            if (!this.WaveformIsPositivePolarity)
            {
                peakCurrent *= -1.0;
            }

            // Extract the Peak Current value
            this.PeakCurrentValue     = peakCurrent;
            this.PeakCurrentDataPoint = new DataPoint(absolutePeakCurrentDataPoint.X, peakCurrent);

            // Determine the min and max allowed values for the Peak Current to be passing
            Tuple <double, double, double> nomMinMaxPeakCurrent = CDMJS002WaveformCharacteristics.PeakCurrentNominalMinMax(this.SignedVoltage, this.IsLargeTarget, this.OscilloscopeIsHighBandwidth);

            this.PeakCurrentAllowedMinimum = nomMinMaxPeakCurrent.Item2.InvertValueIfNegativePolarity(this.WaveformIsPositivePolarity);
            this.PeakCurrentAllowedMaximum = nomMinMaxPeakCurrent.Item3.InvertValueIfNegativePolarity(this.WaveformIsPositivePolarity);

            // Determine if the Peak Current is passing
            this.PeakCurrentIsPassing = DoubleRangeExtensions.BetweenInclusive(this.PeakCurrentAllowedMinimum, this.PeakCurrentAllowedMaximum, this.PeakCurrentValue);
        }
예제 #5
0
        /// <summary>
        /// Calculates the Decay Time related values
        /// </summary>
        private void CalculateDecayTime()
        {
            // The percentage of the Peak Current to be the end of the decay time (1/e)
            double decayTimeEndPercentOfIps = 1.0 / System.Math.E;

            // Trim the waveform, removing everything before the max peak
            Waveform absoluteWaveformAfterPeakCurrentTime = this.AbsoluteWaveform.TrimStart(this.PeakCurrentDataPoint.X);

            // Find the start/stop times for the noise-reducing exponential fit waveform
            DataPoint?expFitStartDataPoint = absoluteWaveformAfterPeakCurrentTime.DataPointAtYThreshold(0.5 * System.Math.Abs(this.PeakCurrentValue), true);

            if (expFitStartDataPoint.HasValue)
            {
                double    expFitStartTimeThreshold = expFitStartDataPoint.Value.X;
                DataPoint?expFitEndDataPoint       = absoluteWaveformAfterPeakCurrentTime.DataPointAtYThreshold(0.3 * System.Math.Abs(this.PeakCurrentValue), true);

                // The waveform was truncated before the lower end of the decaying region,
                // however there might be enough data to calculate by using the last data point instead.
                if (!expFitEndDataPoint.HasValue)
                {
                    expFitEndDataPoint = absoluteWaveformAfterPeakCurrentTime.DataPoints.Last();
                }

                double expFitEndTimeThreshold = expFitEndDataPoint.Value.X;

                // Gate the waveform to just the area for the noise-reducing exponential fit waveform
                Waveform absoluteWaveformDecayingRegion = this.AbsoluteWaveform.Gates(expFitStartTimeThreshold, expFitEndTimeThreshold);

                if (absoluteWaveformDecayingRegion.DataPoints.Any())
                {
                    // Find the exponential fit constants of the waveform from 0.5 * Ips to 0.3 * Ips to eliminate noise
                    Tuple <double, double> expFitAbsoluteWaveformDecayingRegionConstants = absoluteWaveformDecayingRegion.ExponentialFit();

                    // Create time values that go out far enough to ensure the decay time end threshold can be found
                    List <double> timeValues   = (from dp in absoluteWaveformDecayingRegion.DataPoints select dp.X).ToList();
                    double        samplingTime = absoluteWaveformDecayingRegion.SamplingTime();
                    while (timeValues.Last() < 0.000000800 && samplingTime > 0)
                    {
                        timeValues.Add(timeValues.Last() + samplingTime);
                    }

                    // Create the exponential fit equivalent waveform which has noise eliminated
                    Waveform expFitAbsoluteWaveformDecayingRegion = WaveformExtensions.CreateExponentialFitWaveform(
                        expFitAbsoluteWaveformDecayingRegionConstants.Item1,
                        expFitAbsoluteWaveformDecayingRegionConstants.Item2,
                        timeValues);

                    // Calculate what the decay time end threshold is (1/e % of Ips)
                    double decayTimeEndThreshold = System.Math.Abs(this.PeakCurrentValue) * decayTimeEndPercentOfIps;

                    // Find the first (interpolated) data point that is at 1/e % of Ips value (of the absolute value waveform)
                    DataPoint?decayTimeEndDataPointAbsolute = expFitAbsoluteWaveformDecayingRegion.DataPointAtYThreshold(decayTimeEndThreshold, true);

                    if (decayTimeEndDataPointAbsolute.HasValue)
                    {
                        // Convert the Decay Time end DataPoint to the signed value
                        this.DecayTimeEndDataPoint = decayTimeEndDataPointAbsolute.Value.InvertYValueIfNegativePolarity(this.WaveformIsPositivePolarity);

                        // Calculate the Decay Time
                        this.DecayTimeValue = this.DecayTimeEndDataPoint.X - this.PeakCurrentDataPoint.X;

                        // Determine if the Decay Time is passing
                        this.DecayTimeIsPassing = DoubleRangeExtensions.BetweenInclusive(this.DecayTimeAllowedMinimum, this.DecayTimeAllowedMaximum, this.DecayTimeValue);
                    }
                    else
                    {
                        // The derived exponential fit waveform didn't go out to a far enough time to capture the 1/e time.
                    }
                }
                else
                {
                    // Could not find any data points in the decay time window.  Likely due to a malformed waveform.
                }
            }
            else
            {
                // Since the waveform was truncated before even the start of the window to calculate the decaying region, the decay time cannot be calculated.
            }
        }
예제 #6
0
        /// <summary>
        /// Calculates the Rise Time related values
        /// </summary>
        /// <param name="riseTimeStartPercent">Rise Time starting percentage (Default: 90%)</param>
        /// <param name="riseTimeEndPercent">Rise Time ending percentage (Default: 10%)</param>
        private void CalculateRiseTime(double riseTimeStartPercent, double riseTimeEndPercent)
        {
            if (riseTimeStartPercent < 0.0 || riseTimeStartPercent >= 1.0)
            {
                throw new ArgumentOutOfRangeException("The Rise Time Start % cannot be less than 0% or greater than or equal to 100%");
            }

            if (riseTimeEndPercent <= 0.0 || riseTimeEndPercent > 1.0)
            {
                throw new ArgumentOutOfRangeException("The Rise Time End % cannot be less than or equal to 0% or greater than 100%");
            }

            if (riseTimeStartPercent >= riseTimeEndPercent)
            {
                throw new ArgumentOutOfRangeException("The Rise Time Start % cannot be equal to or greater than the Rise Time End %");
            }

            // Generate an absolute-value version of the peak current value
            double peakCurrentAbsoluteValue = this.PeakCurrentValue.InvertValueIfNegativePolarity(this.WaveformIsPositivePolarity);

            // Calculate what the rise time end threshold is (a percentage of peak current)
            double riseTimeEndThreshold = peakCurrentAbsoluteValue * riseTimeEndPercent;

            // Find the first (interpolated) data point that is at the rise time end threshold (of the absolute value waveform)
            DataPoint?riseTimeEndAbsoluteDataPoint = this.AbsoluteWaveform.DataPointAtYThreshold(riseTimeEndThreshold, true);

            if (riseTimeEndAbsoluteDataPoint.HasValue)
            {
                // Convert the first Rise Time Data Point to the signed value
                this.RiseTimeEndDataPoint = riseTimeEndAbsoluteDataPoint.Value.InvertYValueIfNegativePolarity(this.WaveformIsPositivePolarity);

                // Trim the waveform, removing everything after the Rise Time End Time
                Waveform absoluteWaveformUntilRiseTimeEnd = this.AbsoluteWaveform.TrimEnd(this.RiseTimeEndDataPoint.X);

                // Calculate what the Rise Time Start Threshold is (a percentage of peak current)
                double riseTimeStartThreshold = peakCurrentAbsoluteValue * riseTimeStartPercent;

                // Find the last Data Point (interpolated) Data Point that is below the Rise Time Start Threshold (of the absolute trimmed waveform)
                DataPoint?riseTimeStartAbsoluteDataPoint = absoluteWaveformUntilRiseTimeEnd.DataPointAtYThreshold(riseTimeStartThreshold, false);

                if (riseTimeStartAbsoluteDataPoint.HasValue)
                {
                    // Convert the last Rise Time Data Point to the signed value
                    this.RiseTimeStartDataPoint = riseTimeStartAbsoluteDataPoint.Value.InvertYValueIfNegativePolarity(this.WaveformIsPositivePolarity);

                    // Find the Rise Time
                    this.RiseTimeValue = this.RiseTimeEndDataPoint.X - this.RiseTimeStartDataPoint.X;

                    // Determine if the Rise Time is passing
                    this.RiseTimeIsPassing = DoubleRangeExtensions.BetweenInclusive(this.RiseTimeAllowedMinimum, this.RiseTimeAllowedMaximum, this.RiseTimeValue);
                }
                else
                {
                    // Risetime start data point could not be found, no calculations could be made.
                }
            }
            else
            {
                // Risetime end data point could not be found, no calculations could be made.
            }
        }