multifile
Provides tools for combining multiple ADCP binary files from a single deployment into one file before processing. Files are appended in the order they are found (alphabetical by default).
Functions
Function |
Description |
|---|---|
|
Combine all ADCP files found in a folder |
|
Combine a specific ordered list of files |
|
Check a single file for structural validity |
Usage
from pyadps.processing.multifile import combine_adcp_files, combine_file_list
# Combine all *.000 files in a folder (alphabetical order)
result = combine_adcp_files('raw_data/', 'combined.000')
if result.success:
print(f"Combined {result.files_processed} files, {result.total_ensembles} ensembles")
else:
print(result.error_message)
# Combine a specific ordered list
result = combine_file_list(
['data/deploy_001.000', 'data/deploy_002.000', 'data/deploy_003.000'],
'combined.000'
)
Validate before combining
from pyadps.processing.multifile import validate_adcp_file
from pathlib import Path
for f in sorted(Path('raw_data/').glob('*.000')):
v = validate_adcp_file(f)
status = 'OK' if v.is_valid else v.error_message
truncated = ' (truncated)' if v.is_truncated else ''
print(f"{f.name}: {status}{truncated}")
Command line
python -m pyadps.processing.multifile raw_data/ -o combined.000
python -m pyadps.processing.multifile raw_data/ -o combined.000 --strict # stop on first error
python -m pyadps.processing.multifile raw_data/ -o combined.000 -p "*.pd0" # custom extension
Return Objects
CombineResult (returned by combine_adcp_files and combine_file_list):
Field |
Description |
|---|---|
|
Whether the combination completed |
|
Number of files successfully included |
|
Total ensembles in output |
|
Path to the output file |
|
List of filenames that were skipped |
|
Populated if |
FileValidationResult (returned by validate_adcp_file):
Field |
Description |
|---|---|
|
Whether the file has a valid ADCP structure |
|
Number of complete ensembles found |
|
Bytes per ensemble |
|
Last ensemble is incomplete |
|
Populated if |
Non-Obvious Behaviors
Ensemble size must match across all files. All files in a deployment should
have the same ensemble size (bytes per ensemble). A mismatch means different
instrument configurations or a corrupt file — combining them would produce
unreadable output. The check is enabled by default; pass
require_matching_ensemble_size=False only if you are certain the mismatch is
benign.
Truncated files are skipped by default (skip_invalid=True). A truncated
file at the end of a deployment is common when the instrument was recovered
mid-ensemble. The partial last ensemble is dropped and the rest of the file is
included.
File order matters. Use combine_file_list() with an explicitly ordered
list if alphabetical sorting does not match chronological order.
See Also
autoprocess — Run the full pipeline on a combined file
core —
ProcessedDatasetfor step-by-step processing