seabirdfilehandler.parameter module

Inheritance diagram of seabirdfilehandler.parameter
class seabirdfilehandler.parameter.Parameters(data, metadata, only_header=False)[source]

Bases: UserDict

A collection of all the parameters in a CnvFile.

Allows for a much cleaner handling of parameter data and their metadata. Will be heavily expanded.

Parameters:
  • data (list) – The raw data as extraced by DataFile

  • metadata (list) – The raw metadata as extraced by DataFile

get_parameter_names()[source]
Return type:

list[str]

get_parameter_list()[source]
Return type:

list[Parameter]

create_full_ndarray(data_table=[])[source]

Builds a numpy array representing the data table in a cnv file.

Parameters:

data_table (list :) –

The data to work with

(Default value = [])

Return type:

A numpy array of the same shape as the cnv files data table

create_parameter_instances(metadata={})[source]

Differentiates the individual parameter columns into separate parameter instances.

Parameters:

metadata (dict[str, dict] :) –

The structured metadata dictionary

(Default value = {})

Return type:

A dictionary of parameter instances

differentiate_table_description()[source]

The original method that structures data table metadata.

Needs heavy refactoring.

add_parameter(parameter)[source]

Adds one parameter instance to the collection.

Parameters:

parameter (Parameter :) – The new parameter

create_parameter(data, metadata={}, name='')[source]

Creates a new parameter instance with the given data and metadata.

The input data is either a numpy array or a single value. The single value will be broadcasted to the shape of the data table. A use-case would be the addition of an ‘event’ or ‘cast’ column.

Parameters:
  • data (np.ndarray | int | float | str :) – Data to use or expand

  • metadata (dict :) –

    Metadata for the new parameter

    (Default value = {})

  • name (str :) –

    Name to use for missing metadata values

    (Default value = “”)

Return type:

The new parameter instance

add_default_metadata(name, metadata={}, list_of_keys=['shortname', 'longinfo', 'name', 'metainfo', 'unit'])[source]

Fills up missing metadata points with a default value.

Parameters:
  • name (str :) – The value to use as default

  • metadata (dict :) –

    The present metadata

    (Default value = {})

  • list_of_keys (list :) – The expected metadata keys

Return type:

The full metadata dictionary

update_spans()[source]

Updates all spans of the parameters.

get_spans()[source]

Returns all span tuples of the parameters.

Return type:

list[tuple[int, int]]

get_pandas_dataframe()[source]

Returns a pandas DataFrame of the current parameter data.

Return type:

DataFrame

with_name_type(name_type='shortname')[source]

Uses the given name_type as column descriptors.

Parameters:

name_type (str :) –

The metadata name to use

(Default value = “shortname”)

reading_data_header(header_info=[])[source]

Reads the tables header data from the header.

Parameters:
  • header_info (list :) – the header values from the file

  • header_info – (Default value = [])

Return type:

Tuple[dict[str, dict], list[int]]

class seabirdfilehandler.parameter.Parameter(data, metadata)[source]

Bases: object

A representation of one parameter in a cnv file.

Consists of the values of the parameter as well as the metadata.

get_pandas_series()[source]

Returns a pandas Series of the current parameter data.

Return type:

Series

use_name(name_type='shortname')[source]

Uses the given name as parameter descriptor.

Parameters:

name_type (str :) –

The metadata name to use

(Default value = “shortname”)

update_span()[source]

Updates the data span.

Uses the first value if dtype is not numeric.