Ejemplo n.º 1
0
    def test_backscatter_adjustment(self):
        '''
        a simple unit test to validate the backscatter adjustment algorithm works.
        '''
        f = open("tmp.tmp", 'a')
        ping = pygsf.SWATH_BATHYMETRY_PING(f, 0, 0, 0)

        S1_angle = -58.0  # degrees
        S1_twtt = 0.20588  # seconds
        S1_range = 164.8  # metres
        H0_TxPower = 197.0  # dB
        H0_SoundSpeed = 1468.59  # metres/second
        H0_RxAbsorption = 80.0  # dB/Km
        H0_TxBeamWidthVert = 0.0174533  # radians
        H0_TxBeamWidthHoriz = 0.0087266  # radians
        H0_TxPulseWidth = 0.000275  # seconds
        H0_RxSpreading = 35.0  # dB
        H0_RxGain = 8.0 * 2.0  # dB (multiply by 2 for r2sonic)
        H0_VTX_Offset = -21.0 / 100.0  # ask Norm
        S1_uPa = 470  # raw backscatter value

        corrected = ping.backscatteradjustment(
            S1_angle, S1_twtt, S1_range, S1_uPa, H0_TxPower, H0_SoundSpeed,
            H0_RxAbsorption, H0_TxBeamWidthVert, H0_TxBeamWidthHoriz,
            H0_TxPulseWidth, H0_RxSpreading, H0_RxGain, H0_VTX_Offset)
        print(corrected)
        requiredresult = -38.6
        self.assertEqual(corrected, requiredresult)
Ejemplo n.º 2
0
    def test_backscatter_availability(self):
        #setup data
        critical = ['MEAN_CAL_AMPLITUDE_ARRAY', 'MEAN_REL_AMPLITUDE_ARRAY']
        ping = pygsf.SWATH_BATHYMETRY_PING(self.test.reader.fileptr, 0, 2, 0)
        self.test.datagrams = {2: [ping]}
        self.test.datagrams[2][0].MEAN_CAL_AMPLITUDE_ARRAY = [2, 2, 2]
        self.test.datagrams[2][0].MEAN_REL_AMPLITUDE_ARRAY = [2, 2, 2]

        # test pass
        backscatter_available_res = self.test.backscatter_availability()

        self.assertEqual(backscatter_available_res.state, scan.ScanState.PASS)
        self.assertEqual(backscatter_available_res.data, {
            'missing_critical': [],
            'missing_noncritical': [],
            'present': critical
        })

        # test fail
        setattr(self.test.datagrams[2][0], critical[0], [])
        setattr(self.test.datagrams[2][0], critical[1], [])
        backscatter_available_res = self.test.backscatter_availability()
        self.assertEqual(backscatter_available_res.state, scan.ScanState.FAIL)
        self.assertEqual(backscatter_available_res.data, {
            'missing_critical': critical,
            'missing_noncritical': [],
            'present': []
        })
Ejemplo n.º 3
0
    def test_ray_tracing_availability(self):
        #setup data
        non_critical = {3: 'SOUND_VELOCITY_PROFILE', 12: 'ATTITUDE'}
        critical = [
            'BEAM_ANGLE_FORWARD_ARRAY', 'BEAM_ANGLE_ARRAY', 'TRAVEL_TIME_ARRAY'
        ]
        combined = critical + list(non_critical.values())
        sound_velocity = pygsf.SOUND_VELOCITY_PROFILE(self.test.reader.fileptr,
                                                      0, 3, 0)
        attitude = pygsf.ATTITUDE(self.test.reader.fileptr, 0, 12, 0)
        ping = pygsf.SWATH_BATHYMETRY_PING(self.test.reader.fileptr, 0, 2, 0)
        self.test.datagrams = {2: [ping], 12: [attitude], 3: [sound_velocity]}
        self.test.datagrams[2][0].BEAM_ANGLE_FORWARD_ARRAY = [2, 2, 2]
        self.test.datagrams[2][0].BEAM_ANGLE_ARRAY = [2, 2, 2]
        self.test.datagrams[2][0].TRAVEL_TIME_ARRAY = [2, 2, 2]

        # test pass
        ray_tracing_available_res = self.test.ray_tracing_availability()

        self.assertEqual(ray_tracing_available_res.state, scan.ScanState.PASS)
        self.assertEqual(ray_tracing_available_res.data, {
            'missing_critical': [],
            'missing_noncritical': [],
            'present': combined
        })

        # test warning
        self.test.datagrams.pop(3)
        combined.remove(non_critical[3])
        ray_tracing_available_res = self.test.ray_tracing_availability()
        self.assertEqual(ray_tracing_available_res.state,
                         scan.ScanState.WARNING)
        self.assertEqual(
            ray_tracing_available_res.data, {
                'missing_critical': [],
                'missing_noncritical': [non_critical[3]],
                'present': combined
            })

        # test fail
        self.test.datagrams = {2: [ping], 12: [attitude], 3: [sound_velocity]}
        setattr(self.test.datagrams[2][0], critical[0], [])
        setattr(self.test.datagrams[2][0], critical[1], [])
        setattr(self.test.datagrams[2][0], critical[2], [])
        ray_tracing_available_res = self.test.ray_tracing_availability()
        self.assertEqual(ray_tracing_available_res.state, scan.ScanState.FAIL)
        self.assertEqual(
            ray_tracing_available_res.data, {
                'missing_critical': critical,
                'missing_noncritical': [],
                'present': list(non_critical.values())
            })
Ejemplo n.º 4
0
 def test_date_match(self):
     # create test data for warning
     self.test.datagrams = {}
     self.assertEqual(self.test.date_match().state, scan.ScanState.WARNING)
     # create test data for pass
     datagram = pygsf.SWATH_BATHYMETRY_PING(self.test.reader.fileptr, 0, 2,
                                            0)
     self.test.datagrams = {2: [datagram]}
     self.test.datagrams[2][0].time = 1605435342
     self.assertEqual(self.test.date_match().state, scan.ScanState.PASS)
     # create test data for fail
     self.test.datagrams[2][0].time = 1623874890
     self.assertEqual(self.test.date_match().state, scan.ScanState.FAIL)
Ejemplo n.º 5
0
    def test_ellipsoid_height_availability(self):
        # setup data
        self.test.datagrams = {}
        height_data = [0, 1, 2, 3, 4, 5]
        ident = 2
        for val in height_data:
            ping = pygsf.SWATH_BATHYMETRY_PING(self.test.reader.fileptr, 0, 2,
                                               0)
            if ident not in self.test.datagrams:
                self.test.datagrams[ident] = []
            self.test.datagrams[ident].append(ping)
            self.test.datagrams[2][val].height = val

        # test pass
        ellipsoid_height_available_res = self.test.ellipsoid_height_availability(
        )
        self.assertEqual(ellipsoid_height_available_res.state,
                         scan.ScanState.PASS)

        # test warning
        for data in height_data:
            setattr(self.test.datagrams[2][data], 'height', 1)
        ellipsoid_height_available_res = self.test.ellipsoid_height_availability(
        )
        self.assertEqual(ellipsoid_height_available_res.state,
                         scan.ScanState.WARNING)
        self.assertEqual(ellipsoid_height_available_res.data, {'value': 1})

        # test fail
        self.test.datagrams = {}
        ping = pygsf.SWATH_BATHYMETRY_PING(self.test.reader.fileptr, 0, 2, 0)
        self.test.datagrams = {2: [ping]}

        ellipsoid_height_available_res = self.test.ellipsoid_height_availability(
        )
        self.assertEqual(ellipsoid_height_available_res.state,
                         scan.ScanState.FAIL)