Package pylal :: Module ligolw_dataUtils
[hide private]
[frames] | no frames]

Module ligolw_dataUtils

source code

A collection of utilities to assist in storing and sorting data queried from a database or xml document.


Author: Collin Capano <collin.capano@ligo.org>

Classes [hide private]
  dbDataRow
A class to assist in loading data from and performing functions on tables in a SQLite database.
  CompareDataRows
A class that can perform various types of comparison tests between arbitrary DataRow classes.
  OffsetVector
  Category
Class to store category information.
  Data
Class to store statistics and livetime for plotting.
Functions [hide private]
 
get_row_stat(row, arg)
Method to evaluate the desired operation on columns from a row in a table.
source code
 
get_needed_columns(column_list, function)
Returns a list of columns from the given column list that are needed by the given function string.
source code
 
createDataRowClass(classTableName, baseClass=None, columns=[])
Creates a DataRow class.
source code
 
combineRowStats(function, rows)
Performs the desired function on the list of single statistics.
source code
 
createCombineRowsMethod(tableName, columns, functionList)
Creates a CombineRows class that can be used in a sqlite database to combine rows on the fly.
source code
 
combineData(dataObj, match_column, args, param_grouping_function, verbose=False)
Cycles over the DataElements in dataObj, combining any DataElements with the same match_column value via the given args and returns a new Data object in which the element's ids are the values of the match_column.
source code
Function Details [hide private]

get_row_stat(row, arg)

source code 

Method to evaluate the desired operation on columns from a row in a table. The desired operation can be either a pre-defined function (if it exists in the row's namespace) or a function of the elements in the row's name space. Syntax for the arg is python. The name space available to eval is limited to the columns in the row and functions in the math module.

get_needed_columns(column_list, function)

source code 

Returns a list of columns from the given column list that are needed by
the given function string. This can be used to reduce the number of columns
that are passed to get_row_stat.

Parameters
----------
column_list: list
    A list of strings given the possible columns to pull out.
function: str
    A string specifying the match criteria. Can either be:
        * "endTime" or "startTime": in this case, all columns in
          column_list with "end_time", "start_time", or "ifo" in their name
          will be retrieved.
        * "eThinca": in this case, all columns with mass1, mass2, mchirp,
          eta, tau[0-9], time, or [Gg]amma[0-9] in their name will be
          retrieved.
        * a python string that is a function of one or more of the columns
          in column_list.

Returns
-------
needed_columns: str
    The subset of columns needed by the function.

createDataRowClass(classTableName, baseClass=None, columns=[])

source code 

Creates a DataRow class. If classTableName is the same as a table in lsctables, and baseClass is not specified, the DataRow class will inherit from that table's RowType. If baseClass is specified, the DataRow class that is created will inherit from that base class. If baseClass is not specified and classTableName is not in lsctables, then DataRow will just inherit from object. Regardless of inheritance, the DataRow will have a __slots__ attribute. Any columns that are specified in columns will be added to the __slots__ class. The DataRow will also have a tableName attribute. This will be whatever classTableName is, regardless of what baseClass is set to. Think of the DataRow class as a more arbitrary version of an lsctable row.

combineRowStats(function, rows)

source code 

Performs the desired function on the list of single statistics. Note: this can only combine one statistic from each row.

createCombineRowsMethod(tableName, columns, functionList)

source code 

Creates a CombineRows class that can be used in a sqlite database to combine rows on the fly. Takes in a sngl_function, which is the function used to combine columns within a single row, and a combining_function, which is the function used to combine the results of the sngl_functions across rows.

combineData(dataObj, match_column, args, param_grouping_function, verbose=False)

source code 

Cycles over the DataElements in dataObj, combining any DataElements with the same match_column value via the given args and returns a new Data object in which the element's ids are the values of the match_column. Note: the categories of the DataElements in the new Data object are just the concatenation of the older objects individual categories. These might need to be updated depending on the paramters of the newer category.