Esempio n. 1
0
        public void DecodeRtiConstructorTest()
        {
            DataSet.GoodEarthDataSet ge = new DataSet.GoodEarthDataSet(DataSet.Ensemble.DATATYPE_INT,                           // Type of data stored (Float or Int)
                                                                       30,                                                      // Number of bins
                                                                       4,                                                       // Number of beams
                                                                       DataSet.Ensemble.DEFAULT_IMAG,                           // Default Image
                                                                       DataSet.Ensemble.DEFAULT_NAME_LENGTH,                    // Default Image length
                                                                       DataSet.Ensemble.GoodEarthID);                           // Dataset ID

            ge.GoodEarthData[0, 0] = 2;
            ge.GoodEarthData[0, 1] = 2;
            ge.GoodEarthData[0, 2] = 1;
            ge.GoodEarthData[0, 3] = 2;
            ge.GoodEarthData[1, 0] = 2;
            ge.GoodEarthData[1, 1] = 2;
            ge.GoodEarthData[1, 2] = 2;
            ge.GoodEarthData[1, 3] = 1;

            Pd0PercentGood pg = new Pd0PercentGood(ge, 2);

            Assert.AreEqual(100, pg.PercentGood[0, 0], "Percent Good Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(50, pg.PercentGood[0, 1], "Percent Good Bin 0, Beam 1 is incorrect.");
            Assert.AreEqual(100, pg.PercentGood[0, 2], "Percent Good Bin 0, Beam 2 is incorrect.");
            Assert.AreEqual(100, pg.PercentGood[0, 3], "Percent Good Bin 0, Beam 3 is incorrect.");
            Assert.AreEqual(50, pg.PercentGood[1, 0], "Percent Good Bin 1, Beam 0 is incorrect.");
            Assert.AreEqual(100, pg.PercentGood[1, 1], "Percent Good Bin 1, Beam 1 is incorrect.");
            Assert.AreEqual(100, pg.PercentGood[1, 2], "Percent Good Bin 1, Beam 2 is incorrect.");
            Assert.AreEqual(100, pg.PercentGood[1, 3], "Percent Good Bin 1, Beam 3 is incorrect.");
        }
Esempio n. 2
0
        /// <summary>
        /// Convert the RTI Good Earth data set to the PD0 Percent Good data type.
        /// </summary>
        /// <param name="goodEarth">RTI Good Earth data set.</param>
        /// <param name="pingsPerEnsemble">Pings per Ensemble.</param>
        public void DecodeRtiEnsemble(DataSet.GoodEarthDataSet goodEarth, int pingsPerEnsemble)
        {
            if (goodEarth.GoodEarthData != null)
            {
                PercentGood = new byte[goodEarth.GoodEarthData.GetLength(0), NumBeams];

                for (int bin = 0; bin < goodEarth.GoodEarthData.GetLength(0); bin++)
                {
                    // 4 Beam System
                    if (goodEarth.GoodEarthData.GetLength(1) >= 3)
                    {
                        for (int beam = 0; beam < goodEarth.GoodEarthData.GetLength(1); beam++)
                        {
                            // beam order 3,2,0,1; XYZ order 1,0,-2,3, ENU order 0,1,2,3
                            PercentGood[bin, beam] = (byte)(Math.Round((goodEarth.GoodEarthData[bin, beam] * 100.0) / pingsPerEnsemble));
                        }
                    }
                    // Vertical Beam
                    else if (goodEarth.GoodEarthData.GetLength(1) == 1)
                    {
                        PercentGood[bin, 0] = (byte)(Math.Round((goodEarth.GoodEarthData[bin, 0] * 100.0) / pingsPerEnsemble));
                    }
                }
            }
        }
Esempio n. 3
0
        public void DecodePd0Test()
        {
            Pd0PercentGood pg = new Pd0PercentGood(30);

            pg.PercentGood[0, 0] = 100;
            pg.PercentGood[0, 1] = 100;
            pg.PercentGood[0, 2] = 50;
            pg.PercentGood[0, 3] = 100;
            pg.PercentGood[1, 0] = 100;
            pg.PercentGood[1, 1] = 100;
            pg.PercentGood[1, 2] = 100;
            pg.PercentGood[1, 3] = 50;

            DataSet.GoodEarthDataSet goodEarth = new DataSet.GoodEarthDataSet(30);
            goodEarth.DecodePd0Ensemble(pg, 2);

            Assert.AreEqual(1, goodEarth.GoodEarthData[0, 0], "Good Earth Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[0, 1], "Good Earth Bin 0, Beam 1 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[0, 2], "Good Earth Bin 0, Beam 2 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[0, 3], "Good Earth Bin 0, Beam 3 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[1, 0], "Good Earthd Bin 1, Beam 0 is incorrect.");
            Assert.AreEqual(1, goodEarth.GoodEarthData[1, 1], "Good Earth Bin 1, Beam 1 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[1, 2], "Good Earth Bin 1, Beam 2 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[1, 3], "Good Earth Bin 1, Beam 3 is incorrect.");
        }
Esempio n. 4
0
        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.GoodEarthData);
            }
            watch.Stop();
            long resultSerialize = watch.ElapsedMilliseconds;

            // Test Deserialize()
            string encodedd = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.GoodEarthData);

            watch = new Stopwatch();
            watch.Start();
            for (int x = 0; x < 1000; x++)
            {
                DataSet.GoodEarthDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.GoodEarthDataSet>(encodedd);
            }
            watch.Stop();
            long resultDeserialize = watch.ElapsedMilliseconds;

            Debug.WriteLine(String.Format("Serialize:{0}  Deserialize:{1}", resultSerialize, resultDeserialize));

            Debug.WriteLine("Complete");
        }
