Ejemplo n.º 1
0
    def test_spike_realdata(self):
        """
        Test with real-world data.
        """
        suspect_threshold = 0.5
        fail_threshold = 1

        arr = [
            -0.189, -0.0792, -0.0122, 0.0457, 0.0671, 0.0213, -0.0488, -0.1463,
            -0.2438, -0.3261, -0.3871, -0.4054, -0.3932, -0.3383, -0.2804,
            -0.2347, -0.2134, -0.2347, -0.2926, -0.3597, -0.442, -0.509, 0,
            -0.5944, -0.57, -0.4267, -0.2926, -0.1585, -0.0945, -0.0762
        ]

        expected = [
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
            3, 1, 1, 1, 1, 1, 1, 1
        ]

        inputs = [
            arr,
            np.asarray(arr, dtype=np.floating),
            dask_arr(np.asarray(arr, dtype=np.floating))
        ]
        for i in inputs:
            npt.assert_array_equal(
                qartod.spike_test(inp=i,
                                  suspect_threshold=suspect_threshold,
                                  fail_threshold=fail_threshold), expected)
Ejemplo n.º 2
0
    def test_spike_initial_final_values(self):
        """
        The test is not defined for the initial and final values in the array
        """
        arr = [-100, -99, -99, -98]
        expected = [2, 1, 1, 2]

        npt.assert_array_equal(
            qartod.spike_test(inp=arr,
                              suspect_threshold=self.suspect_threshold,
                              fail_threshold=self.fail_threshold), expected)
Ejemplo n.º 3
0
    def test_spike_negative_vals(self):
        """
        Test to make spike detection works properly for negative values.
        """
        arr = [-10, -12, -999.99, -13, -15, -40, -9, -9]

        # First and last elements should always be good data, unless someone
        # has set a threshold to zero.
        expected = [1, 4, 4, 4, 1, 3, 1, 1]

        inputs = [
            arr,
            np.asarray(arr, dtype=np.floating),
            dask_arr(np.asarray(arr, dtype=np.floating))
        ]
        for i in inputs:
            npt.assert_array_equal(
                qartod.spike_test(inp=i,
                                  suspect_threshold=self.suspect_threshold,
                                  fail_threshold=self.fail_threshold),
                expected)
Ejemplo n.º 4
0
    def test_spike(self):
        """
        Test to make ensure single value spike detection works properly.
        """

        arr = [10, 12, 999.99, 13, 15, 40, 9, 9]

        # First and last elements should always be good data, unless someone
        # has set a threshold to zero.
        expected = [2, 4, 4, 4, 1, 3, 1, 2]

        inputs = [
            arr,
            np.asarray(arr, dtype=np.float64),
            dask_arr(np.asarray(arr, dtype=np.float64))
        ]
        for i in inputs:
            npt.assert_array_equal(
                qartod.spike_test(inp=i,
                                  suspect_threshold=self.suspect_threshold,
                                  fail_threshold=self.fail_threshold),
                expected)
Ejemplo n.º 5
0
    def test_spike_masked(self):
        """
        Test with missing data.
        """

        arr = [
            10, 12, 999.99, 13, 15, 40, 9, 9, None, 10, 10, 999.99, 10, None
        ]

        # First and last elements should always be good data, unless someone
        # has set a threshold to zero.
        expected = [1, 4, 4, 4, 1, 3, 1, 1, 9, 9, 4, 4, 4, 9]

        inputs = [
            arr,
            np.asarray(arr, dtype=np.floating),
            dask_arr(np.asarray(arr, dtype=np.floating))
        ]
        for i in inputs:
            npt.assert_array_equal(
                qartod.spike_test(inp=i,
                                  suspect_threshold=self.suspect_threshold,
                                  fail_threshold=self.fail_threshold),
                expected)