public void TestAverageFirstBin() { Average.AverageAmplitude avgAmp = new Average.AverageAmplitude(); // Create an ensemble DataSet.Ensemble ens1 = EnsembleHelper.GenerateEnsemble(30); ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_0_INDEX] = 2; ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_1_INDEX] = 3; ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_2_INDEX] = 4; ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_3_INDEX] = 5; DataSet.Ensemble ens2 = EnsembleHelper.GenerateEnsemble(30); ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_0_INDEX] = 2; ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_1_INDEX] = 3; ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_2_INDEX] = 4; ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_3_INDEX] = 5; avgAmp.AddEnsemble(ens1); avgAmp.AddEnsemble(ens2); float[,] result = avgAmp.GetAverage(); Assert.IsNotNull(result, "Result is incorrect."); Assert.AreEqual(2, result[0, DataSet.Ensemble.BEAM_0_INDEX], "Bin 0 Beam 0 is incorrect."); Assert.AreEqual(3, result[0, DataSet.Ensemble.BEAM_1_INDEX], "Bin 0 Beam 1 is incorrect."); Assert.AreEqual(4, result[0, DataSet.Ensemble.BEAM_2_INDEX], "Bin 0 Beam 2 is incorrect."); Assert.AreEqual(5, result[0, DataSet.Ensemble.BEAM_3_INDEX], "Bin 0 Beam 3 is incorrect."); }
public void TestAverage() { Average.AverageAmplitude avgAmp = new Average.AverageAmplitude(); // Create an ensemble // All zeros for correlation DataSet.Ensemble ens1 = EnsembleHelper.GenerateEnsemble(30); DataSet.Ensemble ens2 = EnsembleHelper.GenerateEnsemble(30); avgAmp.AddEnsemble(ens1); avgAmp.AddEnsemble(ens2); float[,] result = avgAmp.GetAverage(); Assert.IsNotNull(result, "Result is incorrect."); Assert.AreEqual(0, result[0, DataSet.Ensemble.BEAM_0_INDEX], "Bin 0 Beam 0 is incorrect."); Assert.AreEqual(0, result[0, DataSet.Ensemble.BEAM_1_INDEX], "Bin 0 Beam 1 is incorrect."); Assert.AreEqual(0, result[0, DataSet.Ensemble.BEAM_2_INDEX], "Bin 0 Beam 2 is incorrect."); Assert.AreEqual(0, result[0, DataSet.Ensemble.BEAM_3_INDEX], "Bin 0 Beam 3 is incorrect."); }
public void TestRunningAverageNumSamples() { Average.AverageAmplitude avgAmp = new Average.AverageAmplitude(); avgAmp.NumSamples = 2; avgAmp.IsRunningAverage = true; // Create an ensemble DataSet.Ensemble ens1 = EnsembleHelper.GenerateEnsemble(30); ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_0_INDEX] = 2; ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_1_INDEX] = 3; ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_2_INDEX] = 4; ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_3_INDEX] = 5; DataSet.Ensemble ens2 = EnsembleHelper.GenerateEnsemble(30); ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_0_INDEX] = DataSet.Ensemble.BAD_VELOCITY; ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_1_INDEX] = DataSet.Ensemble.BAD_VELOCITY; ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_2_INDEX] = DataSet.Ensemble.BAD_VELOCITY; ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_3_INDEX] = DataSet.Ensemble.BAD_VELOCITY; DataSet.Ensemble ens3 = EnsembleHelper.GenerateEnsemble(30); ens3.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_0_INDEX] = 6; ens3.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_1_INDEX] = 7; ens3.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_2_INDEX] = 8; ens3.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_3_INDEX] = 9; avgAmp.AddEnsemble(ens1); avgAmp.AddEnsemble(ens2); avgAmp.AddEnsemble(ens3); float[,] result = avgAmp.GetAverage(); Assert.IsNotNull(result, "Result is incorrect."); Assert.AreEqual(4, result[0, DataSet.Ensemble.BEAM_0_INDEX], "Bin 0 Beam 0 is incorrect."); Assert.AreEqual(5, result[0, DataSet.Ensemble.BEAM_1_INDEX], "Bin 0 Beam 1 is incorrect."); Assert.AreEqual(6, result[0, DataSet.Ensemble.BEAM_2_INDEX], "Bin 0 Beam 2 is incorrect."); Assert.AreEqual(7, result[0, DataSet.Ensemble.BEAM_3_INDEX], "Bin 0 Beam 3 is incorrect."); }
public void TestAverageBadValue() { Average.AverageAmplitude avgAmp = new Average.AverageAmplitude(); // Create an ensemble DataSet.Ensemble ens1 = EnsembleHelper.GenerateEnsemble(30); ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_0_INDEX] = 2; ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_1_INDEX] = 3; ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_2_INDEX] = 4; ens1.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_3_INDEX] = 5; DataSet.Ensemble ens2 = EnsembleHelper.GenerateEnsemble(30); ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_0_INDEX] = DataSet.Ensemble.BAD_VELOCITY; ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_1_INDEX] = DataSet.Ensemble.BAD_VELOCITY; ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_2_INDEX] = DataSet.Ensemble.BAD_VELOCITY; ens2.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_3_INDEX] = DataSet.Ensemble.BAD_VELOCITY; avgAmp.AddEnsemble(ens1); avgAmp.AddEnsemble(ens2); float[,] result = avgAmp.GetAverage(); Assert.IsNotNull(result, "Result is incorrect."); Assert.AreEqual(2, result[0, DataSet.Ensemble.BEAM_0_INDEX], "Bin 0 Beam 0 is incorrect."); Assert.AreEqual(3, result[0, DataSet.Ensemble.BEAM_1_INDEX], "Bin 0 Beam 1 is incorrect."); Assert.AreEqual(4, result[0, DataSet.Ensemble.BEAM_2_INDEX], "Bin 0 Beam 2 is incorrect."); Assert.AreEqual(5, result[0, DataSet.Ensemble.BEAM_3_INDEX], "Bin 0 Beam 3 is incorrect."); }