# Path: cotede/qctests/qctests.py
# def frozen_profile():
# def grey_list():
# def valid_speed():
# def gross_sensor_drift():
# def platform_identification():


import logging
import numpy as np
from numpy import ma
from .qctests import QCCheckVar

"""

Threshold - |median(v0..v4)| + |sigma(v0..v4)|
y = ma.masked_all_like(x)
yy = np.stack([x[:-4], x[1:-3], x[2:-2], x[3:-1], x[4:]])
y[2:-2] = np.median(yy, axis=0) + yy.std(axis=0)
y = np.stack([x[:-4], x[1:-3], x[2:-2], x[3:-1], x[4:]])
"""





module_logger = logging.getLogger(__name__)


def spike(x):
    """ Spike
    """
    if isinstance(x, ma.MaskedArray):
        x[x.mask] = np.nan
        x = x.data

    x = np.atleast_1d(x)
    y = np.nan * x
    y[1:-1] = np.abs(x[1:-1] - (x[:-2] + x[2:]) / 2.0) - np.abs((x[2:] - x[:-2]) / 2.0)
    return y



# Path: cotede/qctests/qctests.py
# def frozen_profile():
# def grey_list():
# def valid_speed():
# def gross_sensor_drift():
# def platform_identification():


# Path: cotede/qctests/spike.py
import logging
import numpy as np
from numpy import ma
from .qctests import QCCheckVar


"""

Threshold - |median(v0..v4)| + |sigma(v0..v4)|
y = ma.masked_all_like(x)
yy = np.stack([x[:-4], x[1:-3], x[2:-2], x[3:-1], x[4:]])
y[2:-2] = np.median(yy, axis=0) + yy.std(axis=0)
y = np.stack([x[:-4], x[1:-3], x[2:-2], x[3:-1], x[4:]])
"""





module_logger = logging.getLogger(__name__)


def spike(x):
    """ Spike
    """
    if isinstance(x, ma.MaskedArray):
        x[x.mask] = np.nan
        x = x.data

    x = np.atleast_1d(x)
    y = np.nan * x
    y[1:-1] = np.abs(x[1:-1] - (x[:-2] + x[2:]) / 2.0) - np.abs((x[2:] - x[:-2]) / 2.0)
    return y



class Spike(QCCheckVar):