API¶
Entry functions to interact with the module:
- ctdam.parser.read_ctd_data.parse(file_path, downcast_only=False)[source]¶
Parse different file types to a cf-compliant xarray Dataset.
Can handle Seabirds .cnv and .hex file formats and Sea&Suns .TOB file format.
- Parameters:
file_path (
Path|str) – The path to the ctd data file- Return type:
Dataset
- ctdam.entry.functions.process(input='', modules=['loopremoval', 'wildedit', 'wfilter', 'alignctd', 'celltm', 'binavg'], other_settings={}, use_multiprocessing=True, **kwargs)[source]¶
Run processing workflows on CTD data in file or memory form.
Does support multiple ‘modes’, depending on the input. 1) given a path to a directory, all parse-able CTD data formats found inside that directory will be parsed and processed, according to the workflow settings. 2) a path to a file will lead to the parsing and processing of that file. 3) similarly, the input could also consist of already parsed data, as single xarray dataset or a list of datasets.
The output will be processed cf-compliant xarray datasets.
- Parameters:
input (
Path|str|Dataset|list) – The data source to processmodules (
dict|list) – The processing modules to apply to the dataother_settings (
dict) – Processing configuration to useuse_multiprocessing (
bool) – Whether to parallelize the operationskwargs – Will be parsed as additional configuration options
- Return type:
Dataset|List[Dataset]- Returns:
A list of, or a single xarray Dataset.
- ctdam.entry.functions.plot(input, print_plot=True, output_directory='html', output_name='', html_title='', overwrite=False, no_new_plots=False, size_limit=10, filter='', show_html=True, config_path='vis_config.toml', file_type='cnv', use_multiprocessing=True, **kwargs)[source]¶
Display CTD data as interactive bokeh plots inside the web browser.
Single files or datasets will result in simnple plots. Multiple ones will all be individually plotted and a main entry html file will point to these individual plot files.
- Parameters:
input (
Path|str|Dataset|list) – The directory to look for data files to plotprint_plot (
bool) – Whether to write plot files to disk (Default value = True)output_directory (
Path|str) – The directory to save .html file to (Default value = “html”)output_name (
str) – The name of the main html file (Default value = “main.html”)html_title (
str) – The header of the main html (Default value = “”)overwrite (
bool) – Whether to overwrite existing html plot files (Default value = False)no_new_plots (
bool) – Whether to not overwrite existing plot htmls (Default value = False)size_limit (
int) – Data file size limit in MB (Default value = 10)filter (
str) – A search filter for files (Default value = “”)show_html (
bool) – Whether to open main html in browser (Default value = True)config_path (
Path|str) – The path to vis configuration info (Default value = “vis_config.toml”)file_type (
str) – The file type to search for (Default value = “cnv”)use_multiprocessing (
bool) – Whether to use paralleliztion for plotting (Default value = True)kwargs – All additional parameters will be given to basic_bokeh_plot
- class ctdam.entry.casts.Casts(path_to_data='', ctd_data=[], processing_info={}, pattern='', plot=False, show_plot=True, plot_dir='htmls', use_multiprocessing=True)[source]¶
Work on multiple CTD casts simultaneously.
Parses all known CTD data formats if a file path given. Can also be initialized with instances of the cf-compliant xarray dataset structure used throughout ctdam. After parsing, straightforward processing and plotting can be run on all data. In the end, a grand data table of all concatenated casts can be written to disk as .tsv file. The cpu-heavy actions (converting and processing) can be executed in parallel, using multithreading.
- Parameters:
path_to_data (
Path|str) – Path to target filesctd_data (
list[Dataset]) – A list of target xarray Dataset objectsprocessing_info (
dict) – Processing configurationpattern (
str) – A file pattern to filter the target files withplot (
bool) – Whether to create .html plots of the target filesshow_plot (
bool) – Whether to display the plots in a browserplot_dir (
Path|str) – The directory to store the plots inuse_multiprocessing (
bool) – Whether to parallelize conversion and processing
- get_cruise_bottles(path_to_bl_files='', path_to_write='')[source]¶
Returns a DataFrame with all bottles closed during a single cruise.
- Parameters:
path_to_bl_files (
Path|str) – A file path to .bl files, if not in the same directorypath_to_write (
Path|str) – File path to an output .csv file
- Return type:
DataFrame
- convert(file)[source]¶
Converts known CTD data files.
Can work with hex2py processing settings and hides all warnings.
- Parameters:
file (
Path) – A file path to a convertable CTD data file- Return type:
A parsed xarray Dataset
- 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]
- 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 parameterstarget_files (
list[Dataset]) – The input CTD data to process