gwdetchar.utils module

Utility methods

gwdetchar.utils.natural_sort(ls, key=<class 'str'>)[source]

Sort a list the way that humans expect.

This differs from the built-in sorted method by building a custom key to sort numeric parts by value, not by character content, so that ‘2’ gets sorted before ‘10’, for example.

Parameters:
lsiterable

iterable to sort

keycallable

sorting key

Returns:
sortedlist

a sorted version of the input list

gwdetchar.utils.parse_html(html)[source]

Parse a string containing raw HTML code

gwdetchar.utils.table_from_segments(flagdict, sngl_burst=False, snr=10.0, frequency=100.0)[source]

Build an EventTable from a DataQualityDict

gwdetchar.utils.table_from_times(times, names=('time', 'frequency', 'snr'), snr=10.0, frequency=100.0, **kwargs)[source]

Build an EventTable from a DataQualityDict

Parameters:
timesnumpy.ndarray

a 1D array of GPS times

namestuple, list, optional

the list of names to use

snrfloat, optional

the SNR to assign to all ‘event triggers’

frequencyfloat, optional

the frequency to assign to all ‘event triggers’

**kwargs

other keyword arguments to pass to the EventTable constructor

Returns:
tableEventTable

a new table filled with events at the given times