ctdam package¶
Subpackages¶
- ctdam.conv package
- ctdam.parser package
- Submodules
- Module contents
- ctdam.proc package
- ctdam.qc package
- ctdam.vis package
Submodules¶
Module contents¶
- ctdam.get_cast_borders(pressure, downcast_only=True, min_size_factor=0.01, min_soak_window=100, max_fd_quotient=6, prominence_divisor=7, win_size_divisor=500, min_velocity_quotient=15, min_velocity=0.045)[source]¶
Calculates start and end points of one CTD cast.
Uses first (fd) and second derivatives (sd) for that. Relies on carefully fine-tuned parameters that are set as default values. These can be fit to any kind of CTD data.
- Parameters:
pressure (
ndarray) – Pressure arraydowncast_only (
bool) – Whether to only work with downcast data (Default value = True)min_size_factor (
float) – Factor to check final dataset size against (Default value = 0.01)min_soak_window (
int) – Downcast_start: minimum size of soaking window (Default value = 100)max_fd_quotient (
int) – Downcast_start: Cut-off of fd height (Default value = 6)prominence_divisor (
int) – Downcast_start: Minimum size of sd peak prominence (Default value = 7)win_size_divisor (
int) – Downcast_start: Search window size to check fd means (Default value = 500)min_velocity_quotient (
int) – Downcast_start: Minimum velocity cut-off (Default value = 15)min_velocity (
float) – Downcast_start: Minimum velocity cut-off (Default value = 0.045)
- Return type:
dict
- ctdam.get_potential_density(practical_salinity, temperature, pressure, longitude, latitude)[source]¶
- Return type:
ndarray
- class ctdam.Casts(path_to_data='', ctd_data=[], processing_info={}, pattern='', plot=False, show_plot=True, plot_dir='htmls')[source]¶
Bases:
UserListA 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 filesctd_data (
list[Dataset]) – A list of target CTDData 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 in
- 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 configurationtarget_files (
list[Dataset]) – The files to process
- ctdam.read_ctd_data(path_to_ctd_data_file)[source]¶
Parse different file types to a cf-compliant xarray Dataset
- Parameters:
path_to_ctd_data_file (
Path|str) – The path to the ctd data file- Return type:
Dataset
- ctdam.read_cnv(path_to_cnv_file, only_header=False)[source]¶
Parse Seabird .cnv data to cf-compliant xarray Dataset.
- Parameters:
path_to_cnv_file (
Path|str) – The path to the .cnv fileonly_header (
bool) – Whether to only parse the header information
- Return type:
Dataset
- ctdam.read_hex(path_to_hex_file)[source]¶
Parse Seabird .hex data to cf-compliant xarray Dataset.
- Parameters:
path_to_cnv_file (Path | str :) – The path to the .hex file
- Return type:
Dataset
- class ctdam.CnvFile(path_to_file, only_header=False)[source]¶
Bases:
SeabirdDataFileA representation of a cnv-file as used by SeaBird.
- class ctdam.HexFile(path_to_file, path_to_xmlcon='', *args, **kwargs)[source]¶
Bases:
SeabirdDataFileA representation of a .hex file as used by SeaBird.
When no corresponding .xmlcon file given, a search algorithm is used to determine the matching .xmlcon automatically.
- parse_hex(hex)[source]¶
Parse the individual hex information bits using sbe.odf
- Parameters:
hex (
Path|str) – The path to the target hex file- Return type:
Dataset
- get_corresponding_xmlcon(path_to_xmlcon='')[source]¶
Finds the best matching .xmlcon file inside the same directory.
The logics works as follows:
if an .xmlcon of the same name exists, take that
else, find all .xmlcons of the same cruise inside the given directory and use the one used by the previous .hex file, sorted by file name.
- Return type:
XMLCONFile|None
- class ctdam.BottleFile(path_to_file)[source]¶
Bases:
SeabirdDataFileClass that represents a Sea-Bird Bottle File (.btl) .
- create_dataframe()[source]¶
Creates a dataframe out of the .btl file. Handles the double data header correctly.
- adding_timestamp_column()[source]¶
Creates a timestamp column that holds both, Date and Time information.
- selecting_rows(df=None, statistic_of_interest=['avg'])[source]¶
Creates a dataframe with the given row identifier, using the statistics column. A single string or a list of strings can be processed.
- Parameters:
df (pandas.Dataframe :) – the files Pandas representation (Default value = self.df)
statistic_of_interest (
list|str) – collection of values of the ‘statistics’ column in self.df
- class ctdam.BottleLogFile(path_to_file)[source]¶
Bases:
SeabirdDataFileBottle Log file (.bl) representation, that extracts the three different data types from the file: reset time and the table with bottle IDs and corresponding data ranges.
- class ctdam.XMLCONFile(path_to_file)[source]¶
Bases:
XMLFileA representation of a Sea-Bird .XMLCON file.
- ctdam.process(input='', modules=['loop_removal', 'wildedit_geomar', 'wfilter', 'alignctd', 'celltm', 'binavg'], other_settings={}, use_multiprocessing=True, **kwargs)[source]¶
- Return type:
Dataset|List[Dataset]
- ctdam.is_directly_measured_value(parameter)[source]¶
Returns whether a parameter has been measured via a sensor or is calculated.
- Return type:
bool
- ctdam.fill_file_type_dir(file_type_dir, file, copy=True)[source]¶
Copies the target input and output files into individual type directories.
A ‘file type directory’ is a directory that is meant to collect all the file of the same file extension that accumulate over multiple processings. For typical Sea-Bird processings you usually end up with something like this:
- root-dir
hex
cnv
XMLCON
btl
bl
hdr
- Parameters:
file (
Path)copy (
bool) – (Default value = True)
- class ctdam.Workflow(ds, configuration, auto_run=True)[source]¶
Bases:
objectRuns a couple of processing steps in sequence on one or more CTD data source files.
It can use seabird internal processing modules, as well as custom ones. These can be in the form of independent windows exes or just pure python code. The input data can be .hex, .cnv or python data representations, predominantly CTDData. The input and all module and extra information is stored in a dict that usually will be generated by the settings Configuration module that reads a toml config.
- Parameters:
configuration (
dict|Configuration) – The information necessary to run a processing procedure.auto_run (
bool) – Whether to autopilot the whole procedure.
- load_config()[source]¶
Thorough input/format check of the processing configuration, that either stems from a .toml config file, or is a self-build dictionary. Checks for the presence of certain keys, and then, depending on their importance, either fails or sets default values.
- new_file_path(file=PosixPath('.'))[source]¶
Creates the new output file path.
Takes the file type directory or the given output directory and joins them with the given output name.
- Parameters:
file (
Path) – The current path to the target file.- Return type:
Path
- run()[source]¶
Performs the processing on all target files.
This is the ‘main’ method of the procedure. All previous methods prepare data for this method to then finally transform the input files into the wanted format. The main purpose of this method is the coordination of the two different forms of processing modules: standalone executables with config files, mainly Sea-Bird processing modules, and python-internal classes that implement the Module interface. The caveats are mainly the switching from one form to the other. This for example results in a in or out parsing of a CnvFile object.
- Return type:
Dataset
- ctdam.cruise_plots(directory='', output_directory='html', output_name='main.html', embed_contents=False, html_title='', overwrite=False, no_new_plots=False, size_limit=10, filter='', show_html=True, config_path='vis_config.toml', file_type='cnv')[source]¶
Run basic_bokeh_plot and create_main_html and handle inputs.
- Parameters:
directory (
Path|str) – The directory to look for data files to plot (Default value = “”)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”)embed_contents (
bool) – Whether to embed plot htmls into main html (Default value = False)html_title (
str) – The header of the main html (Default value = “”)overwrite (
bool) – Whether to overwrite an existing main html (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”)
- Return type:
Path|None
- ctdam.create_main_html(directory_path, output_name='main_plots.html', output_directory='', embed_contents=True, title='', show_html=True)[source]¶
Assemble a main .html file that stores all individual .html plots.
Does also allow to interactively change plotting parameters and the seamless selection of plots.
- Parameters:
directory_path (
Path|str) – The path to the .html plot filesoutput_name (
str) – The name of the main .html file (Default value = “main_plots.html”)output_directory (
Path|str) – The directory to write the main .html file to (Default value = “”)embed_contents (
bool) – Whether to embed the .html plots into the main html file (Default value = True)title (
str) – The title of the main file (Default value = “”)show_html (
bool) – Whether to open the main .html in a browser (Default value = True)
- Return type:
Path|None
- ctdam.basic_bokeh_plot(ctd_data, print_plot=False, output_name='', output_directory='', metadata=True, show_plot=True, y_axis_params=['pressure', 'depth'], config_path='vis_config.toml')[source]¶
Create a .html plot for a CTD cast.
- Parameters:
ctd_data (
Path|str|Dataset) – The data to operate onprint_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 axisconfig_path (
Path|str) – The path to the config file (Default value = “vis_config.toml”)