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[CTDData]) – 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

convert(file)[source]

Converts .hex files.

Can work with hex2py processing settings and hides all warnings.

Parameters:

file (Path) – Path to target file

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[CTDData]

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) – The processing workflow information

  • target_files (list[CTDData]) – The target files to process, if none, uses self.data (Default value = [])

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 (Default value = True)

to_tsv(file_name=None)[source]

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

Parameters:

file_name (str | Path | None) – The new file name, if none, uses ‘cruise_name_CTD.tab’ (Default value = None)