24 lines
680 B
Python
24 lines
680 B
Python
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
# \file Treshold.py
|
|
# \brief TODO
|
|
# \author Florent Guiotte <florent.guiotte@gmail.com>
|
|
# \version 0.1
|
|
# \date 09 avril 2018
|
|
#
|
|
# TODO details
|
|
|
|
from core import Filter
|
|
|
|
class Treshold(Filter):
|
|
def __init__(self, treshold, max_value=None):
|
|
super().__init__(self.__class__.__name__)
|
|
self.treshold = treshold
|
|
self.max_value = max_value #if max_value is not None else treshold
|
|
|
|
def _process(self, data, metadata):
|
|
if self.max_value is None:
|
|
self.max_value = data[data < self.treshold].max()
|
|
|
|
return data * (data < self.treshold) + self.max_value * (data >= self.treshold), metadata
|