//LORENTZ FITTING private void LorentzStartButton_Click(object sender, EventArgs e) { LorentzTimer.Start(); appSettings.isFitting = true; LorentzStopButton.Enabled = true; LorentzStartButton.Enabled = false; StartPeakTrackButton.Enabled = true; }
private void LorentzStopButton_Click(object sender, EventArgs e) { LorentzTimer.Stop(); FftChart.Series["Series2"].Points.Clear(); appSettings.isFitting = false; LorentzStartButton.Enabled = true; LorentzStopButton.Enabled = false; StartPeakTrackButton.Enabled = false; StopPeakTrackButton.PerformClick(); }
private void LorentzTimer_Tick(object sender, EventArgs e) { totalSW.Start(); Stopwatch fittingSW = new Stopwatch(); Stopwatch chartingSW = new Stopwatch(); bool canTrimFFT; bool isIterMessage = false; bool isTrimMessage = false; bool isGuessMessage = false; lorentzSettings.trimStartFreq = 0; lorentzSettings.trimStopFreq = plottableData.fftData.freq.Max(); // UpdateLorentzStartingPoints(); // get trim frequency from user try { lorentzSettings.trimStartFreq = double.Parse(trimStartFreqTextBox.Text); lorentzSettings.trimStopFreq = double.Parse(trimStopFreqTextBox.Text); canTrimFFT = true; } catch (Exception) { canTrimFFT = false; LorentzTimer.Stop(); StopWaveButton.PerformClick(); if (!isTrimMessage) { MessageBox.Show("The trimming frequency inputs are not doubles"); } isTrimMessage = true; } // get algo iterations from user try { lorentzSettings.nIter = int.Parse(IterTextBox.Text); } catch (Exception) { if (!isIterMessage) { MessageBox.Show("The LMA Algorithm iterations input is not an integer, a default value of 100 will be used"); } isIterMessage = true; lorentzSettings.nIter = 100; } // trim FFT array based on user specifications if (lorentzSettings.isTrimFft && canTrimFFT) { LorentzFftData = pM2WaveForm.TrimFFT(plottableData.fftData, lorentzSettings); } else { LorentzFftData = plottableData.fftData; } // get Lorentz parameters and update lorentz chart based if (plottableData.fftData != null) { fittingSW.Start(); pM2WaveForm.GetLorentzParams(LorentzFftData, lorentzSettings, ref lorentzParams); fittingSW.Stop(); chartingSW.Start(); UpdateLorenztCharts(); chartingSW.Stop(); } else { MessageBox.Show("Could not perform lorentzian fit. Please ensure you are reading data."); LorentzTimer.Stop(); LorentzStartButton.Enabled = true; LorentzStopButton.Enabled = false; } fittingSW.Start(); FittingMetrics = pM2WaveForm.GetFittingMetrics(lorentzParams, fftSettings); UpdateFittingMetricsDisplay(); fittingSW.Stop(); processTimes.fittingTime = fittingSW.Elapsed; chartingSW.Start(); if (appSettings.isPeakTracking) { UpdatePeakTrackerChart(); } chartingSW.Stop(); peakTrackTime += LorentzTimer.Interval / 1000; processTimes.freqPlottingTime = chartingSW.Elapsed; processTimes.fittingTime = fittingSW.Elapsed; FreqDomainPlottingTimeLabel.Text = "Frequency Domain Plotting (ms) = " + Convert.ToString(processTimes.freqPlottingTime.Milliseconds); LorentzianFittingTimeLabel.Text = "Lorentzian Fitting (ms) = " + Convert.ToString(processTimes.fittingTime.Seconds * 1e3 + processTimes.fittingTime.Milliseconds); totalSW.Stop(); }