CTD Data

A CTDData object is meant to be the primary data and metadata storage of one CTD cast. In Sea-Bird terms you can think of it to be the python internal equivalent of a .cnv file. In fact, the ctdam parser of SBE9/11 .cnv files, CnvFile does feature an export method, to_ctd_data(), to generate a CTDData object. Other parsers are meant to follow, for example for SBE19s and SBE37s, for the Sea&Sun CTD format and the custom CTD file format used at GEOMAR. And if you are in need of another, feel free to reach out!

I/O parsing

input parsing

A CTDData object can be retrieved by conversion

from ctdam.conv import decode_hex

ctd_data = decode_hex('sbs_data/hex/EMB356_11-1.hex')

or by parsing a .cnv file

from ctdam.parser import CnvFile

ctd_data = CnvFile('sbs_data/cnv/EMB356_11-1.cnv').to_ctd_data()

output parsing

At the moment, you can parse a CTDData object to Sea-Birds .cnv format

ctd_data.to_cnv()

as well as NetCDF

ctd_data.to_netCDF()

Information to access

You can display all kinds of information from inside the source .hex or .cnv files, like header, custom metadata, file_name and much more:

>>> ctd_data.header
['* Sea-Bird SBE 9 Data File:\n', '* FileName = C:\\CTD\\CTD_Data\\EMB356\\E
MB356_011-01_CTD_0010.hex\n', '* Software Version Seasave V 7.26.7.121\n',
....]

