pd0_parser
Low-level binary parser for RDI ADCP files in PD0 format. Returns raw data as NumPy arrays.
Note
Most users should use binary_reader instead, which wraps this module
and returns convenient xarray.Dataset objects. Use pd0_parser only if
you need direct binary access or are building a custom reader.
Functions
Function |
Description |
|---|---|
|
Parse file structure — ensemble locations and data type offsets |
|
Read static instrument configuration (36 fields × n ensembles) |
|
Read per-ensemble sensor data (48 fields × n ensembles) |
|
Read 3D profile data — velocity, correlation, echo, percent good, status |
Usage
Call fileheader() once and pass its output to all other functions — this
avoids re-scanning the file for each data type.
from pyadps.io import pd0_parser
# Parse file structure once
dt, byte, byteskip, offset, idarray, n_ens, err = pd0_parser.fileheader('deployment.000')
# Reuse for all subsequent reads
fl, _, _ = pd0_parser.fixedleader('deployment.000', byteskip, offset, idarray, n_ens)
vl, _, _ = pd0_parser.variableleader('deployment.000', byteskip, offset, idarray, n_ens)
vel, _, _, _, _ = pd0_parser.datatype('deployment.000', 'velocity',
byteskip=byteskip, offset=offset, idarray=idarray, ensemble=n_ens)
datatype() variable names: 'velocity', 'correlation', 'echo',
'percent good', 'status'.
Data shapes:
fixedleader()→(36, n_ensembles)variableleader()→(48, n_ensembles)datatype()→(beams, cells, n_ensembles)
Velocity is in mm/s with −32768 as the missing value sentinel. All other functions return raw integer counts.
Error Handling
Every function returns an error code as the last element of its return tuple.
data, n_ens, err = pd0_parser.fixedleader('deployment.000')
if err != 0:
print(pd0_parser.ErrorCode.get_message(err))
Code |
Name |
Description |
|---|---|---|
0 |
|
Completed successfully |
1 |
|
File does not exist |
2 |
|
Access denied |
3 |
|
File open or read failed |
4 |
|
Insufficient memory |
5 |
|
Not a valid RDI PD0 file |
6 |
|
Data type ID not found in ensemble |
7 |
|
Inconsistent data types across ensembles |
8 |
|
Invalid structure or truncated data |
9 |
|
Invalid argument |
10 |
|
Ensemble checksum failed |
99 |
|
Unexpected error |
If a file is truncated mid-ensemble, all successfully parsed ensembles up
to the point of corruption are returned along with CHECKSUM_ERROR.
See Also
binary_reader — High-level reader returning
xarray.Datasetaccessors — Domain-specific methods on the Dataset