Esempio n. 1
0
    def test_can_combine_boxes(self):
        """
        Test that it works with multiple boxes
        :return: Nothing
        """
        print(
            "Testing that get_region_hist_loc will fetch data from multiple WMO boxes"
        )

        all_data = get_region_hist_locations(self.wmo_boxes, 'none',
                                             self.config)
        some_data = get_region_hist_locations([self.wmo_boxes[0]], 'none',
                                              self.config)
        half_data = get_region_hist_locations([
            self.wmo_boxes[0],
            [self.config['TEST_FLOAT_WMO_BOXES'][1], 0, 0, 0]
        ], 'none', self.config)

        for i in range(0, all_data.__len__()):
            self.assertGreater(
                all_data[i].__len__(), some_data[i].__len__(),
                "Should have more data when using multiple boxes")
            self.assertEqual(
                some_data[i].__len__(), half_data[i].__len__(),
                "Should get equal data with using one ox and using "
                "two boxes, but getting no data from second box")
Esempio n. 2
0
    def test_can_choose_data(self):
        """
        Check that, by applying different flags, we can fetch differing data types
        :return: Nothing
        """
        print(
            "Testing that get_region_his_locations can fetch different data types"
        )

        wmo_box_argo = np.array(
            [[self.config['TEST_FLOAT_WMO_BOXES'][0], 0, 0, 1]])
        wmo_box_bot = np.array(
            [[self.config['TEST_FLOAT_WMO_BOXES'][0], 0, 1, 0]])
        wmo_box_ctd = np.array(
            [[self.config['TEST_FLOAT_WMO_BOXES'][0], 1, 0, 0]])

        data_argo = get_region_hist_locations(wmo_box_argo, 'none',
                                              self.config)
        data_bot = get_region_hist_locations(wmo_box_bot, 'none', self.config)
        data_ctd = get_region_hist_locations(wmo_box_ctd, 'none', self.config)

        for i in range(0, data_argo.__len__()):
            self.assertNotEqual(
                data_argo[i].__len__(), data_bot[i].__len__(),
                "Should have different data for argo and bottle")
            self.assertNotEqual(data_argo[i].__len__(), data_ctd[i].__len__(),
                                "Should have different data for argo and ctd")
            # no bottle database reference,
            self.assertNotEqual(
                data_bot[i].__len__(), data_ctd[i].__len__(),
                "Should have different data for bottle and ctd")
Esempio n. 3
0
    def test_current_float_removed(self):
        """
        Check that if the argo float currently being processed appears in the historical data that
        it is removed
        :return: Nothing
        """
        print(
            "Testing that get_region_his_locations removes the current float")

        wmo_box_argo = np.array(
            [[self.config['TEST_FLOAT_WMO_BOXES'][0], 0, 0, 1]])

        # Data not including the float:
        lat_rem, long_rem, age_rem = get_region_hist_locations(
            wmo_box_argo, self.float_name, self.config)
        # All data:
        lat_no_rem, long_no_rem, age_no_rem = get_region_hist_locations(
            wmo_box_argo, 'DUMMY_WMO', self.config)

        self.assertNotEqual(lat_rem.__len__(), lat_no_rem.__len__(),
                            "Did not remove current argo float")

        self.assertGreater(
            long_no_rem.__len__(), long_rem.__len__(),
            "Should have more values for the data with no argo removal")

        self.assertEqual(
            age_no_rem.__len__() - age_rem.__len__(),
            self.config['TEST_FLOAT_N_TO_REMOVE'],
            "should have removed %i values" %
            self.config['TEST_FLOAT_N_TO_REMOVE'])
Esempio n. 4
0
    def test_no_data(self):
        """
        Check that if we receive no data then we return the expected values
        :return: Nothing
        """
        print(
            "Testing that get_region_hist_locations returns expected values for no data"
        )

        wmo_boxes_no_data = np.array(
            [[self.config['TEST_FLOAT_WMO_BOXES'][0], 0, 0, 0]])

        with self.assertRaises(ValueError) as no_data:
            get_region_hist_locations(wmo_boxes_no_data, 'none', self.config)

        self.assertTrue(
            'get_region_hist_locations found no data for your specification. '
            'Are your wmo_boxes files set up correctly?' in str(
                no_data.exception))
Esempio n. 5
0
    def test_can_combine_data(self):
        """
        Test that flags can be set to retrieve all the data
        :return: Nothing
        """
        print("Testing that get_region_hist_locations can fetch all the data")

        wmo_box_all = np.array(
            [[self.config['TEST_FLOAT_WMO_BOXES'][0], 1, 1, 1]])
        all_data = get_region_hist_locations(wmo_box_all, 'none', self.config)

        for data in all_data:
            self.assertEqual(data.__len__(), self.config['TEST_FLOAT_N_DATA'],
                             "Should get the same amount of data as matlab")
Esempio n. 6
0
    def test_returns_three(self):
        """
        Check that the function returns 3 unique values
        :return: Nothing
        """
        print(
            "Testing that get_region_his_locations returns 3 unique values of equal length"
        )

        lat, long, age = get_region_hist_locations(self.wmo_box,
                                                   self.float_name,
                                                   self.config)
        self.assertEqual(
            lat.__len__(), long.__len__(),
            "Should have equal numbers of latitude and longitude")
        self.assertEqual(
            lat.__len__(), age.__len__(),
            "should have equal number of spatial and temporal data")

        for i in range(0, lat.__len__()):
            self.assertNotEqual(lat[i], long[i],
                                "latitude and longitude should be unique")
            self.assertNotEqual(lat[i], age[i],
                                "spatial and temporal data should be unique")