dataclasses

Module Contents

Classes

KM3Object

Class to hold data object from ODC

Table

Table of values from json-formatted data

Function

Class to generate numpy function from resource

LookUpTable

Table that can be queried for given x and y value.

HDFTable

Class to hold data object from ODC

SCSServiceVO

Class returning TAP service using the pyvo package.

AudioWave

Class for handling wave audio files from KM3NeT hydrophones

BytesEncoder

Helper to handle hdf5 headers

Functions

print_nice(inlist, selection={'Identifier': 'odcid', 'Title': 'title', 'Description': 'description'})

function to display contents of list of dictionaries as table.

from_json(instring)

Formatting the json string to make it useable from json.loads

_contract_dict(indict, inlist=False, tofloat=False)

Reformat dictionary with entries of similar keys to unnested dictionary

class dataclasses.KM3Object[source]

Class to hold data object from ODC

classmethod from_resource(cls, resourceinfo, datalocation, loadoption='')[source]

Create class instance from resource info (metadata from ODC) and filepath to datafile in cache.

_set_meta(self)[source]

Function template to set object attributes from resource metadata

_read_data(self, loadoption='')[source]

Reads data from file in cache.

show_metadata(self)[source]
class dataclasses.Table[source]

Bases: dataclasses.KM3Object

Table of values from json-formatted data

_set_meta(self)[source]

Function template to set object attributes from resource metadata

_read_data(self, loadoption='')[source]

Reads data from file in cache.

get_dataframe(self)[source]

returns table as pandas dataframe.

class dataclasses.Function[source]

Bases: dataclasses.KM3Object

Class to generate numpy function from resource

_read_data(self, loadoption='')[source]

Reads json file

_set_meta(self)[source]

Setting parameter info from metadata

show_paraminfo(self)[source]

returns info on parameter ranges

get_function(self)[source]

Returns function as numpy object

evaluate(self, xvalue)[source]

Returns evaluated function for a given input value

class dataclasses.LookUpTable[source]

Bases: dataclasses.KM3Object

Table that can be queried for given x and y value.

_set_meta(self)[source]

Setting parameter info and normalization from metadata

_read_data(self, loadoption='')[source]

Reads json file

show_paraminfo(self)[source]

returns info on parameter ranges

check_inrange(self, xvalue, yvalue)[source]

Check if query values (xvalue, yvalue) in range

get_dataframe(self)[source]

returns table as pandas dataframe.

lookup(self, xvalue, yvalue)[source]

Returns value for given x and y values from table

class dataclasses.HDFTable[source]

Bases: dataclasses.KM3Object

Class to hold data object from ODC

_set_meta(self)[source]

Function template to set object attributes from resource metadata

_read_data(self, loadoption='')[source]

Reading data as ‘pandas’ or ‘table’ (default).

get_provenance(self, displayinfo=True)[source]

Returns provenance information stored in the file

get_dataframe(self)[source]
get_paraminfo(self, colname='')[source]

Shows information about parameters in table

class dataclasses.SCSServiceVO[source]

Bases: dataclasses.KM3Object

Class returning TAP service using the pyvo package.

For further use of pyvo, see https://pyvo.readthedocs.io/en/latest/

_set_meta(self)[source]

Function template to set object attributes from resource metadata

_read_data(self, loadoption='')[source]

Reads data from file in cache.

get_tap(self)[source]

returns VO TAP service to use ADQL queries on data table

get_scs(self)[source]

returns Simple Cone Search Service

get_dataframe(self)[source]

returns astropy table with full data set.

show_paraminfo(self)[source]

returns info on parameters

class dataclasses.AudioWave[source]

Bases: dataclasses.KM3Object

Class for handling wave audio files from KM3NeT hydrophones

_set_meta(self)[source]

Function template to set object attributes from resource metadata

_read_data(self, loadoption='')[source]

Reads data from file in cache.

show_paraminfo(self)[source]

returns info on parameters

get_dataframe(self, endframe=1000, startframe=0)[source]

Returns wave frames as pandas DataFrame, betweem startframe and endframe.

dataclasses.print_nice(inlist, selection={'Identifier': 'odcid', 'Title': 'title', 'Description': 'description'})[source]

function to display contents of list of dictionaries as table. Option ‘selection’ takes dictionary with pairs of (columnname, key).

class dataclasses.BytesEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.JSONEncoder

Helper to handle hdf5 headers

default(self, obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
dataclasses.from_json(instring)[source]

Formatting the json string to make it useable from json.loads

dataclasses._contract_dict(indict, inlist=False, tofloat=False)[source]

Reformat dictionary with entries of similar keys to unnested dictionary