ld2daps/ld2dap/Treshold.py
2018-04-12 19:15:50 +02:00

29 lines
893 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 ld2dap.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()
for stack in metadata:
for d, s in zip(stack.desc, stack.symb):
d.append('treshold {}'.format(self.treshold))
s.append('T_{{{}}}'.format(self.treshold))
return data * (data < self.treshold) + self.max_value * (data >= self.treshold), metadata