code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
# parse channel type from name, # e.g. 'L1:GDS-CALIB_STRAIN,reduced' -> 'L1:GDS-CALIB_STRAIN', 'reduced' name, ctype = _strip_ctype(name, ctype, connection.get_protocol()) # query NDS2 found = connection.find_channels(name, ctype, dtype, *sample_rate) # if don't care about defaults, just ...
def _find_channel(connection, name, ctype, dtype, sample_rate, unique=False)
Internal method to find a single channel Parameters ---------- connection : `nds2.connection`, optional open NDS2 connection to use for query name : `str` the name of the channel to find ctype : `int` the NDS2 channel type to match dtype : `int` the NDS2 data ...
7.148093
6.914095
1.033844
# parse channel type from name (e.g. 'L1:GDS-CALIB_STRAIN,reduced') try: name, ctypestr = name.rsplit(',', 1) except ValueError: pass else: ctype = Nds2ChannelType.find(ctypestr).value # NDS1 stores channels with trend suffix, so we put it back: if protocol =...
def _strip_ctype(name, ctype, protocol=2)
Strip the ctype from a channel name for the given nds server version This is needed because NDS1 servers store trend channels _including_ the suffix, but not raw channels, and NDS2 doesn't do this.
7.886587
6.101226
1.292623
# pylint: disable=unused-argument from ..segments import (Segment, SegmentList, SegmentListDict) connection.set_epoch(start, end) # map user-given real names to NDS names names = list(map( _get_nds2_name, find_channels(channels, epoch=(start, end), ...
def get_availability(channels, start, end, connection=None, host=None, port=None)
Query an NDS2 server for data availability Parameters ---------- channels : `list` of `str` list of channel names to query; this list is mapped to NDS channel names using :func:`find_channels`. start : `int` GPS start time of query end : `int` GPS end time of query...
7.862071
5.877718
1.337606
if start % 60: start = int(start) // 60 * 60 if end % 60: end = int(end) // 60 * 60 + 60 return int(start), int(end)
def minute_trend_times(start, end)
Expand a [start, end) interval for use in querying for minute trends NDS2 requires start and end times for minute trends to be a multiple of 60 (to exactly match the time of a minute-trend sample), so this function expands the given ``[start, end)`` interval to the nearest multiples. Parameters --...
2.415614
2.68673
0.899091
try: return cls._member_map_[name] except KeyError: for ctype in cls._member_map_.values(): if ctype.name == name: return ctype raise ValueError('%s is not a valid %s' % (name, cls.__name__))
def find(cls, name)
Returns the NDS2 channel type corresponding to the given name
2.612319
2.620266
0.996967
try: return cls._member_map_[dtype] except KeyError: try: dtype = numpy.dtype(dtype).type except TypeError: for ndstype in cls._member_map_.values(): if ndstype.value is dtype: return...
def find(cls, dtype)
Returns the NDS2 type corresponding to the given python type
2.550763
2.507691
1.017176
if isinstance(connection, FflConnection): return type(connection)(connection.ffldir) kw = {'context': connection._context} if connection.port != 80 else {} return connection.__class__(connection.host, port=connection.port, **kw)
def reconnect(connection)
Open a new datafind connection based on an existing connection This is required because of https://git.ligo.org/lscsoft/glue/issues/1 Parameters ---------- connection : :class:`~gwdatafind.http.HTTPConnection` or `FflConnection` a connection object (doesn't need to be open) Returns --...
7.569006
6.293011
1.202764
# if looking for a trend channel, prioritise the matching type for trendname, trend_regex in [ ('m-trend', MINUTE_TREND_TYPE), ('s-trend', SECOND_TREND_TYPE), ]: if trend == trendname and trend_regex.match(ftype): return 0, len(ftype) # otherwise rank th...
def _type_priority(ifo, ftype, trend=None)
Prioritise the given GWF type based on its name or trend status. This is essentially an ad-hoc ordering function based on internal knowledge of how LIGO does GWF type naming.
4.695883
4.963995
0.945989
for path in files: try: if os.stat(path).st_blocks == 0: return True except AttributeError: # windows doesn't have st_blocks return False return False
def on_tape(*files)
Determine whether any of the given files are on tape Parameters ---------- *files : `str` one or more paths to GWF files Returns ------- True/False : `bool` `True` if any of the files are determined to be on tape, otherwise `False`
4.934929
5.422453
0.910092
@wraps(func) def wrapped(*args, **kwargs): if kwargs.get('connection') is None: kwargs['connection'] = _choose_connection(host=kwargs.get('host'), port=kwargs.get('port')) try: return func(*args, **kwargs) ...
def with_connection(func)
Decorate a function to open a new datafind connection if required This method will inspect the ``connection`` keyword, and if `None` (or missing), will use the ``host`` and ``port`` keywords to open a new connection and pass it as ``connection=<new>`` to ``func``.
2.623379
2.321572
1.130001
try: return find_frametype(channel, gpstime=(start, end), frametype_match=frametype_match, allow_tape=allow_tape, on_gaps='error', connection=connection, host=host, port=port) except RuntimeError: # gaps (or ...
def find_best_frametype(channel, start, end, frametype_match=None, allow_tape=True, connection=None, host=None, port=None)
Intelligently select the best frametype from which to read this channel Parameters ---------- channel : `str`, `~gwpy.detector.Channel` the channel to be found start : `~gwpy.time.LIGOTimeGPS`, `float`, `str` GPS start time of period of interest, any input parseable by `~gwpy.t...
2.929047
3.363651
0.870794
return sorted(connection.find_types(observatory, match=match), key=lambda x: _type_priority(observatory, x, trend=trend))
def find_types(observatory, match=None, trend=None, connection=None, **connection_kw)
Find the available data types for a given observatory. See also -------- gwdatafind.http.HTTPConnection.find_types FflConnection.find_types for details on the underlying method(s)
5.354008
6.051663
0.884717
return connection.find_urls(observatory, frametype, start, end, on_gaps=on_gaps)
def find_urls(observatory, frametype, start, end, on_gaps='error', connection=None, **connection_kw)
Find the URLs of files of a given data type in a GPS interval. See also -------- gwdatafind.http.HTTPConnection.find_urls FflConnection.find_urls for details on the underlying method(s)
2.546567
3.690238
0.690082
try: return self.paths[(site, frametype)] except KeyError: self._find_paths() return self.paths[(site, frametype)]
def ffl_path(self, site, frametype)
Returns the path of the FFL file for the given site and frametype Examples -------- >>> from gwpy.io.datafind import FflConnection >>> conn = FflConnection() >>> print(conn.ffl_path('V', 'V1Online')) /virgoData/ffl/V1Online.ffl
3.152627
4.571375
0.689645
self._find_paths() types = [tag for (site_, tag) in self.paths if site in (None, site_)] if match is not None: match = re.compile(match) return list(filter(match.search, types)) return types
def find_types(self, site=None, match=r'^(?!lastfile|spectro|\.).*')
Return the list of known data types. This is just the basename of each FFL file found in the FFL directory (minus the ``.ffl`` extension)
4.996024
5.349237
0.933969
span = Segment(gpsstart, gpsend) cache = [e for e in self._read_ffl_cache(site, frametype) if e.observatory == site and e.description == frametype and e.segment.intersects(span)] urls = [e.path for e in cache] missing = SegmentList([span]) - cac...
def find_urls(self, site, frametype, gpsstart, gpsend, match=None, on_gaps='warn')
Find all files of the given type in the [start, end) GPS interval.
4.784491
4.552074
1.051057
from ligo.lw import ( ligolw, array as ligolw_array, param as ligolw_param ) @ligolw_array.use_in @ligolw_param.use_in class ArrayContentHandler(ligolw.LIGOLWContentHandler): pass return ArrayContentHandler
def series_contenthandler()
Build a `~xml.sax.handlers.ContentHandler` to read a LIGO_LW <Array>
7.820472
5.028478
1.555236
from ligo.lw.ligolw import (LIGO_LW, Time, Array, Dim) from ligo.lw.param import get_param # read document xmldoc = read_ligolw(source, contenthandler=series_contenthandler()) # parse match dict if match is None: match = dict() def _is_match(elem): try: if...
def read_series(source, name, match=None)
Read a `Series` from LIGO_LW-XML Parameters ---------- source : `file`, `str`, :class:`~ligo.lw.ligolw.Document` file path or open LIGO_LW-format XML file name : `str` name of the relevant `LIGO_LW` element to read match : `dict`, optional dict of (key, value) `Param` pair...
4.313878
3.884148
1.110637
args = self.args fftlength = float(args.secpfft) overlap = args.overlap self.log(2, "Calculating spectrum secpfft: %s, overlap: %s" % (fftlength, overlap)) if overlap is not None: overlap *= fftlength self.log(3, 'Reference channel:...
def make_plot(self)
Generate the coherence plot from all time series
4.412125
4.201653
1.050092
leg = super(Coherence, self).set_legend() if leg is not None: leg.set_title('Coherence with:') return leg
def set_legend(self)
Create a legend for this product
5.859506
5.504852
1.064426
if name is None or isinstance(name, units.UnitBase): return name try: # have we already identified this unit as unrecognised? return UNRECOGNIZED_UNITS[name] except KeyError: # no, this is new # pylint: disable=unexpected-keyword-arg try: return units.Unit...
def parse_unit(name, parse_strict='warn', format='gwpy')
Attempt to intelligently parse a `str` as a `~astropy.units.Unit` Parameters ---------- name : `str` unit name to parse parse_strict : `str` one of 'silent', 'warn', or 'raise' depending on how pedantic you want the parser to be format : `~astropy.units.format.Base` ...
4.688336
4.955321
0.946122
# read params params = dict(frevent.GetParam()) params['time'] = float(LIGOTimeGPS(*frevent.GetGTime())) params['amplitude'] = frevent.GetAmplitude() params['probability'] = frevent.GetProbability() params['timeBefore'] = frevent.GetTimeBefore() params['timeAfter'] = frevent.GetTimeAfte...
def _row_from_frevent(frevent, columns, selection)
Generate a table row from an FrEvent Filtering (``selection``) is done here, rather than in the table reader, to enable filtering on columns that aren't being returned.
4.463645
4.449137
1.003261
# open frame file if isinstance(filename, FILE_LIKE): filename = filename.name stream = io_gwf.open_gwf(filename) # parse selections and map to column indices if selection is None: selection = [] selection = parse_column_filters(selection) # read events row by row ...
def table_from_gwf(filename, name, columns=None, selection=None)
Read a Table from FrEvent structures in a GWF file (or files) Parameters ---------- filename : `str` path of GWF file to read name : `str` name associated with the `FrEvent` structures columns : `list` of `str` list of column names to read selection : `str`, `list` of...
5.125963
4.819983
1.063482
from LDAStools.frameCPP import (FrEvent, GPSTime) # create frame write_kw = {key: kwargs.pop(key) for key in ('compression', 'compression_level') if key in kwargs} frame = io_gwf.create_frame(name=name, **kwargs) # append row by row names = table.dtype.names for row in...
def table_to_gwf(table, filename, name, **kwargs)
Create a new `~frameCPP.FrameH` and fill it with data Parameters ---------- table : `~astropy.table.Table` the data to write filename : `str` the name of the file to write into **kwargs other keyword arguments (see below for references) See Also -------- gwpy....
5.382529
5.179337
1.039231
key = (data_format, data_class) if key not in _FETCHERS or force: _FETCHERS[key] = (function, usage) else: raise IORegistryError("Fetcher for format '{0}' and class '{1}' " "has already been " "defined".format( data_format,...
def register_fetcher(data_format, data_class, function, force=False, usage=None)
Register a new method to EventTable.fetch() for a given format Parameters ---------- data_format : `str` name of the format to be registered data_class : `type` the class that the fetcher returns function : `callable` the method to call from :meth:`EventTable.fetch` f...
3.762096
5.779483
0.65094
# this is a copy of astropy.io.regsitry.get_reader fetchers = [(fmt, cls) for fmt, cls in _FETCHERS if fmt == data_format] for fetch_fmt, fetch_cls in fetchers: if io_registry._is_best_match(data_class, fetch_cls, fetchers): return _FETCHERS[(fetch_fmt, fetch_cls)][0] else: ...
def get_fetcher(data_format, data_class)
Return the :meth:`~EventTable.fetch` function for the given format Parameters ---------- data_format : `str` name of the format data_class : `type` the class that the fetcher returns Raises ------ astropy.io.registry.IORegistryError if not registration is found mat...
3.883294
3.7178
1.044514
return io_registry.read(cls, source, *args, **kwargs)
def read(cls, source, *args, **kwargs)
Read data into a `FrequencySeries` Arguments and keywords depend on the output format, see the online documentation for full details for each format, the parameters below are common to most formats. Parameters ---------- source : `str`, `list` Source of data...
7.224488
14.005297
0.51584
from ..timeseries import TimeSeries nout = (self.size - 1) * 2 # Undo normalization from TimeSeries.fft # The DC component does not have the factor of two applied # so we account for it here dift = npfft.irfft(self.value * nout) / 2 new = TimeSeries(dift,...
def ifft(self)
Compute the one-dimensional discrete inverse Fourier transform of this `FrequencySeries`. Returns ------- out : :class:`~gwpy.timeseries.TimeSeries` the normalised, real-valued `TimeSeries`. See Also -------- :mod:`scipy.fftpack` for the definition o...
10.082074
9.952062
1.013064
f0 = self.f0.decompose().value N = (self.size - 1) * (self.df.decompose().value / df) + 1 fsamples = numpy.arange(0, numpy.rint(N), dtype=self.dtype) * df + f0 out = type(self)(numpy.interp(fsamples, self.frequencies.value, self.value)) ...
def interpolate(self, df)
Interpolate this `FrequencySeries` to a new resolution. Parameters ---------- df : `float` desired frequency resolution of the interpolated `FrequencySeries`, in Hz Returns ------- out : `FrequencySeries` the interpolated version of t...
4.80054
4.24673
1.130409
from ..utils.lal import from_lal_unit try: unit = from_lal_unit(lalfs.sampleUnits) except TypeError: unit = None channel = Channel(lalfs.name, unit=unit, dtype=lalfs.data.data.dtype) return cls(lalfs.data.data, channel=ch...
def from_lal(cls, lalfs, copy=True)
Generate a new `FrequencySeries` from a LAL `FrequencySeries` of any type
3.408876
3.40365
1.001535
return cls(fs.data, f0=0, df=fs.delta_f, epoch=fs.epoch, copy=copy)
def from_pycbc(cls, fs, copy=True)
Convert a `pycbc.types.frequencyseries.FrequencySeries` into a `FrequencySeries` Parameters ---------- fs : `pycbc.types.frequencyseries.FrequencySeries` the input PyCBC `~pycbc.types.frequencyseries.FrequencySeries` array copy : `bool`, optional, defaul...
7.924445
11.517562
0.688031
from pycbc import types if self.epoch is None: epoch = None else: epoch = self.epoch.gps return types.FrequencySeries(self.value, delta_f=self.df.to('Hz').value, epoch=epoch, copy=...
def to_pycbc(self, copy=True)
Convert this `FrequencySeries` into a `~pycbc.types.frequencyseries.FrequencySeries` Parameters ---------- copy : `bool`, optional, default: `True` if `True`, copy these data to a new array Returns ------- frequencyseries : `pycbc.types.frequencyseri...
5.816616
6.000271
0.969392
cls = kwargs.pop('cls', TimeSeries) cache = kwargs.pop('cache', None) verbose = kwargs.pop('verbose', False) # match file format if url.endswith('.gz'): ext = os.path.splitext(url[:-3])[-1] else: ext = os.path.splitext(url)[-1] if ext == '.hdf5': kwargs.setdefau...
def _fetch_losc_data_file(url, *args, **kwargs)
Internal function for fetching a single LOSC file and returning a Series
3.803736
3.758825
1.011948
segments = set() for path in files: seg = file_segment(path) for s in segments: if seg.intersects(s): return True segments.add(seg) return False
def _overlapping(files)
Quick method to see if a file list contains overlapping files
3.38067
2.986307
1.132057
# format arguments start = to_gps(start) end = to_gps(end) span = Segment(start, end) kwargs.update({ 'start': start, 'end': end, }) # find URLs (requires gwopensci) url_kw = {key: kwargs.pop(key) for key in GWOSC_LOCATE_KWARGS if key in kwargs} if...
def fetch_losc_data(detector, start, end, cls=TimeSeries, **kwargs)
Fetch LOSC data for a given detector This function is for internal purposes only, all users should instead use the interface provided by `TimeSeries.fetch_open_data` (and similar for `StateVector.fetch_open_data`).
5.297528
5.405903
0.979953
dataset = io_hdf5.find_dataset(h5f, path) # read data nddata = dataset[()] # read metadata xunit = parse_unit(dataset.attrs['Xunits']) epoch = dataset.attrs['Xstart'] dt = Quantity(dataset.attrs['Xspacing'], xunit) unit = dataset.attrs['Yunits'] # build and return return Tim...
def read_losc_hdf5(h5f, path='strain/Strain', start=None, end=None, copy=False)
Read a `TimeSeries` from a LOSC-format HDF file. Parameters ---------- h5f : `str`, `h5py.HLObject` path of HDF5 file, or open `H5File` path : `str` name of HDF5 dataset to read. Returns ------- data : `~gwpy.timeseries.TimeSeries` a new `TimeSeries` containing the...
4.878158
5.326177
0.915884
# find data dataset = io_hdf5.find_dataset(f, '%s/DQmask' % path) maskset = io_hdf5.find_dataset(f, '%s/DQDescriptions' % path) # read data nddata = dataset[()] bits = [bytes.decode(bytes(b), 'utf-8') for b in maskset[()]] # read metadata epoch = dataset.attrs['Xstart'] try: ...
def read_losc_hdf5_state(f, path='quality/simple', start=None, end=None, copy=False)
Read a `StateVector` from a LOSC-format HDF file. Parameters ---------- f : `str`, `h5py.HLObject` path of HDF5 file, or open `H5File` path : `str` path of HDF5 dataset to read. start : `Time`, `~gwpy.time.LIGOTimeGPS`, optional start GPS time of desired data end : `T...
5.265726
5.65732
0.930781
channels = list(io_gwf.iter_channel_names(file_path(path))) if issubclass(series_class, StateVector): regex = DQMASK_CHANNEL_REGEX else: regex = STRAIN_CHANNEL_REGEX found, = list(filter(regex.match, channels)) if verbose: print("Using channel {0!r}".format(found)) r...
def _gwf_channel(path, series_class=TimeSeries, verbose=False)
Find the right channel name for a LOSC GWF file
6.632591
6.197589
1.070189
# read file path if isinstance(source, string_types): with open(source, 'r') as fobj: return from_segwizard(fobj, gpstype=gpstype, strict=strict) # read file object out = SegmentList() fmt_pat = None for line in source: if line.startswith(('#', ';')): # comment...
def from_segwizard(source, gpstype=LIGOTimeGPS, strict=True)
Read segments from a segwizard format file into a `SegmentList` Parameters ---------- source : `file`, `str` An open file, or file path, from which to read gpstype : `type`, optional The numeric type to which to cast times (from `str`) when reading. strict : `bool`, optional ...
3.657171
3.691353
0.99074
for pat in (FOUR_COL_REGEX, THREE_COL_REGEX, TWO_COL_REGEX): if pat.match(line): return pat raise ValueError("unable to parse segment from line {!r}".format(line))
def _line_format(line)
Determine the column format pattern for a line in an ASCII segment file.
5.431307
4.455885
1.218906
try: start, end, dur = tokens except ValueError: # two-columns return Segment(*map(gpstype, tokens)) seg = Segment(gpstype(start), gpstype(end)) if strict and not float(abs(seg)) == float(dur): raise ValueError( "segment {0!r} has incorrect duration {1!r}".forma...
def _format_segment(tokens, strict=True, gpstype=LIGOTimeGPS)
Format a list of tokens parsed from an ASCII file into a segment.
4.769601
4.690275
1.016913
# write file path if isinstance(target, string_types): with open(target, 'w') as fobj: return to_segwizard(segs, fobj, header=header, coltype=coltype) # write file object if header: print('# seg\tstart\tstop\tduration', file=target) for i, seg in enumerate(segs): ...
def to_segwizard(segs, target, header=True, coltype=LIGOTimeGPS)
Write the given `SegmentList` to a file in SegWizard format. Parameters ---------- segs : :class:`~gwpy.segments.SegmentList` The list of segments to write. target : `file`, `str` An open file, or file path, to which to write. header : `bool`, optional Print a column heade...
2.753995
2.708867
1.016659
def identify(origin, filepath, fileobj, *args, **kwargs): # pylint: disable=unused-argument if (isinstance(filepath, string_types) and filepath.endswith(extensions)): return True return False return identify
def identify_factory(*extensions)
Factory function to create I/O identifiers for a set of extensions The returned function is designed for use in the unified I/O registry via the `astropy.io.registry.register_identifier` hool. Parameters ---------- extensions : `str` one or more file extension strings Returns ----...
5.234177
5.506593
0.950529
# filename declares gzip if name.endswith('.gz'): return gzip.open(name, *args, **kwargs) # open regular file fobj = open(name, *args, **kwargs) sig = fobj.read(3) fobj.seek(0) if sig == GZIP_SIGNATURE: # file signature declares gzip fobj.close() # GzipFile won't clos...
def gopen(name, *args, **kwargs)
Open a file handling optional gzipping If ``name`` endswith ``'.gz'``, or if the GZIP file signature is found at the beginning of the file, the file will be opened with `gzip.open`, otherwise a regular file will be returned from `open`. Parameters ---------- name : `str` path (name) of...
4.532834
4.287165
1.057303
# open a cache file and return list of paths if (isinstance(flist, string_types) and flist.endswith(('.cache', '.lcf', '.ffl'))): from .cache import read_cache return read_cache(flist) # separate comma-separate list of names if isinstance(flist, string_types): r...
def file_list(flist)
Parse a number of possible input types into a list of filepaths. Parameters ---------- flist : `file-like` or `list-like` iterable the input data container, normally just a single file path, or a list of paths, but can generally be any of the following - `str` representing a single...
4.101853
3.77699
1.086011
if isinstance(fobj, string_types) and fobj.startswith("file:"): return urlparse(fobj).path if isinstance(fobj, string_types): return fobj if (isinstance(fobj, FILE_LIKE) and hasattr(fobj, "name")): return fobj.name try: return fobj.path except AttributeError: ...
def file_path(fobj)
Determine the path of a file. This doesn't do any sanity checking to check that the file actually exists, or is readable. Parameters ---------- fobj : `file`, `str`, `CacheEntry`, ... the file object or path to parse Returns ------- path : `str` the path of the underly...
2.833912
3.204296
0.88441
while True: # pick item out of input wqueue idx, arg = q_in.get() if idx is None: # sentinel break # execute method and put the result in the output queue q_out.put((idx, func(arg)))
def process_in_out_queues(func, q_in, q_out)
Iterate through a Queue, call, ``func`, and Queue the result Parameters ---------- func : `callable` any function that can take an element of the input `Queue` as the only argument q_in : `multiprocessing.queue.Queue` the input `Queue` q_out : `multiprocessing.queue.Queue`...
5.730982
7.522145
0.761881
if nproc != 1 and os.name == 'nt': warnings.warn( "multiprocessing is currently not supported on Windows, see " "https://github.com/gwpy/gwpy/issues/880, will continue with " "serial procesing (nproc=1)") nproc = 1 if progress_kw.pop('raise_exceptions', ...
def multiprocess_with_queues(nproc, func, inputs, verbose=False, **progress_kw)
Map a function over a list of inputs using multiprocess This essentially duplicates `multiprocess.map` but allows for arbitrary functions (that aren't necessarily importable) Parameters ---------- nproc : `int` number of processes to use, if ``1`` is given, the current process is u...
3.019
3.066027
0.984662
from astropy.utils.data import get_readable_fileobj import json from six.moves.urllib.error import HTTPError from six.moves import urllib # Need to build the url call for the restful API base = 'https://gravityspytools.ciera.northwestern.edu' + \ '/s...
def search(cls, gravityspy_id, howmany=10, era='ALL', ifos='H1L1', remote_timeout=20)
perform restful API version of search available here: https://gravityspytools.ciera.northwestern.edu/search/ Parameters ---------- gravityspy_id : `str`, This is the unique 10 character hash that identifies a Gravity Spy Image howmany : `int`, optional, ...
4.116562
3.825676
1.076035
try: if self._epoch is None: return None return Time(*modf(self._epoch)[::-1], format='gps', scale='utc') except AttributeError: self._epoch = None return self._epoch
def epoch(self)
GPS epoch associated with these data :type: `~astropy.time.Time`
7.514794
5.100288
1.473406
self._unit = parse_unit(unit, parse_strict=parse_strict)
def override_unit(self, unit, parse_strict='raise')
Forcefully reset the unit of these data Use of this method is discouraged in favour of `to()`, which performs accurate conversions from one unit to another. The method should really only be used when the original unit of the array is plain wrong. Parameters ---------- ...
4.275752
6.707603
0.637449
return super(Array, self).flatten(order=order).view(Quantity)
def flatten(self, order='C')
Return a copy of the array collapsed into one dimension. Any index information is removed as part of the flattening, and the result is returned as a `~astropy.units.Quantity` array. Parameters ---------- order : {'C', 'F', 'A', 'K'}, optional 'C' means to flatten in...
10.179667
15.38058
0.661852
# check sampling rates if ts1.sample_rate.to('Hertz') != ts2.sample_rate.to('Hertz'): sampling = min(ts1.sample_rate.value, ts2.sample_rate.value) # resample higher rate series if ts1.sample_rate.value == sampling: ts2 = ts2.resample(sampling) else: t...
def _from_timeseries(ts1, ts2, stride, fftlength=None, overlap=None, window=None, **kwargs)
Generate a time-frequency coherence :class:`~gwpy.spectrogram.Spectrogram` from a pair of :class:`~gwpy.timeseries.TimeSeries`. For each `stride`, a PSD :class:`~gwpy.frequencyseries.FrequencySeries` is generated, with all resulting spectra stacked in time and returned.
3.584124
3.463315
1.034882
# format FFT parameters if fftlength is None: fftlength = stride / 2. # get size of spectrogram nsteps = int(ts1.size // (stride * ts1.sample_rate.value)) nproc = min(nsteps, nproc) # single-process return if nsteps == 0 or nproc == 1: return _from_timeseries(ts1, ts2,...
def from_timeseries(ts1, ts2, stride, fftlength=None, overlap=None, window=None, nproc=1, **kwargs)
Calculate the coherence `Spectrogram` between two `TimeSeries`. Parameters ---------- timeseries : :class:`~gwpy.timeseries.TimeSeries` input time-series to process. stride : `float` number of seconds in single PSD (column of spectrogram). fftlength : `float` number of secon...
3.008722
3.086318
0.974858
# read file(s) config = configparser.ConfigParser(dict_type=OrderedDict) source = file_list(source) success_ = config.read(*source) if len(success_) != len(source): raise IOError("Failed to read one or more CLF files") # create channel list out = ChannelList() out.source = s...
def read_channel_list_file(*source)
Read a `~gwpy.detector.ChannelList` from a Channel List File
3.944593
3.907049
1.009609
if not isinstance(fobj, FILE_LIKE): with open(fobj, "w") as fobj: return write_channel_list_file(channels, fobj) out = configparser.ConfigParser(dict_type=OrderedDict) for channel in channels: group = channel.group if not out.has_section(group): out.add_...
def write_channel_list_file(channels, fobj)
Write a `~gwpy.detector.ChannelList` to a INI-format channel list file
2.652512
2.58579
1.025803
# warn about deprecated functions if deprecated: func = deprecated_function( func, "the {0!r} PSD methods is deprecated, and will be removed " "in a future release, please consider using {1!r} instead".format( name, name.split('-', 1)[1], ...
def register_method(func, name=None, deprecated=False)
Register a method of calculating an average spectrogram. Parameters ---------- func : `callable` function to execute name : `str`, optional name of the method, defaults to ``func.__name__`` deprecated : `bool`, optional whether this method is deprecated (`True`) or not (`F...
4.668211
4.781676
0.976271
# find method name = _format_name(name) try: return METHODS[name] except KeyError as exc: exc.args = ("no PSD method registered with name {0!r}".format(name),) raise
def get_method(name)
Return the PSD method registered with the given name.
5.831781
4.076223
1.430683
# compute chirp mass and symmetric mass ratio mass1 = units.Quantity(mass1, 'solMass').to('kg') mass2 = units.Quantity(mass2, 'solMass').to('kg') mtotal = mass1 + mass2 mchirp = (mass1 * mass2) ** (3/5.) / mtotal ** (1/5.) # compute ISCO fisco = (constants.c ** 3 / (constants.G * 6**1....
def inspiral_range_psd(psd, snr=8, mass1=1.4, mass2=1.4, horizon=False)
Compute the inspiral sensitive distance PSD from a GW strain PSD Parameters ---------- psd : `~gwpy.frequencyseries.FrequencySeries` the instrumental power-spectral-density data snr : `float`, optional the signal-to-noise ratio for which to calculate range, default: `8` ma...
5.060131
5.051022
1.001803
mass1 = units.Quantity(mass1, 'solMass').to('kg') mass2 = units.Quantity(mass2, 'solMass').to('kg') mtotal = mass1 + mass2 # compute ISCO fisco = (constants.c ** 3 / (constants.G * 6**1.5 * pi * mtotal)).to('Hz') # format frequency limits fmax = units.Quantity(fmax or fisco, 'Hz') ...
def inspiral_range(psd, snr=8, mass1=1.4, mass2=1.4, fmin=None, fmax=None, horizon=False)
Calculate the inspiral sensitive distance from a GW strain PSD The method returns the distance (in megaparsecs) to which an compact binary inspiral with the given component masses would be detectable given the instrumental PSD. The calculation is as defined in: https://dcc.ligo.org/LIGO-T030276/public...
4.042645
4.352987
0.928706
# calculate frequency dependent range in parsecs a = (constants.G * energy * constants.M_sun * 0.4 / (pi**2 * constants.c))**(1/2.) dspec = psd ** (-1/2.) * a / (snr * psd.frequencies) # convert to output unit rspec = dspec.to('Mpc') # rescale 0 Hertz (which has 0 range always) ...
def burst_range_spectrum(psd, snr=8, energy=1e-2)
Calculate the frequency-dependent GW burst range from a strain PSD Parameters ---------- psd : `~gwpy.frequencyseries.FrequencySeries` the instrumental power-spectral-density data snr : `float`, optional the signal-to-noise ratio for which to calculate range, default: `8` ...
9.596503
9.049432
1.060454
freqs = psd.frequencies.value # restrict integral if not fmin: fmin = psd.f0 if not fmax: fmax = psd.span[1] condition = (freqs >= fmin) & (freqs < fmax) # calculate integrand and integrate integrand = burst_range_spectrum( psd[condition], snr=snr, energy=energy)...
def burst_range(psd, snr=8, energy=1e-2, fmin=100, fmax=500)
Calculate the integrated GRB-like GW burst range from a strain PSD Parameters ---------- psd : `~gwpy.frequencyseries.FrequencySeries` the instrumental power-spectral-density data snr : `float`, optional the signal-to-noise ratio for which to calculate range, default: ``8`` ...
4.674922
5.2975
0.882477
# this method is more complicated than it need be to # support matplotlib-1.x. # for matplotlib-2.x this would just be # h, s, v = colors.rgb_to_hsv(colors.to_rgb(c)) # v *= factor # return colors.hsv_to_rgb((h, s, v)) rgb = numpy.array(to_rgb(col), ndmin=3) hsv = colors...
def tint(col, factor=1.0)
Tint a color (make it darker), returning a new RGB array
4.081615
3.921462
1.04084
norm = kwargs.pop('norm', current) or 'linear' vmin = kwargs.pop('vmin', None) vmax = kwargs.pop('vmax', None) clim = kwargs.pop('clim', (vmin, vmax)) or (None, None) clip = kwargs.pop('clip', None) if norm == 'linear': norm = colors.Normalize() elif norm == 'log': norm...
def format_norm(kwargs, current=None)
Format a `~matplotlib.colors.Normalize` from a set of kwargs Returns ------- norm, kwargs the formatted `Normalize` instance, and the remaining keywords
2.263534
2.213627
1.022545
# pylint: disable=unused-argument # try and read file descriptor if fileobj is not None: loc = fileobj.tell() fileobj.seek(0) try: if fileobj.read(4) == GWF_SIGNATURE: return True finally: fileobj.seek(loc) if filepath is not ...
def identify_gwf(origin, filepath, fileobj, *args, **kwargs)
Identify a filename or file object as GWF This function is overloaded in that it will also identify a cache file as 'gwf' if the first entry in the cache contains a GWF file extension
3.364292
3.240291
1.038269
if mode not in ('r', 'w'): raise ValueError("mode must be either 'r' or 'w'") from LDAStools import frameCPP filename = urlparse(filename).path # strip file://localhost or similar if mode == 'r': return frameCPP.IFrameFStream(str(filename)) return frameCPP.OFrameFStream(str(fil...
def open_gwf(filename, mode='r')
Open a filename for reading or writing GWF format data Parameters ---------- filename : `str` the path to read from, or write to mode : `str`, optional either ``'r'`` (read) or ``'w'`` (write) Returns ------- `LDAStools.frameCPP.IFrameFStream` the input frame strea...
8.878717
4.672173
1.90034
from LDAStools import frameCPP # open stream stream = open_gwf(filename, 'w') # write frames one-by-one if isinstance(frames, frameCPP.FrameH): frames = [frames] for frame in frames: stream.WriteFrame(frame, compression, compression_level)
def write_frames(filename, frames, compression=257, compression_level=6)
Write a list of frame objects to a file **Requires:** |LDAStools.frameCPP|_ Parameters ---------- filename : `str` path to write into frames : `list` of `LDAStools.frameCPP.FrameH` list of frames to write into file compression : `int`, optional enum value for compress...
9.080189
4.491893
2.021461
from LDAStools import frameCPP # create frame frame = frameCPP.FrameH() # add timing gps = to_gps(time) gps = frameCPP.GPSTime(gps.gpsSeconds, gps.gpsNanoSeconds) frame.SetGTime(gps) if duration is not None: frame.SetDt(float(duration)) # add FrDetectors for prefi...
def create_frame(time=0, duration=None, name='gwpy', run=-1, ifos=None)
Create a new :class:`~LDAStools.frameCPP.FrameH` **Requires:** |LDAStools.frameCPP|_ Parameters ---------- time : `float`, optional frame start time in GPS seconds duration : `float`, optional frame length in seconds name : `str`, optional name of project or other exp...
8.385499
6.054511
1.385
channel = str(channel) for name, type_ in _iter_channels(framefile): if channel == name: return type_ raise ValueError("%s not found in table-of-contents for %s" % (channel, framefile))
def get_channel_type(channel, framefile)
Find the channel type in a given GWF file **Requires:** |LDAStools.frameCPP|_ Parameters ---------- channel : `str`, `~gwpy.detector.Channel` name of data channel to find framefile : `str` path of GWF file in which to search Returns ------- ctype : `str` the t...
4.826603
5.224605
0.923822
channel = str(channel) for name in iter_channel_names(framefile): if channel == name: return True return False
def channel_in_frame(channel, framefile)
Determine whether a channel is stored in this framefile **Requires:** |LDAStools.frameCPP|_ Parameters ---------- channel : `str` name of channel to find framefile : `str` path of GWF file to test Returns ------- inframe : `bool` whether this channel is includ...
4.288503
8.247094
0.520002
from LDAStools import frameCPP if not isinstance(framefile, frameCPP.IFrameFStream): framefile = open_gwf(framefile, 'r') toc = framefile.GetTOC() for typename in ('Sim', 'Proc', 'ADC'): typen = typename.lower() for name in getattr(toc, 'Get{0}'.format(typename))(): ...
def _iter_channels(framefile)
Yields the name and type of each channel in a GWF file TOC **Requires:** |LDAStools.frameCPP|_ Parameters ---------- framefile : `str`, `LDAStools.frameCPP.IFrameFStream` path of GWF file, or open file stream, to read
13.967729
6.033597
2.314992
segments = SegmentList() for path in paths: segments.extend(_gwf_channel_segments(path, channel, warn=warn)) return segments.coalesce()
def data_segments(paths, channel, warn=True)
Returns the segments containing data for a channel **Requires:** |LDAStools.frameCPP|_ A frame is considered to contain data if a valid FrData structure (of any type) exists for the channel in that frame. No checks are directly made against the underlying FrVect structures. Parameters ------...
6.283658
7.919232
0.793468
stream = open_gwf(path) # get segments for frames toc = stream.GetTOC() secs = toc.GetGTimeS() nano = toc.GetGTimeN() dur = toc.GetDt() readers = [getattr(stream, 'ReadFr{0}Data'.format(type_.title())) for type_ in ("proc", "sim", "adc")] # for each segment, try and...
def _gwf_channel_segments(path, channel, warn=True)
Yields the segments containing data for ``channel`` in this GWF path
7.205949
6.913675
1.042275
# parse keyword args inplace = kwargs.pop('inplace', False) analog = kwargs.pop('analog', False) fs = kwargs.pop('sample_rate', None) if kwargs: raise TypeError("filter() got an unexpected keyword argument '%s'" % list(kwargs.keys())[0]) # parse filter i...
def fdfilter(data, *filt, **kwargs)
Filter a frequency-domain data object See Also -------- gwpy.frequencyseries.FrequencySeries.filter gwpy.spectrogram.Spectrogram.filter
4.283721
4.455705
0.961401
# define command line arguments parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("-V", "--version", action="version", version=__version__, help="show version number and exit") parser.add_argument("-l", "--local", action="store...
def main(args=None)
Parse command-line arguments, tconvert inputs, and print
2.778881
2.599796
1.068884
name = func.__name__ @wraps(func) def timed_func(self, *args, **kwargs): # pylint: disable=missing-docstring _start = time.time() out = func(self, *args, **kwargs) self.log(2, '{0} took {1:.1f} sec'.format(name, time.time() - _start)) return out return timed_func
def timer(func)
Time a method and print its duration after return
2.461591
2.489992
0.988594
def converter(x): return Quantity(x, unit).value converter.__doc__ %= str(unit) # pylint: disable=no-member return converter
def to_float(unit)
Factory to build a converter from quantity string to float Examples -------- >>> conv = to_float('Hz') >>> conv('4 mHz') >>> 0.004
10.211293
18.016273
0.566782
@wraps(func) def decorated_func(*args, **kwargs): norm, kwargs = format_norm(kwargs) kwargs['norm'] = norm return func(*args, **kwargs) return decorated_func
def log_norm(func)
Wrap ``func`` to handle custom gwpy keywords for a LogNorm colouring
2.738856
2.76063
0.992113
@wraps(func) def wrapped_func(self, left=None, right=None, **kw): if right is None and numpy.iterable(left): left, right = left kw['left'] = left kw['right'] = right gpsscale = self.get_xscale() in GPS_SCALES for key in ('left', 'right'): if g...
def xlim_as_gps(func)
Wrap ``func`` to handle pass limit inputs through `gwpy.time.to_gps`
3.262382
3.170543
1.028966
@wraps(func) def wrapped_func(self, *args, **kwargs): grid = (self.xaxis._gridOnMinor, self.xaxis._gridOnMajor, self.yaxis._gridOnMinor, self.yaxis._gridOnMajor) try: return func(self, *args, **kwargs) finally: # reset grid self.xa...
def restore_grid(func)
Wrap ``func`` to preserve the Axes current grid settings.
2.02543
1.86913
1.083621
scale = self.get_xscale() return self.set_xscale(scale, epoch=epoch)
def set_epoch(self, epoch)
Set the epoch for the current GPS scale. This method will fail if the current X-axis scale isn't one of the GPS scales. See :ref:`gwpy-plot-gps` for more details. Parameters ---------- epoch : `float`, `str` GPS-compatible time or date object, anything parseable by ...
7.446944
8.522492
0.873799
if isinstance(array, Array2D): return self._imshow_array2d(array, *args, **kwargs) image = super(Axes, self).imshow(array, *args, **kwargs) self.autoscale(enable=None, axis='both', tight=None) return image
def imshow(self, array, *args, **kwargs)
Display an image, i.e. data on a 2D regular raster. If ``array`` is a :class:`~gwpy.types.Array2D` (e.g. a :class:`~gwpy.spectrogram.Spectrogram`), then the defaults are _different_ to those in the upstream :meth:`~matplotlib.axes.Axes.imshow` method. Namely, the defaults are -...
3.443123
4.066292
0.846747
# NOTE: If you change the defaults for this method, please update # the docstring for `imshow` above. # calculate extent extent = tuple(array.xspan) + tuple(array.yspan) if self.get_xscale() == 'log' and extent[0] == 0.: extent = (1e-300,) + extent[1:]...
def _imshow_array2d(self, array, origin='lower', interpolation='none', aspect='auto', **kwargs)
Render an `~gwpy.types.Array2D` using `Axes.imshow`
3.164022
3.082758
1.026361
if len(args) == 1 and isinstance(args[0], Array2D): return self._pcolormesh_array2d(*args, **kwargs) return super(Axes, self).pcolormesh(*args, **kwargs)
def pcolormesh(self, *args, **kwargs)
Create a pseudocolor plot with a non-regular rectangular grid. When using GWpy, this method can be called with a single argument that is an :class:`~gwpy.types.Array2D`, for which the ``X`` and ``Y`` coordinate arrays will be determined from the indexing. In all other usage, all ``args...
2.505238
3.093839
0.809751
x = numpy.concatenate((array.xindex.value, array.xspan[-1:])) y = numpy.concatenate((array.yindex.value, array.yspan[-1:])) xcoord, ycoord = numpy.meshgrid(x, y, copy=False, sparse=True) return self.pcolormesh(xcoord, ycoord, array.value.T, *args, **kwargs)
def _pcolormesh_array2d(self, array, *args, **kwargs)
Render an `~gwpy.types.Array2D` using `Axes.pcolormesh`
3.006495
2.757515
1.090291
alpha = kwargs.pop('alpha', .1) # plot mean line, = self.plot(data, **kwargs) out = [line] # modify keywords for shading kwargs.update({ 'label': '', 'linewidth': line.get_linewidth() / 2, 'color': line.get_color(), ...
def plot_mmm(self, data, lower=None, upper=None, **kwargs)
Plot a `Series` as a line, with a shaded region around it. The ``data`` `Series` is drawn, while the ``lower`` and ``upper`` `Series` are plotted lightly below and above, with a fill between them and the ``data``. All three `Series` should have the same `~Series.index` array. ...
3.998598
4.449451
0.898672
# get color and sort if color is not None and kwargs.get('c_sort', True): sortidx = color.argsort() x = x[sortidx] y = y[sortidx] w = w[sortidx] h = h[sortidx] color = color[sortidx] # define how to make a polygon ...
def tile(self, x, y, w, h, color=None, anchor='center', edgecolors='face', linewidth=0.8, **kwargs)
Plot rectanguler tiles based onto these `Axes`. ``x`` and ``y`` give the anchor point for each tile, with ``w`` and ``h`` giving the extent in the X and Y axis respectively. Parameters ---------- x, y, w, h : `array_like`, shape (n, ) Input data color : `ar...
1.788723
1.78403
1.002631
fig = self.get_figure() if kwargs.get('use_axesgrid', True): kwargs.setdefault('fraction', 0.) if kwargs.get('fraction', 0.) == 0.: kwargs.setdefault('use_axesgrid', True) mappable, kwargs = gcbar.process_colorbar_kwargs( fig, mappable=mappabl...
def colorbar(self, mappable=None, **kwargs)
Add a `~matplotlib.colorbar.Colorbar` to these `Axes` Parameters ---------- mappable : matplotlib data collection, optional collection against which to map the colouring, default will be the last added mappable artist (collection or image) fraction : `float`, op...
6.439205
6.399065
1.006273
# convert from GPS into datetime try: float(gpsordate) # if we can 'float' it, then its probably a GPS time except (TypeError, ValueError): return to_gps(gpsordate) return from_gps(gpsordate)
def tconvert(gpsordate='now')
Convert GPS times to ISO-format date-times and vice-versa. Parameters ---------- gpsordate : `float`, `astropy.time.Time`, `datetime.datetime`, ... input gps or date to convert, many input types are supported Returns ------- date : `datetime.datetime` or `LIGOTimeGPS` converted...
7.033786
8.021016
0.87692
# -- convert input to Time, or something we can pass to LIGOTimeGPS if isinstance(t, string_types): try: # if str represents a number, leave it for LIGOTimeGPS to handle float(t) except ValueError: # str -> datetime.datetime t = _str_to_datetime(t) # tuple ->...
def to_gps(t, *args, **kwargs)
Convert any input date/time into a `LIGOTimeGPS`. Any input object that can be cast as a `~astropy.time.Time` (with `str` going through the `datetime.datetime`) are acceptable. Parameters ---------- t : `float`, `~datetime.datetime`, `~astropy.time.Time`, `str` the input time, any object t...
4.204109
4.305482
0.976455
try: gps = LIGOTimeGPS(gps) except (ValueError, TypeError, RuntimeError): gps = LIGOTimeGPS(float(gps)) sec, nano = gps.gpsSeconds, gps.gpsNanoSeconds date = Time(sec, format='gps', scale='utc').datetime return date + datetime.timedelta(microseconds=nano*1e-3)
def from_gps(gps)
Convert a GPS time into a `datetime.datetime`. Parameters ---------- gps : `LIGOTimeGPS`, `int`, `float` GPS time to convert Returns ------- datetime : `datetime.datetime` ISO-format datetime equivalent of input GPS time Examples -------- >>> from_gps(1167264018) ...
4.346214
4.287741
1.013637
# try known string try: return DATE_STRINGS[str(datestr).lower()]() except KeyError: # any other string pass # use maya try: import maya return maya.when(datestr).datetime() except ImportError: pass # use dateutil.parse with warnings.catch_...
def _str_to_datetime(datestr)
Convert `str` to `datetime.datetime`.
5.029822
4.940498
1.01808
time = time.utc date = time.datetime micro = date.microsecond if isinstance(date, datetime.datetime) else 0 return LIGOTimeGPS(int(time.gps), int(micro*1e3))
def _time_to_gps(time)
Convert a `Time` into `LIGOTimeGPS`. This method uses `datetime.datetime` underneath, which restricts to microsecond precision by design. This should probably be fixed... Parameters ---------- time : `~astropy.time.Time` formatted `Time` object to convert Returns ------- gps :...
6.509067
5.566547
1.169319
if isinstance(filename, (h5py.Group, h5py.Dataset)): return filename if isinstance(filename, FILE_LIKE): return h5py.File(filename.name, mode) return h5py.File(filename, mode)
def open_hdf5(filename, mode='r')
Wrapper to open a :class:`h5py.File` from disk, gracefully handling a few corner cases
2.53637
2.73873
0.926112
@wraps(func) def decorated_func(fobj, *args, **kwargs): # pylint: disable=missing-docstring if not isinstance(fobj, h5py.HLObject): if isinstance(fobj, FILE_LIKE): fobj = fobj.name with h5py.File(fobj, 'r') as h5f: return func(h5f, *ar...
def with_read_hdf5(func)
Decorate an HDF5-reading function to open a filepath if needed ``func`` should be written to presume an `h5py.Group` as the first positional argument.
2.405732
2.514167
0.95687
# find dataset if isinstance(h5o, h5py.Dataset): return h5o elif path is None and len(h5o) == 1: path = list(h5o.keys())[0] elif path is None: raise ValueError("Please specify the HDF5 path via the " "``path=`` keyword argument") return h5o[path]
def find_dataset(h5o, path=None)
Find and return the relevant dataset inside the given H5 object If ``path=None`` is given, and ``h5o`` contains a single dataset, that will be returned Parameters ---------- h5o : `h5py.File`, `h5py.Group` the HDF5 object in which to search path : `str`, optional the path (rel...
2.874604
3.287447
0.874418
@wraps(func) def decorated_func(obj, fobj, *args, **kwargs): # pylint: disable=missing-docstring if not isinstance(fobj, h5py.HLObject): append = kwargs.get('append', False) overwrite = kwargs.get('overwrite', False) if os.path.exists(fobj) and not (overw...
def with_write_hdf5(func)
Decorate an HDF5-writing function to open a filepath if needed ``func`` should be written to take the object to be written as the first argument, and then presume an `h5py.Group` as the second. This method uses keywords ``append`` and ``overwrite`` as follows if the output file already exists: - ...
2.119471
2.147678
0.986866
# force deletion of existing dataset if path in parent and overwrite: del parent[path] # create new dataset with improved error handling try: return parent.create_dataset(path, **kwargs) except RuntimeError as exc: if str(exc) == 'Unable to create link (Name already exi...
def create_dataset(parent, path, overwrite=False, **kwargs)
Create a new dataset inside the parent HDF5 object Parameters ---------- parent : `h5py.Group`, `h5py.File` the object in which to create a new dataset path : `str` the path at which to create the new dataset overwrite : `bool` if `True`, delete any existing dataset at the...
5.313466
5.477108
0.970123
# parse selection for SQL query if selection is None: return '' selections = [] for col, op_, value in parse_column_filters(selection): if engine and engine.name == 'postgresql': col = '"%s"' % col try: opstr = [key for key in OPERATORS if OPERATORS[k...
def format_db_selection(selection, engine=None)
Format a column filter selection as a SQL database WHERE string
3.993
3.709401
1.076454
import pandas as pd # parse columns for SQL query if columns is None: columnstr = '*' else: columnstr = ', '.join('"%s"' % c for c in columns) # parse selection for SQL query selectionstr = format_db_selection(selection, engine=engine) # build SQL query qstr = 'SE...
def fetch(engine, tablename, columns=None, selection=None, **kwargs)
Fetch data from an SQL table into an `EventTable` Parameters ---------- engine : `sqlalchemy.engine.Engine` the database engine to use when connecting table : `str`, The name of table you are attempting to receive triggers from. selection other filters you would li...
3.125695
3.432441
0.910633