ctdam.proc.seabird package¶
Submodules¶
ctdam.proc.seabird.module module¶
- class ctdam.proc.seabird.module.ProcessingModule(name, exe_dir, psa_dir, exe_path=None, psa_path=None, new_file_suffix='')[source]¶
Bases:
objectCollects the information necesssary to run a Seabird Processing module.
A module needs paths to an exe, to a psa and to an input file. On top of that, a few non-mandatory settings can be specified, like the output file path or a new file name. The collected information is then used to feed a ProcessingStep.
- Parameters:
name (
str) – The name of the module. Is used to find corresponding files.exe_dir (
Path|str) – The path to the executable directory. Is used if no direct path to any executable is given.psa_dir (
Path|str) – The path to the configuration directory. Is used if no direct path to any config file is given.exe_path (
Path|str|None) – The path to the modules executable.psa_path (
Path|str|None) – The path to the modules configuration file.new_file_suffix (
str) – An optional suffix to append to the output file name.
- check_input_path(input_path, file_type, directory)[source]¶
Tests the given exe or config path and runs find_file upon failure.
The path needs to be absolute and present. This method basically performs all the logic to retrieve an executable and configuration path with the help of find_file.
- Parameters:
input_path (
Path|str|None) – The path to the file that needs testing. If none given, directly start searching a default one by calling find_file.file_type (
str) – The type of the file to check on. Either ‘exe’ or some form of configuration file, usually ‘psa’.directory (
Path) – The directory to search for, upon failure.
- Return type:
Path|None
ctdam.proc.seabird.routine module¶
- class ctdam.proc.seabird.routine.ProcessingRoutine(processing_info)[source]¶
Bases:
objectBatch processing of running multiple processing modules in sequence is realised by this class. It also allows batch processing of multiple files at the same time. In order to accomplish that, a very specific input is needed, specified in detail by a configuration .toml file. For that reason, a thorough input check takes place upon initialization.
- Parameters:
processing_info (
dict) – All the information necessary to run a processing routine. Can be built internally in other python code or, more often, will be the input from a .toml configuration file.
- create_modules()[source]¶
Loads the module information into individual module instances.
A module is the representation of one Sea-Bird module of the same name. It stores the path to the executable and a configuration .psa file.
- Return type:
list[ProcessingModule]
- create_steps()[source]¶
Creates a list of processing steps from the input information.
A step is the application of one processing module to a target data file, which usually is either .hex or .cnv .
- Return type:
list[ProcessingStep]
- find_xmlcon(input_file)[source]¶
Recursively searches for a corresponding .XMLCON file to a given input file.
- Parameters:
input_file (
Path) – The path to the target input file.- Return type:
Path|None
ctdam.proc.seabird.step module¶
- class ctdam.proc.seabird.step.ProcessingStep(module, input_path, xmlcon_path=None, output_path=None, original_input_path=None, new_name=None, verbose=False)[source]¶
Bases:
objectA representation of a single Seabird processing step.
One instance of this class corresponds to one Seabird processing module and its invocation on one single file.
- Parameters:
module (
ProcessingModule) – The Sea-Bird module to run.input_path (
Path|str) – The path to the target file.xmlcon_path (
Path|str|None) – The path to the XMLCON file.output_path (
Path|str|None) – The path to write the new file to. Default is the same as the input one.original_input_path (
Path|str|None) – The path to the target file of the whole processing workflow.new_name (
str|None) – Option to set a new name to the output file.verbose (
bool) – Allows to run the module in “window” mode, which gives the option to check and manipulate the modules configuration. Is suppressed by default.
- Return type:
A runnable instance.
- build_new_name(new_name, new_file_suffix)[source]¶
Sets the output file path with all the information given.
- Parameters:
new_name (
str|None) – The optional new output name.new_file_suffix (
str) – The optional suffix to append to the new output name.
- Return type:
Path
- run_string()[source]¶
Builds the command line command that is used to run the module.
Collects the different bits of information and options and handles them accordingly. Does also consider module specific specialities and the wanted verbosity.
- Return type:
list
- run(command=None, timeout=60)[source]¶
Handles the creation of the command line command.
Is mostly needed to correctly running the Sea-Bird processing modules on a linux system using the wine emulator.
- Parameters:
command (
list|None) – The command to run. If not given, creates it.
- run_process(command, timeout=60)[source]¶
Creates and monitors the execution of the module.
This is done in a separate process, to allow leveraging multi-threading. Does also set a timeout for killing the process after some time.
- Parameters:
command (
list) – The command to run, with all the necessary parameters.timeout (
int) – The time in seconds to wait for the execution to finish. Kills the process otherwise.