ctdam.parser.casts module

class ctdam.parser.casts.Casts(path_to_data='', ctd_data=[], processing_info={}, pattern='', plot=False, show_plot=True, plot_dir='htmls')[source]

Bases: UserList

A structure to ease working with multiple ctd casts.

Can work with ascii files, converted (.cnv) or non-converted (.hex), as well as data within python objects (CTDData). Automates the very basic actions ussually performs on these data: converting, processing, plotting and exporting. The cpu-heavy actions (convertion and processing) are calculated in parallel, using multithreading.

Parameters:
  • path_to_data (Path | str) – Path to target files

  • ctd_data (list[Dataset]) – A list of target CTDData objects

  • processing_info (dict) – Processing configuration

  • pattern (str) – A file pattern to filter the target files with

  • plot (bool) – Whether to create .html plots of the target files

  • show_plot (bool) – Whether to display the plots in a browser

  • plot_dir (Path | str) – The directory to store the plots in

data[source]

A list of CTDData objects

Type:

list

processing_info[source]

A processing workflow as used in Procedure

Type:

dict

path_to_data[source]

The input path to the data file(s)

Type:

Path

anomalous_data[source]

A list of data files that seem to be suspiciously small

Type:

list

cruise[source]

The name of the cruise the data files were collected in

Type:

str

sensor_info[source]

The sensor structure as generated by get_unique_sensor_data()

Type:

list

plot_dir[source]

A file path where generated data plots are saved to

Type:

Path

convert(file)[source]

Converts .hex files.

Can work with hex2py processing settings and hides all warnings.

Parameters:

file (Path) – Path to target hex files

check_converted_data()[source]

Basic output data size check.

Catches very obvious test or wrong CTD data. These are saved in an anomalies attribute to allow human intervention.

Return type:

list[Dataset]

read_sensor_info()[source]

Parses all sensor metadata in one structure.

Usually, the sensor layout does not change during one cruise. But if it does, this function should detect that change and document it with a new list that displays the cast number and the differing sensor metadata.

process(processing_info, target_files=[])[source]

Applies the given processing workflow to all CTD data.

Uses multiprocessing for parallel processing and tqdm to display the progress.

Parameters:
  • processing_info (dict) – Processing workflow configuration

  • target_files (list[Dataset]) – The files to process

plot(show_plot=True)[source]

Creates .html plots of the target data.

Uses bokeh for interactive plotting and creates one ‘main’ .html that incorporates all individual cast plots.

Parameters:

show_plot (bool) – Whether to open the plot in a browser

to_tsv(file_name=None)[source]

Exports the target file data into one great .tsv file.

Parameters:

file_name (str | Path | None) – The name of the exported file