Onyx logo

Previous topic

onyx.signalprocessing.processor – Processor object pushes data through objects in a graph

Next topic

onyx.signalprocessing.spectrum – Module for spectrum generation.

This Page

onyx.signalprocessing.scale – Numerical data-scaling objects

class onyx.signalprocessing.scale.Abs(arg=None)

Bases: onyx.signalprocessing.sigprocbase

Takes the absolute value of the components of (possibly complex-valued) data vectors. Returns a tuple of the results.

>>> a = Abs()
>>> a([1, 2, -3])
(1, 2, 3)
>>> c = tuple(complex(3 * x, -4 * x) for x in xrange(7))
>>> c
(0j, (3-4j), (6-8j), (9-12j), (12-16j), (15-20j), (18-24j))
>>> a(c)
(0, 5, 10, 15, 20, 25, 30)
check_serial_version(version)
configure(**kwargs)
get_serial_factory_args()
get_serial_factory_name()
get_serial_module_name()
get_serial_version()
process_one(item)
process_some(items)

Process each of the elements of ‘items’. Return a list of results.

send_many(inputs)
serialize()

Return a serialized version of this object as a tuple of strings. The form of the tuple is: (module_name, factory_name, version, arg0, arg1, ...) where the version and the args will be passed to the factory to construct the object.

class onyx.signalprocessing.scale.Log(args=None)

Bases: onyx.signalprocessing.sigprocbase

Takes the log of the components of data vectors. Actually computes (scale * log_base) of the values given, where scale defaults to 1 and base defaults to that of the natural log given by math.e in the math module.

Returns a tuple of the results.

>>> def roundem(iterable): return tuple(number(round(x, 3)) for x in iterable)
>>> log2 = Log('base=2')
>>> log2([1,2,4,8])
(0.0, 1.0, 2.0, 3.0)
>>> roundem(log2(sqrt(2)**x for x in xrange(11)))
(0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5)
>>> loge = Log()
>>> loge([1, exp(1)])
(0.0, 1.0)
>>> dBamp = Log('base=10 scale=20')
>>> roundem(dBamp(sqrt(10)**x for x in xrange(11)))
(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
>>> dBpower = Log('base=10 scale=10')
>>> roundem(dBpower(10**x for x in xrange(11)))
(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
check_serial_version(version)
configure(**kwargs)
get_serial_factory_args()
get_serial_factory_name()
get_serial_module_name()
get_serial_version()
process_one(item)
process_some(items)

Process each of the elements of ‘items’. Return a list of results.

send_many(inputs)
serialize()

Return a serialized version of this object as a tuple of strings. The form of the tuple is: (module_name, factory_name, version, arg0, arg1, ...) where the version and the args will be passed to the factory to construct the object.

onyx.signalprocessing.scale.number(value)

Change value from string to complex to float to int if such changes do not lose numerical precision.

>>> number(23.0)
23
>>> number(23.5+0j)
23.5
>>> number('23.0+0j')
23