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


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

if (RoC_small (t) + 0.5 × RoC_medium (t)) < (cRoC_small (t - 1) + 0.5 × cRoC_medium (t - 1)):
    cRoC_i (t) = RoC_i (t)
else
    cRoC_i (t) = (1 - k) × RoC_i(t) + k * cRoC_i(t - 1)

i = small, medium, large
"""



module_logger = logging.getLogger(__name__)

def cum_rate_of_change(x, memory):
    """Cummulative rate of change
    """
    if isinstance(x, ma.MaskedArray):
        x[x.mask] = np.nan
        x = x.data

    y = np.nan * np.ones_like(x)
    y[1:] = np.absolute(np.diff(x))

    for i in range(2, y.size):
        if y[i] < y[i - 1]:
            y[i] = (1 - memory) * y[i] + memory * y[i - 1]

    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/cum_rate_of_change.py
import numpy as np
import logging
from numpy import ma
from .qctests import QCCheckVar


if (RoC_small (t) + 0.5 × RoC_medium (t)) < (cRoC_small (t - 1) + 0.5 × cRoC_medium (t - 1)):
    cRoC_i (t) = RoC_i (t)
else
    cRoC_i (t) = (1 - k) × RoC_i(t) + k * cRoC_i(t - 1)

i = small, medium, large
"""



module_logger = logging.getLogger(__name__)

def cum_rate_of_change(x, memory):
    """Cummulative rate of change
    """
    if isinstance(x, ma.MaskedArray):
        x[x.mask] = np.nan
        x = x.data

    y = np.nan * np.ones_like(x)
    y[1:] = np.absolute(np.diff(x))

    for i in range(2, y.size):
        if y[i] < y[i - 1]:
            y[i] = (1 - memory) * y[i] + memory * y[i - 1]

    return y



class CumRateOfChange(QCCheckVar):