ctdam.parser.seabird_data_files module

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

Bases: object

The base class for all Sea-Bird data files, which are .cnv, .btl, and .bl . One instance of this class, or its children, represents one data text file. The different information bits of such a file are structured into individual lists or dictionaries.

path_to_file[source]

The path to the file this object represents

Type:

Path

file_name[source]

The file name

Type:

str

file_dir[source]

The directory the file resides in

Type:

Path

data[source]

The data table

Type:

list

metadata[source]

Parsed custom metadata

Type:

dict

start_time[source]

The start time of the data acquisition

Type:

datetime

start_position[source]

Latitude, Longitude tuple

Type:

tuple

cruise[source]

The name of the cruise the data belongs to

Type:

str

station[source]

The station idenifier of the data

Type:

str

event_name[source]

The streamlined data event name, consisting of cruise and station name

Type:

str

read_file()[source]

Reads and structures all the different information present in the file.

Lists and Dictionaries are the data structures of choice. Uses basic prefix checking to distinguish different header information.

reading_start_time()[source]

Extracts the Cast start time from the metadata header.

Return type:

datetime | None

reading_start_position()[source]

Extracts the Casts starting position.

Return type:

Tuple

read_event_information(regex_string='(?P<c>[a-z]{1,3}\\\\d{1,3})(-|_|\\\\/)?(?P<cn>1|2)?(-|_)(?P<s>\\\\d{1,4})(-|_)(?P<e>\\\\d{1,2})', leading_zeroes=False)[source]

Save the event metadata of the cast inside self.station .

Additionally save cruise information inside self.cruise, if possible. The data sources are file name and custom metadata header, in this order.

sensor_xml_to_flattened_dict(sensor_data)[source]

Reads the pure xml sensor input and creates a multilevel dictionary, dropping the first two dictionaries, as they are single entry only.

Parameters:

sensor_data (str) – The raw xml sensor data.

Return type:

list[dict] | dict

structure_metadata(metadata_list)[source]

Creates a dictionary to store custom metadata, of which Sea-Bird allows 12 lines in each file.

Parameters:

metadata_list (list) – A list of the individual lines of metadata found in the file

Return type:

dict

class ctdam.parser.seabird_data_files.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.seabird_data_files.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.seabird_data_files.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.seabird_data_files.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.