Esempio n. 1
0
        public void DecodePd0Test()
        {
            Pd0EchoIntensity pd0Ei = new Pd0EchoIntensity(30);

            pd0Ei.EchoIntensity[0, 0] = 68;
            pd0Ei.EchoIntensity[0, 1] = 46;
            pd0Ei.EchoIntensity[0, 2] = 90;
            pd0Ei.EchoIntensity[0, 3] = 112;
            pd0Ei.EchoIntensity[1, 0] = 134;
            pd0Ei.EchoIntensity[1, 1] = 156;
            pd0Ei.EchoIntensity[1, 2] = 178;
            pd0Ei.EchoIntensity[1, 3] = 182;

            DataSet.AmplitudeDataSet amp = new DataSet.AmplitudeDataSet(30);

            amp.DecodePd0Ensemble(pd0Ei);

            Assert.AreEqual(45f, amp.AmplitudeData[0, 0], "Amplitude Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(56f, amp.AmplitudeData[0, 1], "Amplitude Bin 0, Beam 1 is incorrect.");
            Assert.AreEqual(23f, amp.AmplitudeData[0, 2], "Amplitude Bin 0, Beam 2 is incorrect.");
            Assert.AreEqual(34f, amp.AmplitudeData[0, 3], "Amplitude Bin 0, Beam 3 is incorrect.");
            Assert.AreEqual(89f, amp.AmplitudeData[1, 0], "Amplitude Bin 1, Beam 0 is incorrect.");
            Assert.AreEqual(91f, amp.AmplitudeData[1, 1], "Amplitude Bin 1, Beam 1 is incorrect.");
            Assert.AreEqual(78f, amp.AmplitudeData[1, 2], "Amplitude Bin 1, Beam 2 is incorrect.");
            Assert.AreEqual(67f, amp.AmplitudeData[1, 3], "Amplitude Bin 1, Beam 3 is incorrect.");
        }
Esempio n. 2
0
        public void DecodeRtiConstructorTest()
        {
            DataSet.AmplitudeDataSet rtiAmp = new DataSet.AmplitudeDataSet(DataSet.Ensemble.DATATYPE_FLOAT,                      // 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.AmplitudeID);                        // Dataset ID

            rtiAmp.AmplitudeData[0, 0] = 23f;
            rtiAmp.AmplitudeData[0, 1] = 34f;
            rtiAmp.AmplitudeData[0, 2] = 45f;
            rtiAmp.AmplitudeData[0, 3] = 56f;
            rtiAmp.AmplitudeData[1, 0] = 67f;
            rtiAmp.AmplitudeData[1, 1] = 78f;
            rtiAmp.AmplitudeData[1, 2] = 89f;
            rtiAmp.AmplitudeData[1, 3] = 91f;
            rtiAmp.AmplitudeData[2, 0] = 101f;
            rtiAmp.AmplitudeData[2, 1] = 112f;
            rtiAmp.AmplitudeData[2, 2] = 123f;

            Pd0EchoIntensity ei = new Pd0EchoIntensity(rtiAmp);

            Assert.AreEqual(112, ei.EchoIntensity[0, 0], "Echo Intensity Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(90, ei.EchoIntensity[0, 1], "Echo Intensity Bin 0, Beam 1 is incorrect.");
            Assert.AreEqual(46, ei.EchoIntensity[0, 2], "Echo Intensity Bin 0, Beam 2 is incorrect.");
            Assert.AreEqual(68, ei.EchoIntensity[0, 3], "Echo Intensity Bin 0, Beam 3 is incorrect.");
            Assert.AreEqual(182, ei.EchoIntensity[1, 0], "Echo Intensity Bin 1, Beam 0 is incorrect.");
            Assert.AreEqual(178, ei.EchoIntensity[1, 1], "Echo Intensity Bin 1, Beam 1 is incorrect.");
            Assert.AreEqual(134, ei.EchoIntensity[1, 2], "Echo Intensity Bin 1, Beam 2 is incorrect.");
            Assert.AreEqual(156, ei.EchoIntensity[1, 3], "Echo Intensity Bin 1, Beam 3 is incorrect.");
        }
Esempio n. 3
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 encodeAmp = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.AmplitudeData);
            }
            watch.Stop();
            long resultSerialize = watch.ElapsedMilliseconds;

            // Test Deserialize()
            string encodedAmpp = Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.AmplitudeData);

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

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

            Debug.WriteLine("Complete");
        }
