ctdam.parser.ctddata module

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

Bases: object

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)

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)

Return type:

Tuple[Parameters, list]

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

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