ctdam.proc.module module

class ctdam.proc.module.Module[source]

Bases: ABC

An interface to implement new processing modules against.

Is meant to perform and unify all the necessary work that is needed to streamline processing on Sea-Bird CTD data. Implementing classes should only overwrite the transformation method, that does the actual altering of the data. All other organizational overhead should be covered by this interface. This includes parsing to .cnv output with correct handling of the metadata header.

add_processing_metadata()[source]

Parses the module processing information into cnv-compliant metadata lines.

These take on the form of {MODULE_NAME}_{KEY} = {VALUE} for every key-value pair inside of the given dictionary with the modules processing info.

load_file(file_path)[source]

Loads the target files information into an CnvFile instance.

Parameters:

file_path (Path) – Path to the target file.

Return type:

CnvFile

abstractmethod to_cnv()[source]
class ctdam.proc.module.ArrayModule[source]

Bases: Module

Modules working on numpy arrays should implement this class.

Parameters:
  • input (Path | str | CnvFile | CTDData) – The data input

  • arguments (dict = {}) – The arguments to run the module with

  • output (str) – The output type, eg. cnv or python object

  • output_name (str | None) – The output name when writing to disk

  • default_values (dict) – The default arguments, if any

  • original_input_path (Path | str | None) – The path to original data file

  • bad_flag (float) – The value to consider as bad flag

abstractmethod transformation()[source]
Return type:

bool

get_array()[source]

Return the full data array.

Return type:

ndarray

get_data_size()[source]

Return the number of data points.

Return type:

int

create_flag_array_if_missing()[source]

Check flag array presence and create, if not found.

handle_new_flags(new_flag_array)[source]

Write number of flagged rows to metadata info and concatenate flags.

Parameters:

new_flag_array (ndarray) – The array of new flags

check_whether_working_on_binned_data()[source]

Raise error when working with binned data.

to_cnv()[source]
class ctdam.proc.module.DataFrameModule[source]

Bases: Module

abstractmethod transformation()[source]

The actual data transformation on the CTD data.

Needs to be implemented by the implementing classes.

Return type:

DataFrame

to_cnv(additional_data_columns=[], custom_data_columns=None)[source]

Writes the internal CnvFile instance to disk.

Uses the CnvFile’s output parser for that and organizes the different bits of information for that.

Parameters:
  • additional_data_columns (list[str]) –

    A list of columns that in addition to the ones inside the original dataframe.

    (Default value = [])

  • custom_data_columns (list | None) –

    A list of coulumns that will exclusively used to select the data items for the output .cnv .

    (Default value = None)

to_csv()[source]

Writes the dataframe as .csv to disk.

exception ctdam.proc.module.MissingParameterError(step_name, parameter_name)[source]

Bases: Exception

A custom error to throw when necessary parameters are missing from the input .cnv file.