ctdam.parser package¶
Submodules¶
- ctdam.parser.casts module
- ctdam.parser.custom_xarray_accessors module
ProcessingAccessorInputAccessorMetadataAccessorDataRetrievalAccessorDataRetrievalAccessor.btl_infoDataRetrievalAccessor.spans()DataRetrievalAccessor.sizeDataRetrievalAccessor.sample_rateDataRetrievalAccessor.bin_unitDataRetrievalAccessor.binnedDataRetrievalAccessor.sensor_strand()DataRetrievalAccessor.flattened_ds()DataRetrievalAccessor.numpy_array()DataRetrievalAccessor.pandas_dataframe
ExportAccessorQCAccessorPlotAccessor
- ctdam.parser.geomar_ctd_file_parser module
- ctdam.parser.read_ctd_data module
- ctdam.parser.seabird_data_files module
SeabirdDataFileSeabirdDataFile.path_to_fileSeabirdDataFile.file_nameSeabirdDataFile.file_dirSeabirdDataFile.dataSeabirdDataFile.metadataSeabirdDataFile.start_timeSeabirdDataFile.start_positionSeabirdDataFile.cruiseSeabirdDataFile.stationSeabirdDataFile.event_nameSeabirdDataFile.read_file()SeabirdDataFile.reading_start_time()SeabirdDataFile.reading_start_position()SeabirdDataFile.read_event_information()SeabirdDataFile.sensor_xml_to_flattened_dict()SeabirdDataFile.structure_metadata()
CnvFileHexFileBottleLogFileBottleFile
- ctdam.parser.sst_ctd_file_parser module
- ctdam.parser.xmlfiles module
Module contents¶
- class ctdam.parser.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.parser.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.parser.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.parser.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.parser.CnvFile(path_to_file, only_header=False)[source]¶
Bases:
SeabirdDataFileA representation of a cnv-file as used by SeaBird.
- class ctdam.parser.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.parser.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.parser.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.parser.XMLCONFile(path_to_file)[source]¶
Bases:
XMLFileA representation of a Sea-Bird .XMLCON file.