Esempio n. 5
0
        public void DecodeRtiConstructorTest()
        {
            DataSet.GoodEarthDataSet ge = new DataSet.GoodEarthDataSet(DataSet.Ensemble.DATATYPE_INT,                           // Type of data stored (Float or Int)
                                                                                    30,                                             // Number of bins
                                                                                    4,                                              // Number of beams
                                                                                    DataSet.Ensemble.DEFAULT_IMAG,                  // Default Image
                                                                                    DataSet.Ensemble.DEFAULT_NAME_LENGTH,           // Default Image length
                                                                                    DataSet.Ensemble.GoodEarthID);                  // Dataset ID

            ge.GoodEarthData[0, 0] = 2;
            ge.GoodEarthData[0, 1] = 2;
            ge.GoodEarthData[0, 2] = 1;
            ge.GoodEarthData[0, 3] = 2;
            ge.GoodEarthData[1, 0] = 2;
            ge.GoodEarthData[1, 1] = 2;
            ge.GoodEarthData[1, 2] = 2;
            ge.GoodEarthData[1, 3] = 1;

            Pd0PercentGood pg = new Pd0PercentGood(ge, 2);

            Assert.AreEqual(100, pg.PercentGood[0, 0], "Percent Good Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(50, pg.PercentGood[0, 1], "Percent Good Bin 0, Beam 1 is incorrect.");
            Assert.AreEqual(100, pg.PercentGood[0, 2], "Percent Good Bin 0, Beam 2 is incorrect.");
            Assert.AreEqual(100, pg.PercentGood[0, 3], "Percent Good Bin 0, Beam 3 is incorrect.");
            Assert.AreEqual(50, pg.PercentGood[1, 0], "Percent Good Bin 1, Beam 0 is incorrect.");
            Assert.AreEqual(100, pg.PercentGood[1, 1], "Percent Good Bin 1, Beam 1 is incorrect.");
            Assert.AreEqual(100, pg.PercentGood[1, 2], "Percent Good Bin 1, Beam 2 is incorrect.");
            Assert.AreEqual(100, pg.PercentGood[1, 3], "Percent Good Bin 1, Beam 3 is incorrect.");
        }
Esempio n. 6
0
        public void DecodePd0Test()
        {
            Pd0PercentGood pg = new Pd0PercentGood(30);

            pg.PercentGood[0, 0] = 100;
            pg.PercentGood[0, 1] = 100;
            pg.PercentGood[0, 2] = 50;
            pg.PercentGood[0, 3] = 100;
            pg.PercentGood[1, 0] = 100;
            pg.PercentGood[1, 1] = 100;
            pg.PercentGood[1, 2] = 100;
            pg.PercentGood[1, 3] = 50;

            DataSet.GoodEarthDataSet goodEarth = new DataSet.GoodEarthDataSet(30);
            goodEarth.DecodePd0Ensemble(pg, 2);

            Assert.AreEqual(1, goodEarth.GoodEarthData[0, 0], "Good Earth Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[0, 1], "Good Earth Bin 0, Beam 1 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[0, 2], "Good Earth Bin 0, Beam 2 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[0, 3], "Good Earth Bin 0, Beam 3 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[1, 0], "Good Earthd Bin 1, Beam 0 is incorrect.");
            Assert.AreEqual(1, goodEarth.GoodEarthData[1, 1], "Good Earth Bin 1, Beam 1 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[1, 2], "Good Earth Bin 1, Beam 2 is incorrect.");
            Assert.AreEqual(2, goodEarth.GoodEarthData[1, 3], "Good Earth Bin 1, Beam 3 is incorrect.");
        }
Esempio n. 7
0
        /// <summary>
        /// Initialize the object.
        /// </summary>
        /// <param name="goodEarth">RTI Good Earth data set.</param>
        /// <param name="pingsPerEnsemble">Pings per Ensemble.</param>
        public Pd0PercentGood(DataSet.GoodEarthDataSet goodEarth, int pingsPerEnsemble)
            : base(ID_LSB, ID_MSB, Pd0ID.Pd0Types.PercentGood)
        {
            NumDepthCells = goodEarth.NumElements;
            NumBeams      = goodEarth.ElementsMultiplier;

            DecodeRtiEnsemble(goodEarth, pingsPerEnsemble);
        }
Esempio n. 8
0
        /// <summary>
        /// Convert the RTI Good Earth data set to the PD0 Percent Good data type.
        /// </summary>
        /// <param name="goodEarth">RTI Good Earth data set.</param>
        /// <param name="pingsPerEnsemble">Pings per Ensemble.</param>
        public void DecodeRtiEnsemble(DataSet.GoodEarthDataSet goodEarth, int pingsPerEnsemble)
        {
            if (goodEarth.GoodEarthData != null)
            {
                PercentGood = new byte[goodEarth.GoodEarthData.GetLength(0), NumBeams];

                for (int bin = 0; bin < goodEarth.GoodEarthData.GetLength(0); bin++)
                {
                    // 4 Beam System
                    if (goodEarth.GoodEarthData.GetLength(1) >= 3)
                    {
                        for (int beam = 0; beam < goodEarth.GoodEarthData.GetLength(1); beam++)
                        {
                            // beam order 3,2,0,1; XYZ order 1,0,-2,3, ENU order 0,1,2,3
                            int newBeam = 0;
                            if (goodEarth.GoodEarthData.GetLength(1) >= 4)
                            {
                                switch (beam)
                                {
                                case 0:
                                    newBeam = 3;
                                    break;

                                case 1:
                                    newBeam = 2;
                                    break;

                                case 2:
                                    newBeam = 0;
                                    break;

                                case 3:
                                    newBeam = 1;
                                    break;

                                default:
                                    break;
                                }
                            }
                            else
                            {
                                newBeam = beam;
                            }

                            PercentGood[bin, beam] = (byte)(Math.Round((goodEarth.GoodEarthData[bin, newBeam] * 100.0) / pingsPerEnsemble));
                        }
                    }
                    // Vertical Beam
                    else if (goodEarth.GoodEarthData.GetLength(1) == 1)
                    {
                        PercentGood[bin, 0] = (byte)(Math.Round((goodEarth.GoodEarthData[bin, 0] * 100.0) / pingsPerEnsemble));
                    }
                }
            }
        }
Esempio n. 9
0
        public void TestJson()
        {
            // Generate an Ensemble
            DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30);

            // Modify the data
            ensemble.GoodEarthData.GoodEarthData[0, DataSet.Ensemble.BEAM_0_INDEX] = 1;
            ensemble.GoodEarthData.GoodEarthData[0, DataSet.Ensemble.BEAM_1_INDEX] = 2;
            ensemble.GoodEarthData.GoodEarthData[0, DataSet.Ensemble.BEAM_2_INDEX] = 3;
            ensemble.GoodEarthData.GoodEarthData[0, DataSet.Ensemble.BEAM_3_INDEX] = 4;

            ensemble.GoodEarthData.GoodEarthData[3, DataSet.Ensemble.BEAM_0_INDEX] = 2;
            ensemble.GoodEarthData.GoodEarthData[3, DataSet.Ensemble.BEAM_1_INDEX] = 3;
            ensemble.GoodEarthData.GoodEarthData[3, DataSet.Ensemble.BEAM_2_INDEX] = 4;
            ensemble.GoodEarthData.GoodEarthData[3, DataSet.Ensemble.BEAM_3_INDEX] = 5;

            ensemble.GoodEarthData.GoodEarthData[5, DataSet.Ensemble.BEAM_0_INDEX] = 3;
            ensemble.GoodEarthData.GoodEarthData[5, DataSet.Ensemble.BEAM_1_INDEX] = 4;
            ensemble.GoodEarthData.GoodEarthData[5, DataSet.Ensemble.BEAM_2_INDEX] = 5;
            ensemble.GoodEarthData.GoodEarthData[5, DataSet.Ensemble.BEAM_3_INDEX] = 6;

            string encoded = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.GoodEarthData);                                      // Serialize object to JSON

            DataSet.GoodEarthDataSet decoded = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.GoodEarthDataSet>(encoded);      // Deserialize the JSON

            // Verify the values are the same
            Assert.AreEqual(1, decoded.GoodEarthData[0, DataSet.Ensemble.BEAM_0_INDEX], "Good Beam Data 0 0 is incorrect.");
            Assert.AreEqual(2, decoded.GoodEarthData[0, DataSet.Ensemble.BEAM_1_INDEX], "Good Beam Data 0 1 is incorrect.");
            Assert.AreEqual(3, decoded.GoodEarthData[0, DataSet.Ensemble.BEAM_2_INDEX], "Good Beam Data 0 2 is incorrect.");
            Assert.AreEqual(4, decoded.GoodEarthData[0, DataSet.Ensemble.BEAM_3_INDEX], "Good Beam Data 0 3 is incorrect.");

            Assert.AreEqual(2, decoded.GoodEarthData[3, DataSet.Ensemble.BEAM_0_INDEX], "Good Beam Data 3 0 is incorrect.");
            Assert.AreEqual(3, decoded.GoodEarthData[3, DataSet.Ensemble.BEAM_1_INDEX], "Good Beam Data 3 1 is incorrect.");
            Assert.AreEqual(4, decoded.GoodEarthData[3, DataSet.Ensemble.BEAM_2_INDEX], "Good Beam Data 3 2 is incorrect.");
            Assert.AreEqual(5, decoded.GoodEarthData[3, DataSet.Ensemble.BEAM_3_INDEX], "Good Beam Data 3 3 is incorrect.");

            Assert.AreEqual(3, decoded.GoodEarthData[5, DataSet.Ensemble.BEAM_0_INDEX], "Good Beam Data 5 0 is incorrect.");
            Assert.AreEqual(4, decoded.GoodEarthData[5, DataSet.Ensemble.BEAM_1_INDEX], "Good Beam Data 5 1 is incorrect.");
            Assert.AreEqual(5, decoded.GoodEarthData[5, DataSet.Ensemble.BEAM_2_INDEX], "Good Beam Data 5 2 is incorrect.");
            Assert.AreEqual(6, decoded.GoodEarthData[5, DataSet.Ensemble.BEAM_3_INDEX], "Good Beam Data 5 3 is incorrect.");
        }