# Path: cotede/qctests/deepest_pressure.py
# class DeepestPressure(QCCheckVar):
#     """Deepest measurable pressure
# 
#        Some probes have a maximum operational depth, which can be used as a
#        hard threshold. For instance, on Argo, Solo operates up to 2000m while
#        Deep Solo goes up to 6000m.
#     """
#     flag_bad = 3
# 
#     def test(self, tol_frac=0.1):
#         """Apply test to define flags
# 
#            tol_frac is the tolerance fraction of the threshold. Argo uses a
#            tolerance of 10%, so that every measurement deeper than the 110%
#            of the threshold fails this flag.
#         """
#         self.flags = {}
# 
#         assert "PRES" in self.data.keys(), "Missing pressure record"
# 
#         threshold = self.cfg["threshold"]
#         assert (
#             (np.size(threshold) == 1)
#             and (threshold is not None)
#             and (np.isfinite(threshold))
#         )
#         threshold *= (1 + tol_frac)
# 
#         flag = np.zeros(self.data[self.varname].shape, dtype="i1")
#         feature = self.data["PRES"]
#         flag[np.nonzero(feature > threshold)] = self.flag_bad
#         flag[np.nonzero(feature <= threshold)] = self.flag_good
#         flag[ma.getmaskarray(self.data[self.varname])] = 9
#         self.flags["deepest_pressure"] = flag
# 
# Path: tests/data.py
# class DummyData(object):
#     def __init__(self):
#         self.attrs = {
#                 'datetime': datetime(2016,6,4),
#                 'LATITUDE': 15, 'LONGITUDE': -38}
#         self.data = {
#                 'PRES': ma.fix_invalid(
#                     [2, 6, 10, 21, 44, 79, 100, 150,
#                         200, 400, 410, 650, 1000, 2000, 5000]),
#                 'TEMP': ma.fix_invalid(
#                     [25.32, 25.34, 25.34, 25.31, 24.99, 23.46, 21.85, 17.95,
#                         15.39, 11.08, 6.93, 7.93, 5.71, 3.58, np.nan]),
#                 'PSAL': ma.fix_invalid(
#                     [36.49, 36.51, 36.52, 36.53, 36.59, 36.76, 36.81, 36.39,
#                         35.98, 35.30, 35.28, 34.93, 34.86, np.nan, np.nan])}
# 
#     def __getitem__(self, key):
#         return self.data[key]
# 
#     def keys(self):
#         return self.data.keys()
# 
#     @property
#     def attributes(self):
#         print('attributes will be removed. Use attrs instead!')
#         return self.attrs


import numpy as np
from numpy import ma
from cotede.qctests import DeepestPressure
from ..data import DummyData
# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst

"""Validate Deepest Pressure test
"""




def test_default():
    profile = DummyData()

    cfg = {'threshold': 1000}


# Path: cotede/qctests/deepest_pressure.py
# class DeepestPressure(QCCheckVar):
#     """Deepest measurable pressure
# 
#        Some probes have a maximum operational depth, which can be used as a
#        hard threshold. For instance, on Argo, Solo operates up to 2000m while
#        Deep Solo goes up to 6000m.
#     """
#     flag_bad = 3
# 
#     def test(self, tol_frac=0.1):
#         """Apply test to define flags
# 
#            tol_frac is the tolerance fraction of the threshold. Argo uses a
#            tolerance of 10%, so that every measurement deeper than the 110%
#            of the threshold fails this flag.
#         """
#         self.flags = {}
# 
#         assert "PRES" in self.data.keys(), "Missing pressure record"
# 
#         threshold = self.cfg["threshold"]
#         assert (
#             (np.size(threshold) == 1)
#             and (threshold is not None)
#             and (np.isfinite(threshold))
#         )
#         threshold *= (1 + tol_frac)
# 
#         flag = np.zeros(self.data[self.varname].shape, dtype="i1")
#         feature = self.data["PRES"]
#         flag[np.nonzero(feature > threshold)] = self.flag_bad
#         flag[np.nonzero(feature <= threshold)] = self.flag_good
#         flag[ma.getmaskarray(self.data[self.varname])] = 9
#         self.flags["deepest_pressure"] = flag
# 
# Path: tests/data.py
# class DummyData(object):
#     def __init__(self):
#         self.attrs = {
#                 'datetime': datetime(2016,6,4),
#                 'LATITUDE': 15, 'LONGITUDE': -38}
#         self.data = {
#                 'PRES': ma.fix_invalid(
#                     [2, 6, 10, 21, 44, 79, 100, 150,
#                         200, 400, 410, 650, 1000, 2000, 5000]),
#                 'TEMP': ma.fix_invalid(
#                     [25.32, 25.34, 25.34, 25.31, 24.99, 23.46, 21.85, 17.95,
#                         15.39, 11.08, 6.93, 7.93, 5.71, 3.58, np.nan]),
#                 'PSAL': ma.fix_invalid(
#                     [36.49, 36.51, 36.52, 36.53, 36.59, 36.76, 36.81, 36.39,
#                         35.98, 35.30, 35.28, 34.93, 34.86, np.nan, np.nan])}
# 
#     def __getitem__(self, key):
#         return self.data[key]
# 
#     def keys(self):
#         return self.data.keys()
# 
#     @property
#     def attributes(self):
#         print('attributes will be removed. Use attrs instead!')
#         return self.attrs


# Path: tests/qctests/test_qc_deepest_pressure.py
import numpy as np
from numpy import ma
from cotede.qctests import DeepestPressure
from ..data import DummyData

# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst

"""Validate Deepest Pressure test
"""




def test_default():
    profile = DummyData()

    cfg = {'threshold': 1000}


    y = DeepestPressure(profile, 'TEMP', cfg)