>>> ctd_data.metadata
{'Cruise': 'EMB356', 'Station': 'EMB356_11-1', 'Platform': 'CTD', 'Cast': '0
010', 'Operator': 'Johann Ruickoldt', 'GPS_Time': '08.02.2024 08:30:10', 'GP
S_Lat': '54  9.308 N', 'GPS_Lon': '11 17.587 E', 'Echo_Depth': '25.7 m', 'Ai
r_Pressure': '1000.8 hPa', 'WsStartID': '251', 'Pos_Alias': 'TF0021'}

>>> ctd_data.file_name
'EMB356_11-1'

Apart from these attributes, other interesting ones are parsed sensor information

>>> ctd_data.sensor_info
[{'Channel': '1', 'SensorName': 'Temperature', '@SensorID': '55', 'SerialNum
ber': '5492', 'CalibrationDate': '2023-12-18', 'UseG_J': '1', 'A': '0.000000
00e+000', 'B':...]

processing step information

>>> ctd_data.processing_steps
[hex2py, wildedit, wfilter, alignctd, celltm, binning]

>>> ctd_data.processing_steps[5].metadata
{'metainfo': '2026.02.19 11:35:18, ctdam python package, v1.4.1', 'bin_varia
ble': 'prDM', 'bin_size': '1', 'cast_type': 'down'}

and cast start and end points

>>> ctd_data.cast_borders
{'down_start': 0, 'down_end': 42009, 'input_size': 78018}

Functionality

Noticeable methods to run on a CTDData object are processing ctd_data.process(), and plotting ctd_data.plot(), which run the given operations directly on the CTDData objects.

Full class description

class ctdam.parser.ctddata.CTDData(parameters, metadata_source, processing_steps=[])[source]

Class to store data and metadata representing one single CTD cast in.

Is meant to work as single exchange format for CTD data. At the moment, Sea-Birds .hex and .cnv file can be parsed in this format, but other CTD data formats are meant to follow. From this class, several output options are possible, at the moment, the .cnv format is the only one available.

Parameters:
  • parameters (Parameters) – A parameters instance holding all data values

  • metadata_source (HexFile | CnvFile) – Source file information

  • processing_steps (CnvProcessingSteps) – The processing history of the file upon creation (Default: empty)

parameters[source]

All data inside individual Parameter instances. All attributes and methods can be accessed directly.

Type:

Parameters

metadata_source[source]

The complete parent file the data is parsed from. All attributes and methods can be accessed directly.

Type:

HexFile | CnvFile

raw_sensor[source]

Sensor metadata parsed into accessible key-value pairs

Type:

dict

sensor_info[source]

Tidied sensor metadata

Type:

list

processing_steps[source]

Structure to hold Processing metadata

Type:

CnvProcessingSteps

conductivity_on_creation[source]

The original conductivity

Type:

np.array

cast_borders[source]

Structured cast start and end points

Type:

dict

output_cnv_data[source]

The full file written as ascii .cnv file

Type:

list

output_parameters[source]

The parameters exported to a ascii .cnv file

Type:

Parameters

process(proc_settings={'modules': {'alignctd': {}, 'binavg': {}, 'celltm': {}, 'wfilter': {}, 'wildedit_geomar': {}}, 'output_type': 'internal', 'remove_flags': False})[source]

Applies a processing workflow to this CTD data.

Parameters:

proc_settings (dict) – A processing workflow that can be parsed by ctdam.proc.Procedure

plot(*args, **kwargs)[source]

Plots this CTD Data.

Parameters:
  • 'ctdam.vis.visualize.basic_bokeh_plot' (Will be passed to)

  • print_plot (bool) – Whether to save the plot to disk (Default value = False)

  • output_name (str) – The name of the output file (Default value = “”)

  • output_directory (Path | str) – The directory to store the output file in (Default value = “”)

  • metadata (bool) – Whether to save metadata in the file (Default value = True)

  • show_plot (bool) – Whether to open the plot in a browser (Default value = True)

  • y_axis_params (list[str] :) – Possible parameters for the y axis

  • config_path (Path | str) – The path to the config file (Default value = “vis_config.toml”)

get_cast_borders_dict()[source]

Parses the cast border information into a manageable format.

Return type:

dict

update_salinity()[source]

Re-calculate the salinity values.

During processing, the conductivity, pressure and temperature values may change. In order to use this upgraded information in depending parameters, they need to be re-calculated.

array2cnv(parameters=None, bad_flag=-9.99e-29)[source]

Parse the numpy array data into .cnv data format.

Parameters:
  • parameters (Parameters | None) – A specific parameters instance or self.parameters

  • bad_flag – The value to use to indicate bad values (Default value = -9.990e-29)

Return type:

list

parse_output_sensor_info()[source]

Recreate the sensor information of a .cnv file.

Return type:

list

get_processing_info()[source]

Return processing information.

Does add hex2py metadata if no conversion information present.

Return type:

list

create_header(parameters=None, reduced_header=False)[source]

Re-creates the .cnv header.

Parameters:
  • parameters (Parameters | None) – A specific parameters instance or self.parameters

  • reduced_header (bool) – Whether to build a streamlined non-cnv header (Default value = False)

Return type:

list

extra_data_table_desc(data_table_description, system_utc)[source]

A helper method for .cnv header generation.

Parameters:
  • data_table_description (list) – Data table information from parameters

  • system_utc (str) – The system time

Return type:

list

drop_flagged_rows(parameters=None)[source]

Remove data rows that are flagged bad and the flag column.

Parameters:

parameters (Parameters | None) – A specific parameters instance or self.parameters

pick_output_columns(parameters, mode='all')[source]

Define the parameter columns to output.

Parameters:
  • parameters (Parameters) – A specific parameters instance or self.parameters

  • mode (list[str] | Literal['all', 'default']) – List of output parameters, or descriptors ‘all’ or ‘default’ (Default value = “all”)

to_cnv(file_path='', remove_flags=True, output_parameters='all', reduced_header=False, bad_flag=-9.99e-29)[source]

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

Parameters:
  • file_path (Path | str) – Path to the new .cnv file, will default to the input file name

  • remove_flags (bool) – Whether to remove flagged rows (Default value = True)

  • output_parameters (list[str] | Literal['all', 'default']) – Which parameter columns to output (Default value = “all”)

  • reduced_header (bool) – Whether to output a reduced head (Default value = False)

  • bad_flag (float) – The value to use as bad value indicator (Default value = -9.990e-29)

to_netCDF(file_path='', toml_path=None, nc_path=None)[source]

creates a netCDF file out of a hex or cnv file.