Esempio n. 4
0
        public void DecodePd0Test()
        {
            Pd0EchoIntensity pd0Ei = new Pd0EchoIntensity(30);

            pd0Ei.EchoIntensity[0, 0] = 68;
            pd0Ei.EchoIntensity[0, 1] = 46;
            pd0Ei.EchoIntensity[0, 2] = 90;
            pd0Ei.EchoIntensity[0, 3] = 112;
            pd0Ei.EchoIntensity[1, 0] = 134;
            pd0Ei.EchoIntensity[1, 1] = 156;
            pd0Ei.EchoIntensity[1, 2] = 178;
            pd0Ei.EchoIntensity[1, 3] = 182;


            DataSet.AmplitudeDataSet amp = new DataSet.AmplitudeDataSet(30);

            amp.DecodePd0Ensemble(pd0Ei);

            Assert.AreEqual(45f, amp.AmplitudeData[0, 0], "Amplitude Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(56f, amp.AmplitudeData[0, 1], "Amplitude Bin 0, Beam 1 is incorrect.");
            Assert.AreEqual(23f, amp.AmplitudeData[0, 2], "Amplitude Bin 0, Beam 2 is incorrect.");
            Assert.AreEqual(34f, amp.AmplitudeData[0, 3], "Amplitude Bin 0, Beam 3 is incorrect.");
            Assert.AreEqual(89f, amp.AmplitudeData[1, 0], "Amplitude Bin 1, Beam 0 is incorrect.");
            Assert.AreEqual(91f, amp.AmplitudeData[1, 1], "Amplitude Bin 1, Beam 1 is incorrect.");
            Assert.AreEqual(78f, amp.AmplitudeData[1, 2], "Amplitude Bin 1, Beam 2 is incorrect.");
            Assert.AreEqual(67f, amp.AmplitudeData[1, 3], "Amplitude Bin 1, Beam 3 is incorrect.");
        }
Esempio n. 5
0
        public void DecodeRtiConstructorTest()
        {
            DataSet.AmplitudeDataSet rtiAmp = new DataSet.AmplitudeDataSet(DataSet.Ensemble.DATATYPE_FLOAT,                      // 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.AmplitudeID);                  // Dataset ID

            rtiAmp.AmplitudeData[0, 0] = 23f;
            rtiAmp.AmplitudeData[0, 1] = 34f;
            rtiAmp.AmplitudeData[0, 2] = 45f;
            rtiAmp.AmplitudeData[0, 3] = 56f;
            rtiAmp.AmplitudeData[1, 0] = 67f;
            rtiAmp.AmplitudeData[1, 1] = 78f;
            rtiAmp.AmplitudeData[1, 2] = 89f;
            rtiAmp.AmplitudeData[1, 3] = 91f;
            rtiAmp.AmplitudeData[2, 0] = 101f;
            rtiAmp.AmplitudeData[2, 1] = 112f;
            rtiAmp.AmplitudeData[2, 2] = 123f;

            Pd0EchoIntensity ei = new Pd0EchoIntensity(rtiAmp);

            Assert.AreEqual(112, ei.EchoIntensity[0, 0], "Echo Intensity Bin 0, Beam 0 is incorrect.");
            Assert.AreEqual(90, ei.EchoIntensity[0, 1], "Echo Intensity Bin 0, Beam 1 is incorrect.");
            Assert.AreEqual(46, ei.EchoIntensity[0, 2], "Echo Intensity Bin 0, Beam 2 is incorrect.");
            Assert.AreEqual(68, ei.EchoIntensity[0, 3], "Echo Intensity Bin 0, Beam 3 is incorrect.");
            Assert.AreEqual(182, ei.EchoIntensity[1, 0], "Echo Intensity Bin 1, Beam 0 is incorrect.");
            Assert.AreEqual(178, ei.EchoIntensity[1, 1], "Echo Intensity Bin 1, Beam 1 is incorrect.");
            Assert.AreEqual(134, ei.EchoIntensity[1, 2], "Echo Intensity Bin 1, Beam 2 is incorrect.");
            Assert.AreEqual(156, ei.EchoIntensity[1, 3], "Echo Intensity Bin 1, Beam 3 is incorrect.");
        }
Esempio n. 6
0
        /// <summary>
        /// Initialize the object.
        /// </summary>
        /// <param name="amp">RTI Amplitude data.</param>
        public Pd0EchoIntensity(DataSet.AmplitudeDataSet amp)
            : base(ID_LSB, ID_MSB, Pd0ID.Pd0Types.EchoIntensity)
        {
            NumDepthCells = amp.NumElements;
            NumBeams      = amp.ElementsMultiplier;

            DecodeRtiEnsemble(amp);
        }
Esempio n. 7
0
        /// <summary>
        /// Convert the RTI Amplitude data set to the PD0 Echo Intensity data type.
        /// </summary>
        /// <param name="amp">RTI Amplitude data set.</param>
        public void DecodeRtiEnsemble(DataSet.AmplitudeDataSet amp)
        {
            if (amp.AmplitudeData != null)
            {
                EchoIntensity = new byte[amp.AmplitudeData.GetLength(0), NumBeams];

                // 0.5 dB per count
                for (int bin = 0; bin < amp.AmplitudeData.GetLength(0); bin++)
                {
                    // 4 Beam system
                    if (amp.AmplitudeData.GetLength(1) >= NumBeams)
                    {
                        for (int beam = 0; beam < amp.AmplitudeData.GetLength(1); beam++)
                        {
                            // Reorder the beams for PD0 to RTI
                            int newBeam = 0;

                            if (NumBeams >= 4)
                            {
                                // beam order 3,2,0,1
                                switch (beam)
                                {
                                case 0:
                                    newBeam = 3;
                                    break;

                                case 1:
                                    newBeam = 2;
                                    break;

                                case 2:
                                    newBeam = 0;
                                    break;

                                case 3:
                                    newBeam = 1;
                                    break;
                                }
                            }
                            else
                            {
                                // 3 Beam (SeaSEVEN) does not reorder
                                newBeam = beam;
                            }

                            // Set the value
                            EchoIntensity[bin, beam] = (byte)(Math.Round(amp.AmplitudeData[bin, newBeam] * 2));
                        }
                    }
                    // Vertical beam
                    else if (amp.AmplitudeData.GetLength(1) == 1)
                    {
                        EchoIntensity[bin, 0] = (byte)(Math.Round(amp.AmplitudeData[bin, 0] * 2));
                    }
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Convert the RTI Amplitude data set to the PD0 Echo Intensity data type.
        /// </summary>
        /// <param name="amp">RTI Amplitude data set.</param>
        public void DecodeRtiEnsemble(DataSet.AmplitudeDataSet amp)
        {
            if (amp.AmplitudeData != null)
            {
                EchoIntensity = new byte[amp.AmplitudeData.GetLength(0), NumBeams];

                // 0.5 dB per count
                for (int bin = 0; bin < amp.AmplitudeData.GetLength(0); bin++)
                {
                    // 4 Beam system
                    if (amp.AmplitudeData.GetLength(1) >= NumBeams)
                    {
                        for (int beam = 0; beam < amp.AmplitudeData.GetLength(1); beam++)
                        {
                            // beam order 3,2,0,1
                            int newBeam = 0;
                            switch (beam)
                            {
                            case 0:
                                newBeam = 3;
                                break;

                            case 1:
                                newBeam = 2;
                                break;

                            case 2:
                                newBeam = 0;
                                break;

                            case 3:
                                newBeam = 1;
                                break;
                            }

                            EchoIntensity[bin, beam] = (byte)(Math.Round(amp.AmplitudeData[bin, newBeam] * 2));
                        }
                    }
                    // Vertical beam
                    else if (amp.AmplitudeData.GetLength(1) == 1)
                    {
                        EchoIntensity[bin, 0] = (byte)(Math.Round(amp.AmplitudeData[bin, 0] * 2));
                    }
                }
            }
        }
Esempio n. 9
0
        public void TestJson()
        {
            // Generate an Ensemble
            DataSet.Ensemble ensemble = EnsembleHelper.GenerateEnsemble(30);

            // Modify the data
            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;

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

            DataSet.AmplitudeDataSet decodedAmp = Newtonsoft.Json.JsonConvert.DeserializeObject <DataSet.AmplitudeDataSet>(encodedAmp);   // Deserialize the JSON

            // Verify the values are the same
            Assert.AreEqual(1.2f, decodedAmp.AmplitudeData[0, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 0 0 is incorrect.");
            Assert.AreEqual(2.3f, decodedAmp.AmplitudeData[0, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 0 1 is incorrect.");
            Assert.AreEqual(3.4f, decodedAmp.AmplitudeData[0, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 0 2 is incorrect.");
            Assert.AreEqual(4.5f, decodedAmp.AmplitudeData[0, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 0 3 is incorrect.");

            Assert.AreEqual(2.2f, decodedAmp.AmplitudeData[3, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 3 0 is incorrect.");
            Assert.AreEqual(3.3f, decodedAmp.AmplitudeData[3, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 3 1 is incorrect.");
            Assert.AreEqual(4.4f, decodedAmp.AmplitudeData[3, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 3 2 is incorrect.");
            Assert.AreEqual(5.5f, decodedAmp.AmplitudeData[3, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 3 3 is incorrect.");

            Assert.AreEqual(3.2f, decodedAmp.AmplitudeData[5, DataSet.Ensemble.BEAM_0_INDEX], "Amp Data 5 0 is incorrect.");
            Assert.AreEqual(4.3f, decodedAmp.AmplitudeData[5, DataSet.Ensemble.BEAM_1_INDEX], "Amp Data 5 1 is incorrect.");
            Assert.AreEqual(5.4f, decodedAmp.AmplitudeData[5, DataSet.Ensemble.BEAM_2_INDEX], "Amp Data 5 2 is incorrect.");
            Assert.AreEqual(6.5f, decodedAmp.AmplitudeData[5, DataSet.Ensemble.BEAM_3_INDEX], "Amp Data 5 3 is incorrect.");
        }