gwsumm.data.mathutils module

Handle arbitrary mathematical operations applied to data series

gwsumm.data.mathutils.get_operator(opstr)[source]
gwsumm.data.mathutils.get_with_math(channel, segments, load_func, get_func, **ioargs)[source]

Get data with optional arbitrary math definitions

Parameters:
channelstr

name of the meta-channel to create

segments~gwpy.segments.SegmentList

segments over which to create the new channel

load_funccallable

method to call to load data from disk

get_funccallable

method to call to return channel data

**ioargs

all other kwargs are passed to the load_func and get_func

Returns:
datalistTimeSeriesList, or similar

a structured list of data objects, probably either for TimeSeries or Spectrogram

gwsumm.data.mathutils.parse_math_definition(definition)[source]

Parse the definition for a channel combination

This method can only handle commutative operations, no fancy stuff with parentheses. Something like A * B is fine, but not (A + B) ^ 2

All operands, operators, and values should be space-separated.

Returns:
channelslist of tuple

a list of 2-tuples containing the name of each channel, and any mathematical operations to be applied to that channel only

operatorslist of callable

the list of functions that combine one channel and the previous, if channels is a list of length N, then the operators list will have length N-1

Examples

>>> parse_math_definition('H1:TEST * L1:TEST^2')
([('H1:TEST', None), ('L1:TEST', (<built-in function pow>, 2.0))],
 [<built-in function mul>])