ctdam.parser.cnvfile module

class ctdam.parser.cnvfile.CnvFile(path_to_file, only_header=False, create_dataframe=False, absolute_time_calculation=False, event_log_column=False, coordinate_columns=False)[source]

Bases: DataFile

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

This class intends to fully extract and organize the different types of data and metadata present inside of such a file. Downstream libraries shall be able to use this representation for all applications concerning cnv files, like data processing, transformation or visualization.

To achieve that, the metadata header is organized by the parent-class, DataFile, while the data table is extracted by this class. The data representation can be a numpy array or pandas dataframe. The handling of the data is mostly done inside parameters, a representation of the individual measurement parameter data and metadata.

This class is also able to parse the edited data and metadata back to the original .cnv file format, allowing for custom data processing using this representation, while still being able to use Sea-Birds original software on that output. It also allows to stay comparable with other parsers or methods in general.

Parameters:
  • path_to_file (Path | str) – The path to the file

  • only_header (bool) – Whether to stop reading the file after the metadata header.

  • create_dataframe (bool) – Whether to create a pandas DataFrame from the data table.

  • absolute_time_calculation (bool) – Whether to use a real timestamp instead of the second count

  • event_log_column (bool) – Whether to add a station and device event column from DSHIP

  • coordinate_columns (bool) – Whether to add longitude and latitude from the extra metadata header

create_dataframe()[source]

Plain dataframe creator.

Return type:

DataFrame

absolute_time_calculation()[source]

Replaces the basic cnv time representation of counting relative to the casts start point, by real UTC timestamps.

A new parameter column, ‘datetime’, will be created.

Return type:

bool

add_start_time()[source]

Create a parameter column holding the start time.

Return type:

bool

get_processing_step_infos()[source]

Collects the individual validation modules and their respective information, usually present in key-value pairs.

Return type:

CnvProcessingSteps

df2cnv(df=None)[source]

Parses a pandas dataframe into a list that represents the lines inside of a cnv data table.

Parameters:

df (DataFrame | None) – DataFrame to export, default is self.df

Return type:

list

array2cnv()[source]

Parses a numpy array into the .cnv data format.

Delegates to the CTDData method of the same name.

Return type:

list

to_cnv(file_name='')[source]

Writes the data and metadata inside of this instance as new .cnv file to disk.

Delegates to the CTDData method of the same name.

Parameters:

file_name (Path | str) – The new file name to use for writing

to_ctd_data()[source]

Create a CTDData instance using the information inside this .cnv file instance.

Return type:

The CTDData representation of this file.

add_processing_metadata(module, key, value)[source]

Adds new processing lines to the list of processing module information

Parameters:
  • module (str) – The name of the processing module

  • key (str) – The description of the value

  • value (str) – The information

add_station_and_event_column()[source]

Adds a column with the DSHIP station and device event numbers to the dataframe. These must be present inside the extra metadata header.

Return type:

bool

add_position_columns()[source]

Adds parameter columns with the longitude and latitude information.

Return type:

bool

add_cast_number(number=None)[source]

Adds a parameter column holding the cast number inside a cruise.

Kept for legacy compatibility.

Parameters:

number (int | None) – The cast number of this files cast

Return type:

bool