from ..plugin.curve import CurveArgument
from ..plugin.playlist import FilterCommand
from ..plugin.vclamp import scale
-from ..util.peak import find_peaks, find_peaks_arguments, Peak
+from ..util.peak import find_peaks, find_peaks_arguments, Peak, _kwargs
class ConvFiltPlugin (Plugin):
start_index += 1
conv = numpy.convolve(d_data[start_index:], params['convolution'],
mode='valid')
- kwargs = dict([(a.name, params[a.name]) for a in find_peaks_arguments])
- peaks = find_peaks(conv, **kwargs)
+ peaks = find_peaks(conv, **_kwargs(params, find_peaks_arguments,
+ argument_input_keys=True))
for peak in peaks:
peak.name = 'convolution of %s with %s' \
% (params['deflection column name'], params['convolution'])
from ..plugin.curve import CurveArgument
from ..plugin.playlist import FilterCommand
from ..plugin.vclamp import scale
-from ..util.peak import find_peaks, find_peaks_arguments, Peak
+from ..util.peak import find_peaks, find_peaks_arguments, Peak, _kwargs
class FlatFiltPlugin (Plugin):
# function, just detecting peaks.
super(FlatPeaksCommand, self).__init__(
name='flat filter peaks',
- arguments=[CurveArgument] + config_arguments,
+ arguments=[
+ CurveArgument,
+ Argument('blind window', type='float', default=20e-9, help="""
+Meters after the contact point where we do not count peaks to avoid
+non-specific surface interaction.
+""".strip()),
+ Argument('median window', type='float', default=7, help="""
+Number of points to use in the initial rolling median filter.
+""".strip()),
+ ] + config_arguments,
help=self.__doc__, plugin=plugin)
def _run(self, hooke, inqueue, outqueue, params):
z_data,d_data,params = self._setup(params)
start_index = 0
- while z_data[start_index] < params['bind window']:
+ while z_data[start_index] < params['blind window']:
start_index += 1
median = medfilt(d_data[start_index:], params['median window']),
deriv = diff(median)
- kwargs = dict([(a.name, params[a.name]) for a in find_peaks_arguments])
- peaks = find_peaks(deriv, **kwargs)
+ peaks = find_peaks(deriv, **_kwargs(params, find_peaks_arguments,
+ argument_input_keys=True))
for peak in peaks:
- peak.name = 'flat filter of %s with %s' \
- % (params['deflection column name'], params['convolution'])
+ peak.name = 'flat filter of %s' % (params['deflection column name'])
peak.index += start_index
outqueue.put(peaks)
for key,value in params.items():
if value == None: # Use configured default value.
params[key] = self.plugin.config[key]
+ # TODO: better option parser to do this automatically by Argument.type
+ for key in ['max cut', 'min deviation', 'min points', 'see double', 'stable']:
+ params[key] = float(params[key])
+ # TODO: convert 'see double' from nm to points
return z_data,d_data,params
class FlatFilterCommand (FilterCommand):