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 TestAverageBadValue() { Average.AverageCorrelation avgCorr = new Average.AverageCorrelation(); // Create an ensemble DataSet.Ensemble ens1 = EnsembleHelper.GenerateEnsemble(30); ens1.CorrelationData.CorrelationData[0, DataSet.Ensemble.BEAM_0_INDEX] = 2; ens1.CorrelationData.CorrelationData[0, DataSet.Ensemble.BEAM_1_INDEX] = 3; ens1.CorrelationData.CorrelationData[0, DataSet.Ensemble.BEAM_2_INDEX] = 4; ens1.CorrelationData.CorrelationData[0, DataSet.Ensemble.BEAM_3_INDEX] = 5; DataSet.Ensemble ens2 = EnsembleHelper.GenerateEnsemble(30); ens2.CorrelationData.CorrelationData[0, DataSet.Ensemble.BEAM_0_INDEX] = DataSet.Ensemble.BAD_VELOCITY; ens2.CorrelationData.CorrelationData[0, DataSet.Ensemble.BEAM_1_INDEX] = DataSet.Ensemble.BAD_VELOCITY; ens2.CorrelationData.CorrelationData[0, DataSet.Ensemble.BEAM_2_INDEX] = DataSet.Ensemble.BAD_VELOCITY; ens2.CorrelationData.CorrelationData[0, DataSet.Ensemble.BEAM_3_INDEX] = DataSet.Ensemble.BAD_VELOCITY; avgCorr.AddEnsemble(ens1); avgCorr.AddEnsemble(ens2); float[,] result = avgCorr.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 TestScreenEqual() { int bins = 10; // Generate ensemble with blank data DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(bins); // Populate the data for (int bin = 0; bin < bins; bin++) { ensemble.EarthVelocityData.EarthVelocityData[bin, DataSet.Ensemble.BEAM_EAST_INDEX] = 0.1f; ensemble.EarthVelocityData.EarthVelocityData[bin, DataSet.Ensemble.BEAM_NORTH_INDEX] = 0.2f; ensemble.EarthVelocityData.EarthVelocityData[bin, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.01f; ensemble.EarthVelocityData.EarthVelocityData[bin, DataSet.Ensemble.BEAM_Q_INDEX] = 0.0f; } // Make some high Error Velocities int badBin = (int)bins / 2; ensemble.EarthVelocityData.EarthVelocityData[badBin, DataSet.Ensemble.BEAM_Q_INDEX] = 1.0f; // Screen the ensemble ScreenData.ScreenErrorVelocityThreshold.Screen(ref ensemble, 1.0f); Assert.AreEqual(0.1f, ensemble.EarthVelocityData.EarthVelocityData[0, DataSet.Ensemble.BEAM_EAST_INDEX], 0.0001, "East Velocity for Good is incorrect."); Assert.AreEqual(0.2f, ensemble.EarthVelocityData.EarthVelocityData[0, DataSet.Ensemble.BEAM_NORTH_INDEX], 0.0001, "North Velocity for Good is incorrect."); Assert.AreEqual(0.01f, ensemble.EarthVelocityData.EarthVelocityData[0, DataSet.Ensemble.BEAM_VERTICAL_INDEX], 0.0001, "Veritcal Velocity for Good is incorrect."); Assert.AreEqual(0.0f, ensemble.EarthVelocityData.EarthVelocityData[0, DataSet.Ensemble.BEAM_Q_INDEX], 0.0001, "Q Velocity for Good is incorrect."); Assert.AreEqual(DataSet.Ensemble.BAD_VELOCITY, ensemble.EarthVelocityData.EarthVelocityData[badBin, DataSet.Ensemble.BEAM_EAST_INDEX], 0.0001, "East Velocity for Bad is incorrect."); Assert.AreEqual(DataSet.Ensemble.BAD_VELOCITY, ensemble.EarthVelocityData.EarthVelocityData[badBin, DataSet.Ensemble.BEAM_NORTH_INDEX], 0.0001, "North Velocity for Bad is incorrect."); Assert.AreEqual(DataSet.Ensemble.BAD_VELOCITY, ensemble.EarthVelocityData.EarthVelocityData[badBin, DataSet.Ensemble.BEAM_VERTICAL_INDEX], 0.0001, "Veritcal Velocity for Bad is incorrect."); Assert.AreEqual(DataSet.Ensemble.BAD_VELOCITY, ensemble.EarthVelocityData.EarthVelocityData[badBin, DataSet.Ensemble.BEAM_Q_INDEX], 0.0001, "Q Velocity for Bad is incorrect."); }
public void TestTiming() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); Stopwatch watch = new Stopwatch(); // Test Serialize() watch = new Stopwatch(); watch.Start(); for (int x = 0; x < 1000; x++) { string encoded = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.InstrumentVelocityData); } watch.Stop(); long resultSerialize = watch.ElapsedMilliseconds; // Test Deserialize() string encodedd = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.InstrumentVelocityData); watch = new Stopwatch(); watch.Start(); for (int x = 0; x < 1000; x++) { DataSet.InstrumentVelocityDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.InstrumentVelocityDataSet>(encodedd); } watch.Stop(); long resultDeserialize = watch.ElapsedMilliseconds; Debug.WriteLine(String.Format("Serialize:{0} Deserialize:{1}", resultSerialize, resultDeserialize)); Debug.WriteLine("Complete"); }
public void TestCloneEnsembleDataSet() { DataSet.Ensemble ensemble = new DataSet.Ensemble(); EnsembleHelper.AddEnsemble(ref ensemble, 20); ensemble.EnsembleData.EnsembleNumber = 22; DataSet.Ensemble clone = ensemble.Clone(); Assert.AreEqual(22, ensemble.EnsembleData.EnsembleNumber, "Ensemble Number is incorrect."); Assert.AreEqual(22, clone.EnsembleData.EnsembleNumber, "Cloned Ensemble Number is incorrect."); }
public void TestClone() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); ensemble.EnsembleData.EnsembleNumber = 22; DataSet.Ensemble clone = ensemble.Clone(); Assert.AreEqual(22, ensemble.EnsembleData.EnsembleNumber, "Ensemble Number is incorrect."); Assert.AreEqual(22, clone.EnsembleData.EnsembleNumber, "Cloned Ensemble Number is incorrect."); }
public void TestTiming() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); Stopwatch watch = new Stopwatch(); //// Test ToJson() //watch.Start(); //for (int x = 0; x < 1000; x++) //{ // string encodedAmp = ensemble.BeamVelocityData.ToJson(); //} //watch.Stop(); //long resultToJson = watch.ElapsedMilliseconds; // Test Serialize() watch = new Stopwatch(); watch.Start(); for (int x = 0; x < 1000; x++) { string encoded = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.BeamVelocityData); } watch.Stop(); long resultSerialize = watch.ElapsedMilliseconds; //// Test JSON Constructor string encodedd = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.BeamVelocityData); //watch = new Stopwatch(); //watch.Start(); //for (int x = 0; x < 1000; x++) //{ // DataSet.AmplitudeDataSet decodedAmp = new DataSet.AmplitudeDataSet(encodedAmpp); //} //watch.Stop(); //long resultJsonConstructor = watch.ElapsedMilliseconds; // Test Deserialize() watch = new Stopwatch(); watch.Start(); for (int x = 0; x < 1000; x++) { DataSet.BeamVelocityDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.BeamVelocityDataSet>(encodedd); } watch.Stop(); long resultDeserialize = watch.ElapsedMilliseconds; Debug.WriteLine(String.Format("Serialize:{0} Deserialize:{1}", resultSerialize, resultDeserialize)); Debug.WriteLine("Complete"); }
public void DecodeRtiTest() { DataSet.Ensemble ens = EnsembleHelper.GenerateEnsemble(30); PD0 pd0 = new PD0(ens, PD0.CoordinateTransforms.Coord_Earth); Assert.IsTrue(pd0.IsVelocityExist, "IsVelocityExist is incorrect."); Assert.IsTrue(pd0.IsCorrelationExist, "IsCorrelationExist is incorrect."); Assert.IsTrue(pd0.IsEchoIntensityExist, "IsEchoIntensityExist is incorrect."); Assert.IsTrue(pd0.IsPercentGoodExist, "IsPercentGoodExist is incorrect."); Assert.IsTrue(pd0.IsBottomTrackExist, "IsBottomTrackExist is incorrect."); Assert.AreEqual(30, pd0.FixedLeader.NumberOfCells, "Number of cells is incorrect."); Assert.AreEqual(4, pd0.FixedLeader.NumberOfBeams, "Number of beams is incorrect."); Assert.AreEqual(PD0.CoordinateTransforms.Coord_Earth, pd0.FixedLeader.GetCoordinateTransform(), "Coordinate Transform is incorrect."); }
public void TestJson() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); // Modify the data string nmeaData = "$HEHDT,274.67,T*1F$HEROT,-32.6,A*31$GPGGA,155339.00,3245.44007,N,11719.83271,W,2,09,0.9,-1.1,M,-33.3,M,5.0,0138*50$GPVTG,277.26,T,265.15,M,2.62,N,4.86,K,D*29$GPZDA,155339.00,08,12,2011,00,00*67$GPGSV,3,1,09,02,75,182,50,04,56,053,51,05,08,167,42,09,50,241,48*75$GPGSV,3,2,09,10,24,111,46,12,45,322,47,17,17,063,45,25,15,313,44*71$GPGSV,3,3,09,28,05,121,36,,,,,,,,,,,,*48"; ensemble.AddNmeaData(nmeaData); Assert.IsNotNull(ensemble, "Adcp Data was not properly created."); Assert.IsTrue(ensemble.IsNmeaAvail, "Nmea Dataset not created."); Assert.IsTrue(ensemble.NmeaData.IsGpggaAvail(), "GGA message not parsed correctly."); Assert.IsTrue(ensemble.NmeaData.IsGpvtgAvail(), "VTG message not parsed correctly."); Assert.IsTrue(ensemble.NmeaData.IsGpgsvAvail(), "GSV message not parsed correctly."); Assert.IsFalse(ensemble.NmeaData.IsGpgllAvail(), "GLL message should not have been found."); Assert.IsFalse(ensemble.NmeaData.IsGpgsaAvail(), "GSA message should not have been found."); Assert.IsFalse(ensemble.NmeaData.IsGprmcAvail(), "RMC message should not have been found."); Assert.IsFalse(ensemble.NmeaData.IsPgrmfAvail(), "PGRMF message should not have been found."); Assert.AreEqual(new DotSpatial.Positioning.Latitude("32 45.44007").DecimalDegrees, ensemble.NmeaData.GPGGA.Position.Latitude.DecimalDegrees, 0.0001, "Latitude is not correct"); Assert.AreEqual(new DotSpatial.Positioning.Latitude("-117 19.83271").DecimalDegrees, ensemble.NmeaData.GPGGA.Position.Longitude.DecimalDegrees, 0.0001, "Longitude is not correct"); Assert.AreEqual(DotSpatial.Positioning.FixQuality.DifferentialGpsFix, ensemble.NmeaData.GPGGA.FixQuality, "Fix Quality is not correct"); Assert.AreEqual(9, ensemble.NmeaData.GPGGA.FixedSatelliteCount, "Number of fixed satellites is incorrect."); Assert.AreEqual(new DotSpatial.Positioning.Distance(-1.1, DotSpatial.Positioning.DistanceUnit.Meters).Value, ensemble.NmeaData.GPGGA.Altitude.Value, 0.00001, "Altitude is not correct"); Assert.AreEqual(new DotSpatial.Positioning.Azimuth(277.26), ensemble.NmeaData.GPVTG.Bearing, "True Track Made Good Bearing not correct."); Assert.AreEqual(new DotSpatial.Positioning.Speed(2.62, DotSpatial.Positioning.SpeedUnit.Knots), ensemble.NmeaData.GPVTG.Speed, "Speed is not correct."); string encoded = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.NmeaData); // Serialize object to JSON DataSet.NmeaDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.NmeaDataSet>(encoded); // Deserialize the JSON // Verify the values are the same Assert.IsTrue(decoded.IsGpggaAvail(), "GGA message not parsed correctly."); Assert.IsTrue(decoded.IsGpvtgAvail(), "VTG message not parsed correctly."); Assert.IsTrue(decoded.IsGpgsvAvail(), "GSV message not parsed correctly."); Assert.IsFalse(decoded.IsGpgllAvail(), "GLL message should not have been found."); Assert.IsFalse(decoded.IsGpgsaAvail(), "GSA message should not have been found."); Assert.IsFalse(decoded.IsGprmcAvail(), "RMC message should not have been found."); Assert.IsFalse(decoded.IsPgrmfAvail(), "PGRMF message should not have been found."); Assert.AreEqual(new DotSpatial.Positioning.Latitude("32 45.44007").DecimalDegrees, decoded.GPGGA.Position.Latitude.DecimalDegrees, 0.0001, "Latitude is not correct"); Assert.AreEqual(new DotSpatial.Positioning.Latitude("-117 19.83271").DecimalDegrees, decoded.GPGGA.Position.Longitude.DecimalDegrees, 0.0001, "Longitude is not correct"); Assert.AreEqual(DotSpatial.Positioning.FixQuality.DifferentialGpsFix, decoded.GPGGA.FixQuality, "Fix Quality is not correct"); Assert.AreEqual(9, decoded.GPGGA.FixedSatelliteCount, "Number of fixed satellites is incorrect."); Assert.AreEqual(new DotSpatial.Positioning.Distance(-1.1, DotSpatial.Positioning.DistanceUnit.Meters).Value, decoded.GPGGA.Altitude.Value, 0.00001, "Altitude is not correct"); Assert.AreEqual(new DotSpatial.Positioning.Azimuth(277.26), decoded.GPVTG.Bearing, "True Track Made Good Bearing not correct."); Assert.AreEqual(new DotSpatial.Positioning.Speed(2.62, DotSpatial.Positioning.SpeedUnit.Knots), decoded.GPVTG.Speed, "Speed is not correct."); }
public void TestScreenNoBad() { // Create an ensemble with 30 bins DataSet.Ensemble ens = EnsembleHelper.GenerateEnsemble(30); ens.BottomTrackData.Range[DataSet.Ensemble.BEAM_0_INDEX] = 12.34f; ens.BottomTrackData.Range[DataSet.Ensemble.BEAM_1_INDEX] = 12.45f; ens.BottomTrackData.Range[DataSet.Ensemble.BEAM_2_INDEX] = 12.56f; ens.BottomTrackData.Range[DataSet.Ensemble.BEAM_3_INDEX] = 12.78f; ScreenData.ScreenBottomTrackRange.ScreenBottomTrackRangeResult result = ScreenData.ScreenBottomTrackRange.Screen(ref ens); Assert.AreEqual(12.34f, ens.BottomTrackData.Range[DataSet.Ensemble.BEAM_0_INDEX], "Range 0 is incorrect."); Assert.AreEqual(12.45f, ens.BottomTrackData.Range[DataSet.Ensemble.BEAM_1_INDEX], "Range 1 is incorrect."); Assert.AreEqual(12.56f, ens.BottomTrackData.Range[DataSet.Ensemble.BEAM_2_INDEX], "Range 2 is incorrect."); Assert.AreEqual(12.78f, ens.BottomTrackData.Range[DataSet.Ensemble.BEAM_3_INDEX], "Range 3 is incorrect."); }
public void AddEnsembles() { ReferenceLayerAverage avger = new ReferenceLayerAverage(2, 0, 3, false); // Create an ensemble // All zeros for correlation DataSet.Ensemble ens1 = EnsembleHelper.GenerateEnsemble(30); DataSet.Ensemble ens2 = EnsembleHelper.GenerateEnsemble(30); avger.AddEnsemble(ens1); avger.AddEnsemble(ens2); float[,] result = avger.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 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 TestJson() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); // Modify the data ensemble.InstrumentVelocityData.InstrumentVelocityData[0, DataSet.Ensemble.BEAM_0_INDEX] = 1.2f; ensemble.InstrumentVelocityData.InstrumentVelocityData[0, DataSet.Ensemble.BEAM_1_INDEX] = 2.3f; ensemble.InstrumentVelocityData.InstrumentVelocityData[0, DataSet.Ensemble.BEAM_2_INDEX] = 3.4f; ensemble.InstrumentVelocityData.InstrumentVelocityData[0, DataSet.Ensemble.BEAM_3_INDEX] = 4.5f; ensemble.InstrumentVelocityData.InstrumentVelocityData[3, DataSet.Ensemble.BEAM_0_INDEX] = 2.2f; ensemble.InstrumentVelocityData.InstrumentVelocityData[3, DataSet.Ensemble.BEAM_1_INDEX] = 3.3f; ensemble.InstrumentVelocityData.InstrumentVelocityData[3, DataSet.Ensemble.BEAM_2_INDEX] = 4.4f; ensemble.InstrumentVelocityData.InstrumentVelocityData[3, DataSet.Ensemble.BEAM_3_INDEX] = 5.5f; ensemble.InstrumentVelocityData.InstrumentVelocityData[5, DataSet.Ensemble.BEAM_0_INDEX] = 3.2f; ensemble.InstrumentVelocityData.InstrumentVelocityData[5, DataSet.Ensemble.BEAM_1_INDEX] = 4.3f; ensemble.InstrumentVelocityData.InstrumentVelocityData[5, DataSet.Ensemble.BEAM_2_INDEX] = 5.4f; ensemble.InstrumentVelocityData.InstrumentVelocityData[5, DataSet.Ensemble.BEAM_3_INDEX] = 6.5f; string encoded = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.InstrumentVelocityData); // Serialize object to JSON DataSet.InstrumentVelocityDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.InstrumentVelocityDataSet>(encoded); // Deserialize the JSON // Verify the values are the same Assert.AreEqual(1.2f, decoded.InstrumentVelocityData[0, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 0 0 is incorrect."); Assert.AreEqual(2.3f, decoded.InstrumentVelocityData[0, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 0 1 is incorrect."); Assert.AreEqual(3.4f, decoded.InstrumentVelocityData[0, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 0 2 is incorrect."); Assert.AreEqual(4.5f, decoded.InstrumentVelocityData[0, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 0 3 is incorrect."); Assert.AreEqual(2.2f, decoded.InstrumentVelocityData[3, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 3 0 is incorrect."); Assert.AreEqual(3.3f, decoded.InstrumentVelocityData[3, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 3 1 is incorrect."); Assert.AreEqual(4.4f, decoded.InstrumentVelocityData[3, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 3 2 is incorrect."); Assert.AreEqual(5.5f, decoded.InstrumentVelocityData[3, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 3 3 is incorrect."); Assert.AreEqual(3.2f, decoded.InstrumentVelocityData[5, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 5 0 is incorrect."); Assert.AreEqual(4.3f, decoded.InstrumentVelocityData[5, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 5 1 is incorrect."); Assert.AreEqual(5.4f, decoded.InstrumentVelocityData[5, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 5 2 is incorrect."); Assert.AreEqual(6.5f, decoded.InstrumentVelocityData[5, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 5 3 is incorrect."); }
public void TestJson() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); // Modify the data ensemble.GoodBeamData.GoodBeamData[0, DataSet.Ensemble.BEAM_0_INDEX] = 1; ensemble.GoodBeamData.GoodBeamData[0, DataSet.Ensemble.BEAM_1_INDEX] = 2; ensemble.GoodBeamData.GoodBeamData[0, DataSet.Ensemble.BEAM_2_INDEX] = 3; ensemble.GoodBeamData.GoodBeamData[0, DataSet.Ensemble.BEAM_3_INDEX] = 4; ensemble.GoodBeamData.GoodBeamData[3, DataSet.Ensemble.BEAM_0_INDEX] = 2; ensemble.GoodBeamData.GoodBeamData[3, DataSet.Ensemble.BEAM_1_INDEX] = 3; ensemble.GoodBeamData.GoodBeamData[3, DataSet.Ensemble.BEAM_2_INDEX] = 4; ensemble.GoodBeamData.GoodBeamData[3, DataSet.Ensemble.BEAM_3_INDEX] = 5; ensemble.GoodBeamData.GoodBeamData[5, DataSet.Ensemble.BEAM_0_INDEX] = 3; ensemble.GoodBeamData.GoodBeamData[5, DataSet.Ensemble.BEAM_1_INDEX] = 4; ensemble.GoodBeamData.GoodBeamData[5, DataSet.Ensemble.BEAM_2_INDEX] = 5; ensemble.GoodBeamData.GoodBeamData[5, DataSet.Ensemble.BEAM_3_INDEX] = 6; string encoded = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.GoodBeamData); // Serialize object to JSON DataSet.GoodBeamDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.GoodBeamDataSet>(encoded); // Deserialize the JSON // Verify the values are the same Assert.AreEqual(1, decoded.GoodBeamData[0, DataSet.Ensemble.BEAM_0_INDEX], "Good Beam Data 0 0 is incorrect."); Assert.AreEqual(2, decoded.GoodBeamData[0, DataSet.Ensemble.BEAM_1_INDEX], "Good Beam Data 0 1 is incorrect."); Assert.AreEqual(3, decoded.GoodBeamData[0, DataSet.Ensemble.BEAM_2_INDEX], "Good Beam Data 0 2 is incorrect."); Assert.AreEqual(4, decoded.GoodBeamData[0, DataSet.Ensemble.BEAM_3_INDEX], "Good Beam Data 0 3 is incorrect."); Assert.AreEqual(2, decoded.GoodBeamData[3, DataSet.Ensemble.BEAM_0_INDEX], "Good Beam Data 3 0 is incorrect."); Assert.AreEqual(3, decoded.GoodBeamData[3, DataSet.Ensemble.BEAM_1_INDEX], "Good Beam Data 3 1 is incorrect."); Assert.AreEqual(4, decoded.GoodBeamData[3, DataSet.Ensemble.BEAM_2_INDEX], "Good Beam Data 3 2 is incorrect."); Assert.AreEqual(5, decoded.GoodBeamData[3, DataSet.Ensemble.BEAM_3_INDEX], "Good Beam Data 3 3 is incorrect."); Assert.AreEqual(3, decoded.GoodBeamData[5, DataSet.Ensemble.BEAM_0_INDEX], "Good Beam Data 5 0 is incorrect."); Assert.AreEqual(4, decoded.GoodBeamData[5, DataSet.Ensemble.BEAM_1_INDEX], "Good Beam Data 5 1 is incorrect."); Assert.AreEqual(5, decoded.GoodBeamData[5, DataSet.Ensemble.BEAM_2_INDEX], "Good Beam Data 5 2 is incorrect."); Assert.AreEqual(6, decoded.GoodBeamData[5, DataSet.Ensemble.BEAM_3_INDEX], "Good Beam Data 5 3 is incorrect."); }
public void TestJson() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); // Modify the data ensemble.InstrumentWaterMassData.VelocityX = 2.3f; ensemble.InstrumentWaterMassData.VelocityY = 3.4f; ensemble.InstrumentWaterMassData.VelocityZ = 4.5f; ensemble.InstrumentWaterMassData.WaterMassDepthLayer = 3.77f; string encoded = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.InstrumentWaterMassData); // Serialize object to JSON DataSet.InstrumentWaterMassDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.InstrumentWaterMassDataSet>(encoded); // Deserialize the JSON // Verify the values are the same Assert.AreEqual(2.3f, decoded.VelocityX, "Velocity X is incorrect."); Assert.AreEqual(3.4f, decoded.VelocityY, "Velocity Y is incorrect."); Assert.AreEqual(4.5f, decoded.VelocityZ, "Velocity Z is incorrect."); Assert.AreEqual(3.77f, decoded.WaterMassDepthLayer, "Water Mass Depty Layer is incorrect."); }
public void TestJson() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); // Modify the data ensemble.AncillaryData.FirstBinRange = 1.2f; ensemble.AncillaryData.BinSize = 2.3f; ensemble.AncillaryData.FirstPingTime = 3.4f; ensemble.AncillaryData.LastPingTime = 4.5f; ensemble.AncillaryData.Heading = 5.6f; ensemble.AncillaryData.Pitch = 6.7f; ensemble.AncillaryData.Roll = 7.8f; ensemble.AncillaryData.WaterTemp = 8.9f; ensemble.AncillaryData.SystemTemp = 9.10f; ensemble.AncillaryData.Salinity = 10.11f; ensemble.AncillaryData.Pressure = 11.12f; ensemble.AncillaryData.TransducerDepth = 12.13f; ensemble.AncillaryData.SpeedOfSound = 13.14f; string encoded = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.AncillaryData); // Serialize object to JSON DataSet.AncillaryDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.AncillaryDataSet>(encoded); // Deserialize the JSON // Verify the values are the same Assert.AreEqual(1.2f, decoded.FirstBinRange, "First Bin Range is incorrect."); Assert.AreEqual(2.3f, decoded.BinSize, "BinSize is incorrect."); Assert.AreEqual(3.4f, decoded.FirstPingTime, "FirstPingTime is incorrect."); Assert.AreEqual(4.5f, decoded.LastPingTime, "LastPingTime is incorrect."); Assert.AreEqual(5.6f, decoded.Heading, "Heading is incorrect."); Assert.AreEqual(6.7f, decoded.Pitch, "Pitch is incorrect."); Assert.AreEqual(7.8f, decoded.Roll, "Roll is incorrect."); Assert.AreEqual(8.9f, decoded.WaterTemp, "WaterTemp is incorrect."); Assert.AreEqual(9.10f, decoded.SystemTemp, "SystemTemp is incorrect."); Assert.AreEqual(10.11f, decoded.Salinity, "Salinity is incorrect."); Assert.AreEqual(11.12f, decoded.Pressure, "Pressure is incorrect."); Assert.AreEqual(12.13f, decoded.TransducerDepth, "TransducerDepth is incorrect."); Assert.AreEqual(13.14f, decoded.SpeedOfSound, "SpeedOfSound 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 TestTiming() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); string nmeaData = "$HEHDT,274.67,T*1F$HEROT,-32.6,A*31$GPGGA,155339.00,3245.44007,N,11719.83271,W,2,09,0.9,-1.1,M,-33.3,M,5.0,0138*50$GPVTG,277.26,T,265.15,M,2.62,N,4.86,K,D*29$GPZDA,155339.00,08,12,2011,00,00*67$GPGSV,3,1,09,02,75,182,50,04,56,053,51,05,08,167,42,09,50,241,48*75$GPGSV,3,2,09,10,24,111,46,12,45,322,47,17,17,063,45,25,15,313,44*71$GPGSV,3,3,09,28,05,121,36,,,,,,,,,,,,*48"; ensemble.AddNmeaData(nmeaData); Stopwatch watch = new Stopwatch(); // Test Serialize() watch = new Stopwatch(); watch.Start(); for (int x = 0; x < 1000; x++) { string encoded = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.NmeaData); } watch.Stop(); long resultSerialize = watch.ElapsedMilliseconds; // Test Deserialize() string encodedd = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.NmeaData); watch = new Stopwatch(); watch.Start(); for (int x = 0; x < 1000; x++) { DataSet.NmeaDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.NmeaDataSet>(encodedd); } watch.Stop(); long resultDeserialize = watch.ElapsedMilliseconds; Debug.WriteLine(String.Format("Serialize:{0} Deserialize:{1}", resultSerialize, resultDeserialize)); Debug.WriteLine("Complete"); }
public void TestJson() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); // Modify the data ensemble.EnsembleData.EnsembleNumber = 1222; ensemble.EnsembleData.NumBins = 30; ensemble.EnsembleData.NumBeams = 4; ensemble.EnsembleData.DesiredPingCount = 2; ensemble.EnsembleData.ActualPingCount = 2; ensemble.EnsembleData.SysSerialNumber = new SerialNumber("01300000000000000000000000000001"); ensemble.EnsembleData.SysFirmware = new Firmware(Subsystem.SUB_600KHZ_4BEAM_20DEG_PISTON_3, 0, 2, 3); ensemble.EnsembleData.SubsystemConfig = new SubsystemConfiguration(new Subsystem(Subsystem.SUB_600KHZ_4BEAM_20DEG_PISTON_3), 2, 2); ensemble.EnsembleData.Status = new Status(1); ensemble.EnsembleData.Year = DateTime.Now.Year; ensemble.EnsembleData.Month = DateTime.Now.Month; ensemble.EnsembleData.Day = DateTime.Now.Day; ensemble.EnsembleData.Hour = DateTime.Now.Hour; ensemble.EnsembleData.Minute = DateTime.Now.Minute; ensemble.EnsembleData.Second = DateTime.Now.Second; ensemble.EnsembleData.HSec = 22; ensemble.EnsembleData.EnsDateTime = DateTime.Now; ensemble.EnsembleData.UniqueId = new DataSet.UniqueID(ensemble.EnsembleData.EnsembleNumber, ensemble.EnsembleData.EnsDateTime); string encoded = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.EnsembleData); // Serialize object to JSON DataSet.EnsembleDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.EnsembleDataSet>(encoded); // Deserialize the JSON // Verify the values are the same Assert.AreEqual(1222, decoded.EnsembleNumber, "EnsembleNumber is incorrect."); Assert.AreEqual(30, decoded.NumBins, "NumBins is incorrect."); Assert.AreEqual(4, decoded.NumBeams, "NumBeams is incorrect."); Assert.AreEqual(2, decoded.DesiredPingCount, "DesiredPingCount is incorrect."); Assert.AreEqual(2, decoded.ActualPingCount, "ActualPingCount is incorrect."); Assert.AreEqual(new SerialNumber("01300000000000000000000000000001"), decoded.SysSerialNumber, "SysSerialNumber is incorrect."); Assert.AreEqual(1, decoded.SysSerialNumber.SystemSerialNumber, "Serial number is incorrect."); Assert.AreEqual("300000000000000", decoded.SysSerialNumber.SubSystems, "Subsystems are incorrect."); Assert.AreEqual(1, decoded.SysSerialNumber.SubSystemsList.Count, "Subsystem count is incorrect."); Assert.AreEqual(new Firmware(Subsystem.SUB_600KHZ_4BEAM_20DEG_PISTON_3, 0, 2, 3), decoded.SysFirmware, "SysFirmware is incorrect."); Assert.AreEqual(0, decoded.SysFirmware.FirmwareMajor, "Firmware Major is incorrect."); Assert.AreEqual(2, decoded.SysFirmware.FirmwareMinor, "Firmware Minor is incorrect."); Assert.AreEqual(3, decoded.SysFirmware.FirmwareRevision, "Firmware Revision is incorrect."); Assert.AreEqual(Subsystem.SUB_600KHZ_4BEAM_20DEG_PISTON_3, decoded.SysFirmware.GetSubsystemCode(decoded.SysSerialNumber), "Firmware Subsystem code is incorrect."); Assert.AreEqual(2, decoded.SubsystemConfig.CepoIndex, "SubsystemConfig config number is incorrect."); Assert.AreEqual(Subsystem.SUB_600KHZ_4BEAM_20DEG_PISTON_3, decoded.SubsystemConfig.SubSystem.Code, "SubsystemConfig Subsystem code is incorrect."); Assert.AreEqual(new Subsystem(Subsystem.SUB_600KHZ_4BEAM_20DEG_PISTON_3), decoded.SysFirmware.GetSubsystem(decoded.SysSerialNumber), "SysFirmware GetSubsystem is incorrect."); Assert.AreEqual(Subsystem.SUB_600KHZ_4BEAM_20DEG_PISTON_3, decoded.SysFirmware.GetSubsystemCode(decoded.SysSerialNumber), "Firmware SubsystemCode is incorrect."); Assert.AreEqual(Subsystem.SUB_600KHZ_4BEAM_20DEG_PISTON_3, decoded.SubsystemConfig.SubSystem.Code, "SubsystemConfig Subystem Code is incorrect."); Assert.AreEqual(DateTime.Now.Year, decoded.EnsDateTime.Year, "EnsDateTime Year is incorrect."); Assert.AreEqual(DateTime.Now.Year, decoded.Year, "Year is incorrect."); Assert.AreEqual(DateTime.Now.Month, decoded.EnsDateTime.Month, "EnsDateTime Month is incorrect."); Assert.AreEqual(DateTime.Now.Month, decoded.Month, "Month is incorrect."); Assert.AreEqual(DateTime.Now.Day, decoded.EnsDateTime.Day, "EnsDateTime Day is incorrect."); Assert.AreEqual(DateTime.Now.Day, decoded.Day, "Day is incorrect."); Assert.AreEqual(DateTime.Now.Hour, decoded.EnsDateTime.Hour, "EnsDateTime Hour is incorrect."); Assert.AreEqual(DateTime.Now.Hour, decoded.Hour, "Hour is incorrect."); Assert.AreEqual(DateTime.Now.Minute, decoded.EnsDateTime.Minute, "EnsDateTime Minute is incorrect."); Assert.AreEqual(DateTime.Now.Minute, decoded.Minute, "Minute is incorrect."); Assert.AreEqual(DateTime.Now.Second, decoded.EnsDateTime.Second, "EnsDateTime Second is incorrect."); Assert.AreEqual(DateTime.Now.Second, decoded.Second, "Second is incorrect."); Assert.AreEqual(new DataSet.UniqueID(ensemble.EnsembleData.EnsembleNumber, ensemble.EnsembleData.EnsDateTime), decoded.UniqueId, "UniqueID is incorrect."); }
public void TestJsonVV() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); // Modify the data ensemble.EarthVelocityData.EarthVelocityData[0, DataSet.Ensemble.BEAM_0_INDEX] = 1.2f; ensemble.EarthVelocityData.EarthVelocityData[0, DataSet.Ensemble.BEAM_1_INDEX] = 2.3f; ensemble.EarthVelocityData.EarthVelocityData[0, DataSet.Ensemble.BEAM_2_INDEX] = 3.4f; ensemble.EarthVelocityData.EarthVelocityData[0, DataSet.Ensemble.BEAM_3_INDEX] = 4.5f; ensemble.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_0_INDEX] = 2.2f; ensemble.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_1_INDEX] = 3.3f; ensemble.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_2_INDEX] = 4.4f; ensemble.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_3_INDEX] = 5.5f; ensemble.EarthVelocityData.EarthVelocityData[5, DataSet.Ensemble.BEAM_0_INDEX] = 3.2f; ensemble.EarthVelocityData.EarthVelocityData[5, DataSet.Ensemble.BEAM_1_INDEX] = 4.3f; ensemble.EarthVelocityData.EarthVelocityData[5, DataSet.Ensemble.BEAM_2_INDEX] = 5.4f; ensemble.EarthVelocityData.EarthVelocityData[5, DataSet.Ensemble.BEAM_3_INDEX] = 6.5f; #region VelocityVectors ensemble.EarthVelocityData.IsVelocityVectorAvail = true; ensemble.EarthVelocityData.VelocityVectors = new DataSet.VelocityVector[30]; ensemble.EarthVelocityData.VelocityVectors[0] = new DataSet.VelocityVector() { Magnitude = 1.2f, DirectionXNorth = 2.2f, DirectionYNorth = 3.2f }; ensemble.EarthVelocityData.VelocityVectors[1] = new DataSet.VelocityVector() { Magnitude = 1.3f, DirectionXNorth = 2.3f, DirectionYNorth = 3.3f }; ensemble.EarthVelocityData.VelocityVectors[2] = new DataSet.VelocityVector() { Magnitude = 1.4f, DirectionXNorth = 2.4f, DirectionYNorth = 3.4f }; ensemble.EarthVelocityData.VelocityVectors[3] = new DataSet.VelocityVector() { Magnitude = 1.5f, DirectionXNorth = 2.5f, DirectionYNorth = 3.5f }; ensemble.EarthVelocityData.VelocityVectors[4] = new DataSet.VelocityVector() { Magnitude = 1.6f, DirectionXNorth = 2.6f, DirectionYNorth = 3.6f }; ensemble.EarthVelocityData.VelocityVectors[5] = new DataSet.VelocityVector() { Magnitude = 1.7f, DirectionXNorth = 2.7f, DirectionYNorth = 3.7f }; ensemble.EarthVelocityData.VelocityVectors[6] = new DataSet.VelocityVector() { Magnitude = 1.8f, DirectionXNorth = 2.8f, DirectionYNorth = 3.8f }; ensemble.EarthVelocityData.VelocityVectors[7] = new DataSet.VelocityVector() { Magnitude = 1.9f, DirectionXNorth = 2.9f, DirectionYNorth = 3.9f }; #endregion string encoded = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.EarthVelocityData); // Serialize object to JSON DataSet.EarthVelocityDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.EarthVelocityDataSet>(encoded); // Deserialize the JSON // Verify the values are the same Assert.AreEqual(1.2f, decoded.EarthVelocityData[0, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 0 0 is incorrect."); Assert.AreEqual(2.3f, decoded.EarthVelocityData[0, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 0 1 is incorrect."); Assert.AreEqual(3.4f, decoded.EarthVelocityData[0, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 0 2 is incorrect."); Assert.AreEqual(4.5f, decoded.EarthVelocityData[0, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 0 3 is incorrect."); Assert.AreEqual(2.2f, decoded.EarthVelocityData[3, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 3 0 is incorrect."); Assert.AreEqual(3.3f, decoded.EarthVelocityData[3, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 3 1 is incorrect."); Assert.AreEqual(4.4f, decoded.EarthVelocityData[3, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 3 2 is incorrect."); Assert.AreEqual(5.5f, decoded.EarthVelocityData[3, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 3 3 is incorrect."); Assert.AreEqual(3.2f, decoded.EarthVelocityData[5, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 5 0 is incorrect."); Assert.AreEqual(4.3f, decoded.EarthVelocityData[5, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 5 1 is incorrect."); Assert.AreEqual(5.4f, decoded.EarthVelocityData[5, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 5 2 is incorrect."); Assert.AreEqual(6.5f, decoded.EarthVelocityData[5, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 5 3 is incorrect."); Assert.AreEqual(true, decoded.IsVelocityVectorAvail, "IsVelocityVectorAvail incorrect."); Assert.AreEqual(1.2f, decoded.VelocityVectors[0].Magnitude, "VV 0 Mag is incorrect."); Assert.AreEqual(2.2f, decoded.VelocityVectors[0].DirectionXNorth, "VV 0 X North is incorrect."); Assert.AreEqual(3.2f, decoded.VelocityVectors[0].DirectionYNorth, "VV 0 Y North is incorrect."); Assert.AreEqual(1.3f, decoded.VelocityVectors[1].Magnitude, "VV 1 Mag is incorrect."); Assert.AreEqual(2.3f, decoded.VelocityVectors[1].DirectionXNorth, "VV 1 X North is incorrect."); Assert.AreEqual(3.3f, decoded.VelocityVectors[1].DirectionYNorth, "VV 1 Y North is incorrect."); Assert.AreEqual(1.4f, decoded.VelocityVectors[2].Magnitude, "VV 2 Mag is incorrect."); Assert.AreEqual(2.4f, decoded.VelocityVectors[2].DirectionXNorth, "VV 2 X North is incorrect."); Assert.AreEqual(3.4f, decoded.VelocityVectors[2].DirectionYNorth, "VV 2 Y North is incorrect."); Assert.AreEqual(1.5f, decoded.VelocityVectors[3].Magnitude, "VV 3 Mag is incorrect."); Assert.AreEqual(2.5f, decoded.VelocityVectors[3].DirectionXNorth, "VV 3 X North is incorrect."); Assert.AreEqual(3.5f, decoded.VelocityVectors[3].DirectionYNorth, "VV 3 Y North is incorrect."); Assert.AreEqual(1.6f, decoded.VelocityVectors[4].Magnitude, "VV 4 Mag is incorrect."); Assert.AreEqual(2.6f, decoded.VelocityVectors[4].DirectionXNorth, "VV 4 X North is incorrect."); Assert.AreEqual(3.6f, decoded.VelocityVectors[4].DirectionYNorth, "VV 4 Y North is incorrect."); Assert.AreEqual(1.7f, decoded.VelocityVectors[5].Magnitude, "VV 5 Mag is incorrect."); Assert.AreEqual(2.7f, decoded.VelocityVectors[5].DirectionXNorth, "VV 5 X North is incorrect."); Assert.AreEqual(3.7f, decoded.VelocityVectors[5].DirectionYNorth, "VV 5 Y North is incorrect."); Assert.AreEqual(1.8f, decoded.VelocityVectors[6].Magnitude, "VV 6 Mag is incorrect."); Assert.AreEqual(2.8f, decoded.VelocityVectors[6].DirectionXNorth, "VV 6 X North is incorrect."); Assert.AreEqual(3.8f, decoded.VelocityVectors[6].DirectionYNorth, "VV 6 Y North is incorrect."); Assert.AreEqual(1.9f, decoded.VelocityVectors[7].Magnitude, "VV 7 Mag is incorrect."); Assert.AreEqual(2.9f, decoded.VelocityVectors[7].DirectionXNorth, "VV 7 X North is incorrect."); Assert.AreEqual(3.9f, decoded.VelocityVectors[7].DirectionYNorth, "VV 7 Y North is incorrect."); }
public void TestJson() { // Generate an Ensemble DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30); // Modify the data #region Beam Velocity ensemble.BeamVelocityData.BeamVelocityData[0, DataSet.Ensemble.BEAM_0_INDEX] = 1.2f; ensemble.BeamVelocityData.BeamVelocityData[0, DataSet.Ensemble.BEAM_1_INDEX] = 2.3f; ensemble.BeamVelocityData.BeamVelocityData[0, DataSet.Ensemble.BEAM_2_INDEX] = 3.4f; ensemble.BeamVelocityData.BeamVelocityData[0, DataSet.Ensemble.BEAM_3_INDEX] = 4.5f; ensemble.BeamVelocityData.BeamVelocityData[3, DataSet.Ensemble.BEAM_0_INDEX] = 2.2f; ensemble.BeamVelocityData.BeamVelocityData[3, DataSet.Ensemble.BEAM_1_INDEX] = 3.3f; ensemble.BeamVelocityData.BeamVelocityData[3, DataSet.Ensemble.BEAM_2_INDEX] = 4.4f; ensemble.BeamVelocityData.BeamVelocityData[3, DataSet.Ensemble.BEAM_3_INDEX] = 5.5f; ensemble.BeamVelocityData.BeamVelocityData[5, DataSet.Ensemble.BEAM_0_INDEX] = 3.2f; ensemble.BeamVelocityData.BeamVelocityData[5, DataSet.Ensemble.BEAM_1_INDEX] = 4.3f; ensemble.BeamVelocityData.BeamVelocityData[5, DataSet.Ensemble.BEAM_2_INDEX] = 5.4f; ensemble.BeamVelocityData.BeamVelocityData[5, DataSet.Ensemble.BEAM_3_INDEX] = 6.5f; #endregion #region Amplitude ensemble.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_0_INDEX] = 1.2f; ensemble.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_1_INDEX] = 2.3f; ensemble.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_2_INDEX] = 3.4f; ensemble.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_3_INDEX] = 4.5f; ensemble.AmplitudeData.AmplitudeData[3, DataSet.Ensemble.BEAM_0_INDEX] = 2.2f; ensemble.AmplitudeData.AmplitudeData[3, DataSet.Ensemble.BEAM_1_INDEX] = 3.3f; ensemble.AmplitudeData.AmplitudeData[3, DataSet.Ensemble.BEAM_2_INDEX] = 4.4f; ensemble.AmplitudeData.AmplitudeData[3, DataSet.Ensemble.BEAM_3_INDEX] = 5.5f; ensemble.AmplitudeData.AmplitudeData[5, DataSet.Ensemble.BEAM_0_INDEX] = 3.2f; ensemble.AmplitudeData.AmplitudeData[5, DataSet.Ensemble.BEAM_1_INDEX] = 4.3f; ensemble.AmplitudeData.AmplitudeData[5, DataSet.Ensemble.BEAM_2_INDEX] = 5.4f; ensemble.AmplitudeData.AmplitudeData[5, DataSet.Ensemble.BEAM_3_INDEX] = 6.5f; #endregion string encodedEns = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble); // Serialize to JSON DataSet.Ensemble decodedEns = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.Ensemble>(encodedEns); // Deserialize the JSON Assert.AreEqual(true, ensemble.IsEnsembleAvail, "IsEnsembleAvail is incorrect."); // Verify the values are the same #region Beam Velocity Assert.AreEqual(1.2f, decodedEns.BeamVelocityData.BeamVelocityData[0, DataSet.Ensemble.BEAM_0_INDEX], "Beam Vel Data 0 0 is incorrect."); Assert.AreEqual(2.3f, decodedEns.BeamVelocityData.BeamVelocityData[0, DataSet.Ensemble.BEAM_1_INDEX], "Beam Vel Data 0 1 is incorrect."); Assert.AreEqual(3.4f, decodedEns.BeamVelocityData.BeamVelocityData[0, DataSet.Ensemble.BEAM_2_INDEX], "Beam Vel Data 0 2 is incorrect."); Assert.AreEqual(4.5f, decodedEns.BeamVelocityData.BeamVelocityData[0, DataSet.Ensemble.BEAM_3_INDEX], "Beam Vel Data 0 3 is incorrect."); Assert.AreEqual(2.2f, decodedEns.BeamVelocityData.BeamVelocityData[3, DataSet.Ensemble.BEAM_0_INDEX], "Beam Vel Data 3 0 is incorrect."); Assert.AreEqual(3.3f, decodedEns.BeamVelocityData.BeamVelocityData[3, DataSet.Ensemble.BEAM_1_INDEX], "Beam Vel Data 3 1 is incorrect."); Assert.AreEqual(4.4f, decodedEns.BeamVelocityData.BeamVelocityData[3, DataSet.Ensemble.BEAM_2_INDEX], "Beam Vel Data 3 2 is incorrect."); Assert.AreEqual(5.5f, decodedEns.BeamVelocityData.BeamVelocityData[3, DataSet.Ensemble.BEAM_3_INDEX], "Beam Vel Data 3 3 is incorrect."); Assert.AreEqual(3.2f, decodedEns.BeamVelocityData.BeamVelocityData[5, DataSet.Ensemble.BEAM_0_INDEX], "Beam Vel Data 5 0 is incorrect."); Assert.AreEqual(4.3f, decodedEns.BeamVelocityData.BeamVelocityData[5, DataSet.Ensemble.BEAM_1_INDEX], "Beam Vel Data 5 1 is incorrect."); Assert.AreEqual(5.4f, decodedEns.BeamVelocityData.BeamVelocityData[5, DataSet.Ensemble.BEAM_2_INDEX], "Beam Vel Data 5 2 is incorrect."); Assert.AreEqual(6.5f, decodedEns.BeamVelocityData.BeamVelocityData[5, DataSet.Ensemble.BEAM_3_INDEX], "Beam Vel Data 5 3 is incorrect."); #endregion #region Amplitude Assert.AreEqual(1.2f, decodedEns.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 0 0 is incorrect."); Assert.AreEqual(2.3f, decodedEns.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 0 1 is incorrect."); Assert.AreEqual(3.4f, decodedEns.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 0 2 is incorrect."); Assert.AreEqual(4.5f, decodedEns.AmplitudeData.AmplitudeData[0, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 0 3 is incorrect."); Assert.AreEqual(2.2f, decodedEns.AmplitudeData.AmplitudeData[3, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 3 0 is incorrect."); Assert.AreEqual(3.3f, decodedEns.AmplitudeData.AmplitudeData[3, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 3 1 is incorrect."); Assert.AreEqual(4.4f, decodedEns.AmplitudeData.AmplitudeData[3, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 3 2 is incorrect."); Assert.AreEqual(5.5f, decodedEns.AmplitudeData.AmplitudeData[3, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 3 3 is incorrect."); Assert.AreEqual(3.2f, decodedEns.AmplitudeData.AmplitudeData[5, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 5 0 is incorrect."); Assert.AreEqual(4.3f, decodedEns.AmplitudeData.AmplitudeData[5, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 5 1 is incorrect."); Assert.AreEqual(5.4f, decodedEns.AmplitudeData.AmplitudeData[5, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 5 2 is incorrect."); Assert.AreEqual(6.5f, decodedEns.AmplitudeData.AmplitudeData[5, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 5 3 is incorrect."); #endregion }
public void Test1() { // 5 Samples // Min Ref layer = 1 // Max Ref Layer = 3 // Not running average ReferenceLayerAverage avger = new ReferenceLayerAverage(5, 1, 3, false); // Create an ensemble // All zeros for correlation DataSet.Ensemble ens1 = EnsembleHelper.GenerateEnsemble(30); DataSet.Ensemble ens2 = EnsembleHelper.GenerateEnsemble(30); DataSet.Ensemble ens3 = EnsembleHelper.GenerateEnsemble(30); DataSet.Ensemble ens4 = EnsembleHelper.GenerateEnsemble(30); DataSet.Ensemble ens5 = EnsembleHelper.GenerateEnsemble(30); #region Ensemble 1 ens1.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.3f; ens1.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.6f; ens1.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.2f; ens1.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.6f; ens1.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.3f; ens1.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.15f; ens1.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.4f; ens1.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.4f; ens1.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.11f; #endregion #region Ensemble 2 ens2.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.4f; ens2.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.5f; ens2.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.3f; ens2.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.5f; ens2.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.42f; ens2.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.15f; ens2.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.6f; ens2.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.8f; ens2.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.2f; #endregion #region Ensemble 3 ens3.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.4f; ens3.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.6f; ens3.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.2f; ens3.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.6f; ens3.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.23f; ens3.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.5f; ens3.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.12f; ens3.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.4f; ens3.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.123f; #endregion #region Ensemble 4 ens4.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.3f; ens4.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.25f; ens4.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.3f; ens4.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.5f; ens4.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.54f; ens4.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.25f; ens4.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.4f; ens4.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.45f; ens4.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.4f; #endregion #region Ensemble 5 ens5.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.3f; ens5.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.45f; ens5.EarthVelocityData.EarthVelocityData[1, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.3f; ens5.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.6f; ens5.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.25f; ens5.EarthVelocityData.EarthVelocityData[2, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.25f; ens5.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_EAST_INDEX] = 2.45f; ens5.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_NORTH_INDEX] = 1.36f; ens5.EarthVelocityData.EarthVelocityData[3, DataSet.Ensemble.BEAM_VERTICAL_INDEX] = 0.14f; #endregion // Add the ensembles avger.AddEnsemble(ens1); avger.AddEnsemble(ens2); avger.AddEnsemble(ens3); avger.AddEnsemble(ens4); avger.AddEnsemble(ens5); // Get the average float[,] result = avger.GetAverage(); Assert.IsNotNull(result, "Result is incorrect."); Assert.AreEqual(2.34, result[1, DataSet.Ensemble.BEAM_EAST_INDEX], 0.01, "Bin 1 EAST is incorrect."); Assert.AreEqual(1.48, result[1, DataSet.Ensemble.BEAM_NORTH_INDEX], 0.01, "Bin 1 NORTH is incorrect."); Assert.AreEqual(0.26, result[1, DataSet.Ensemble.BEAM_VERTICAL_INDEX], 0.01, "Bin 1 VERTICAL is incorrect."); Assert.AreEqual(0, result[1, DataSet.Ensemble.BEAM_Q_INDEX], 0.01, "Bin 1 Q is incorrect."); Assert.AreEqual(2.56, result[2, DataSet.Ensemble.BEAM_EAST_INDEX], 0.01, "Bin 2 EAST is incorrect."); Assert.AreEqual(1.348, result[2, DataSet.Ensemble.BEAM_NORTH_INDEX], 0.01, "Bin 2 NORTH is incorrect."); Assert.AreEqual(0.26, result[2, DataSet.Ensemble.BEAM_VERTICAL_INDEX], 0.01, "Bin 2 VERTICAL is incorrect."); Assert.AreEqual(0, result[2, DataSet.Ensemble.BEAM_Q_INDEX], 0.01, "Bin 2 Q is incorrect."); Assert.AreEqual(2.394, result[3, DataSet.Ensemble.BEAM_EAST_INDEX], 0.01, "Bin 3 EAST is incorrect."); Assert.AreEqual(1.482, result[3, DataSet.Ensemble.BEAM_NORTH_INDEX], 0.01, "Bin 3 NORTH is incorrect."); Assert.AreEqual(0.1946, result[3, DataSet.Ensemble.BEAM_VERTICAL_INDEX], 0.01, "Bin 3 VERTICAL is incorrect."); Assert.AreEqual(0, result[3, DataSet.Ensemble.BEAM_Q_INDEX], 0.01, "Bin 3 Q is incorrect."); }