ctdam.parser package

Submodules

Module contents

ctdam.parser.parse(file_path, downcast_only=False)[source]

Parse different file types to a cf-compliant xarray Dataset.

Can handle Seabirds .cnv and .hex file formats and Sea&Suns .TOB file format.

Parameters:

file_path (Path | str) – The path to the ctd data file

Return type:

Dataset

class ctdam.parser.CnvFile(path_to_file, only_header=False)[source]

Bases: SeabirdDataFile

A representation of a cnv-file as used by SeaBird.

parse_cnv_data_format()[source]
Return type:

dict[str, ndarray]

absolute_time_calculation()[source]

Replaces the basic cnv time representation of counting relative to the casts start point, by a unix timestamp.

Return type:

ndarray

class ctdam.parser.HexFile(path_to_file, path_to_xmlcon='', *args, **kwargs)[source]

Bases: SeabirdDataFile

A representation of a .hex file as used by SeaBird.

When no corresponding .xmlcon file given, a search algorithm is used to determine the matching .xmlcon automatically.

parse_hex(hex)[source]

Parse the individual hex information bits using sbe.odf

Parameters:

hex (Path | str) – The path to the target hex file

Return type:

Dataset

get_corresponding_xmlcon(path_to_xmlcon='')[source]

Finds the best matching .xmlcon file inside the same directory.

The logics works as follows:

  • if an .xmlcon of the same name exists, take that

  • else, find all .xmlcons of the same cruise inside the given directory and use the one used by the previous .hex file, sorted by file name.

Return type:

XMLCONFile | None

class ctdam.parser.BottleFile(path_to_file)[source]

Bases: SeabirdDataFile

Class that represents a Sea-Bird Bottle File (.btl) .

create_dataframe()[source]

Creates a dataframe out of the .btl file. Handles the double data header correctly.

adding_timestamp_column()[source]

Creates a timestamp column that holds both, Date and Time information.

selecting_rows(df=None, statistic_of_interest=['avg'])[source]

Creates a dataframe with the given row identifier, using the statistics column. A single string or a list of strings can be processed.

Parameters:
  • df (pandas.Dataframe :) – the files Pandas representation (Default value = self.df)

  • statistic_of_interest (list | str) – collection of values of the ‘statistics’ column in self.df

reading_data_header()[source]

Identifies and separatly collects the rows that specify the data tables headers.

class ctdam.parser.BottleLogFile(path_to_file)[source]

Bases: SeabirdDataFile

Bottle Log file (.bl) representation, that extracts the three different data types from the file: reset time and the table with bottle IDs and corresponding data ranges.

data_whitespace_removal()[source]

Strips the input from whitespace characters, in this case especially newline characters.

Return type:

list

obtaining_reset_time()[source]

Reading reset time with small input check.

Return type:

datetime

create_dataframe()[source]

Creates a dataframe from the list specified in self.data.

Return type:

DataFrame

class ctdam.parser.XMLCONFile(path_to_file)[source]

Bases: XMLFile

A representation of a Sea-Bird .XMLCON file.

read_xml_config()[source]

Parse the companion .xmlcon calibration file into self.cfgp.

Locates the xmlcon file alongside the hex file, parses the SensorArray block, and converts coefficient strings to floats. Sensors not in the supported set are skipped.

xml_coeffs_to_float(cfgp)[source]

Returns float-parsed xml coefficients.

get_sensor_info()[source]

Creates a multilevel dictionary, dropping the first four dictionaries, to retrieve pure sensor information.

Return type:

list[dict]