def test_dataqc_localrangetest_data(self):
        testcases = [
                'test-data/dataqc_localrangetest_testcase01.mat',
                'test-data/dataqc_localrangetest_testcase02.mat',
                # This one fails because MATLAB has a different interpolation alg
                #'test-data/dataqc_localrangetest_testcase03.mat',
                ]
        for tc in testcases:
            if not os.path.exists(tc):
                raise unittest.SkipTest('%s not found' % tc)

            import scipy.io
            mat = scipy.io.loadmat(tc)

            dat = mat['dat']
            dat = dat[:,0]

            z = mat['z']
            z = z[:,0]

            datlimz = mat['datlimz']
            datlimz  = datlimz[:,0]

            datlim = mat['datlim']

            expected = mat['out']
            expected = expected[:,0]

            qc = qcfunc.dataqc_localrangetest(dat, z, datlim, datlimz)
            np.testing.assert_array_equal(qc, expected)
    def test_dataqc_localrangetest(self):
        """
        Test of the dataqc_localrangetest function.

        Test values calculated in Matlab R2012b using DPS function.

        OOI (2012). Data Product Specification for Local Range Test. Document
            Control Number 1341-10005. https://alfresco.oceanobservatories.org/
            (See: Company Home >> OOI >> Controlled >> 1000 System Level >>
            1341-10005_Data_Product_SPEC_LOCLRNG_OOI.pdf)

        Implemented by Christopher Wingard, April 2013
        """
        dat = np.array([3.5166, 8.3083, 5.8526, 5.4972, 9.1719,
                        2.8584, 7.5720, 7.5373, 3.8045, 5.6782])

        z = np.array([0.1517, 0.1079, 1.0616, 1.5583, 1.8680,
                      0.2598, 1.1376, 0.9388, 0.0238, 0.6742])

        datlim = np.array([[0, 2], [0, 2], [1, 8], [1, 9], [1, 10]])

        datlimz = np.array([0, 0.5, 1, 1.5, 2])

        qcflag = np.array([0, 0, 1, 1, 1, 0, 1, 0, 0, 0], dtype='int8')

        got = qcfunc.dataqc_localrangetest(dat, z, datlim, datlimz)

        self.assertTrue(np.array_equal(got, qcflag))
    def test_dataqc_localrangetest_data(self):
        testcases = [
                'test-data/dataqc_localrangetest_testcase01.mat',
                'test-data/dataqc_localrangetest_testcase02.mat',
                # This one fails because MATLAB has a different interpolation alg
                #'test-data/dataqc_localrangetest_testcase03.mat',
                ]
        for tc in testcases:
            if not os.path.exists(tc):
                raise unittest.SkipTest('%s not found' % tc)

            import scipy.io
            mat = scipy.io.loadmat(tc)

            dat = mat['dat']
            dat = dat[:,0]

            z = mat['z']
            z = z[:,0]

            datlimz = mat['datlimz']
            datlimz  = datlimz[:,0]

            datlim = mat['datlim']

            expected = mat['out']
            expected = expected[:,0]

            qc = qcfunc.dataqc_localrangetest(dat, z, datlim, datlimz)
            np.testing.assert_array_equal(qc, expected)
    def test_dataqc_localrangetest(self):
        """
        Test of the dataqc_localrangetest function.

        Test values calculated in Matlab R2012b using DPS function.

        OOI (2012). Data Product Specification for Local Range Test. Document
            Control Number 1341-10005. https://alfresco.oceanobservatories.org/
            (See: Company Home >> OOI >> Controlled >> 1000 System Level >>
            1341-10005_Data_Product_SPEC_LOCLRNG_OOI.pdf)

        Implemented by Christopher Wingard, April 2013
        """
        dat = np.array([3.5166, 8.3083, 5.8526, 5.4972, 9.1719,
                        2.8584, 7.5720, 7.5373, 3.8045, 5.6782])

        z = np.array([0.1517, 0.1079, 1.0616, 1.5583, 1.8680,
                      0.2598, 1.1376, 0.9388, 0.0238, 0.6742])

        datlim = np.array([[0, 2], [0, 2], [1, 8], [1, 9], [1, 10]])

        datlimz = np.array([0, 0.5, 1, 1.5, 2])

        qcflag = np.array([0, 0, 1, 1, 1, 0, 1, 0, 0, 0], dtype='int8')

        got = qcfunc.dataqc_localrangetest(dat, z, datlim, datlimz)

        self.assertTrue(np.array_equal(got, qcflag))
    def process_local_range_test(self, coverage, parameter, input_name, datlim, datlimz):
        qc_array = coverage.get_parameter_values(parameter.name)
        indexes = np.where(qc_array == -88)[0]

        from ion_functions.qc.qc_functions import dataqc_localrangetest
        value_array = coverage.get_parameter_values(input_name)
        # z_parameter_name needs to come from, I guess the column headings... 
        # I also need to deal with the case where there are multiple axes... 
        # I don't have a good feeling about this.
        z_parameter_name = None
        z_array = coverage.get_parameter_values(z_parameter_name)

        qc_array = dataqc_localrangetest(value_array, z_array, datlim, datlimz)
        return_dictionary = {
                coverage.temporal_parameter_name : time_array[indexes],
                parameter.name : qc_array[indexes]
        }