private void SetupRace() { if (!_resetIsRequired) { return; } StopTimer(); InitialiseVariables(); SetupProgressBar(); ResultsText.Clear(); _resetIsRequired = false; }
//////////////////////////////////////////////////////////////////////////////////////////////////// private void button1_Click(object sender, EventArgs e) { mTemperatureLines.Clear(); ResultsText.Clear(); chrTemperatureDistr.Series.Clear(); chrSahaBoltzmanPlot.Series.Clear(); int measurementNum = 0; foreach (var measurement in MainWindow.mExperiments) { if (measurement.mSpectra.Count == 0) { continue; } var line = new List<TemperaturePoint>(); mTemperatureLines.Add(line); string name = "Measurement " + measurementNum; chrTemperatureDistr.Series.Add(name); chrTemperatureDistr.Series[name].ChartType = SeriesChartType.FastLine; ResultsText.Text += "Measurement " + measurementNum + Environment.NewLine; int spectrumNumber = 0; foreach (var spec in measurement.mSpectra) { // get points in coordinates of [ E; ln(I/A*g) ] var points = GetLogPoints(spec); // plot points on Saha-Boltzman plane var distributionName = "Distribution " + spectrumNumber; LinePoint minPoint = points[0], maxPoint = points[0]; chrSahaBoltzmanPlot.Series.Add(distributionName); StreamWriter of = new StreamWriter(distributionName + ".bdp"); foreach (var p in points) { chrSahaBoltzmanPlot.Series[distributionName].Points.AddXY(Math.Round(p.mX,2), Math.Round(p.mY,2)); chrSahaBoltzmanPlot.Series[distributionName].ChartType = SeriesChartType.Point; of.WriteLine("P\t" + p.mX + "\t" + p.mY); if (p.mX > maxPoint.mX) { maxPoint = p; } if (p.mX < minPoint.mX) { minPoint = p; } } of.Close(); // do linear approximation to get slope from points, for further temperature calculation double a = 0.0f; double b = 0.0f; LinearApproximation(points, ref a, ref b); double slope = ComputeSlope(a, b); // plot approximation var approxName = "Approximation " + spectrumNumber; chrSahaBoltzmanPlot.Series.Add(approxName); chrSahaBoltzmanPlot.Series[approxName].Points.AddXY(Math.Round(minPoint.mX, 2), Math.Round(a * minPoint.mX + b, 2)); chrSahaBoltzmanPlot.Series[approxName].Points.AddXY(Math.Round(maxPoint.mX,2), Math.Round(a * maxPoint.mX + b, 2)); chrSahaBoltzmanPlot.Series[approxName].ChartType = SeriesChartType.FastLine; // calculate temperature using line slope double temperature = ComputeTemperature(slope); ResultsText.Text += "T: " + Math.Round(temperature, 2) + "; S: " + Math.Round(slope, 2) + Environment.NewLine; line.Add(new TemperaturePoint(temperature, a, b, slope, spec.mIntegrationDelayMicroSec)); chrTemperatureDistr.Series[name].Points.AddXY(Math.Round(spec.mIntegrationDelayMicroSec, 1), temperature); ++spectrumNumber; } ++measurementNum; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// private void ClearResults_Click(object sender, EventArgs e) { ResultsText.Clear(); }