gwdetchar.utils module

Utility methods

class gwdetchar.utils.GWHTMLParser(*, convert_charrefs=True)[source]

Bases: html.parser.HTMLParser

See https://docs.python.org/3/library/html.parser.html.

Methods

check_for_whole_start_tag(self, i)
close(self) Handle any buffered data.
feed(self, data) Feed data to the parser.
get_starttag_text(self) Return full source of start tag: ‘<…>’.
getpos(self) Return current line number and offset.
goahead(self, end)
handle_charref(self, name)
handle_comment(self, data)
handle_entityref(self, name)
handle_pi(self, data)
handle_startendtag(self, tag, attrs)
parse_bogus_comment(self, i[, report])
parse_comment(self, i[, report])
parse_declaration(self, i)
parse_endtag(self, i)
parse_html_declaration(self, i)
parse_marked_section(self, i[, report])
parse_pi(self, i)
parse_starttag(self, i)
reset(self) Reset this instance.
unescape(self, s)
updatepos(self, i, j)
clear_cdata_mode  
error  
handle_data  
handle_decl  
handle_endtag  
handle_starttag  
set_cdata_mode  
unknown_decl  
handle_data(self, data)[source]
handle_decl(self, data)[source]
handle_endtag(self, tag)[source]
handle_starttag(self, tag, attrs)[source]
gwdetchar.utils.natural_sort(l, 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:

l : iterable

iterable to sort

key : callable

sorting key

Returns:

sorted : list

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:

times : numpy.ndarray

a 1D array of GPS times

names : tuple, list, optional

the list of names to use

snr : float, optional

the SNR to assign to all ‘event triggers’

frequency : float, optional

the frequency to assign to all ‘event triggers’

**kwargs

other keyword arguments to pass to the EventTable constructor

Returns:

table : EventTable

a new table filled with events at the given times