DFT parser¶
C
pynasonde.digisonde.parsers.dft — DftExtractor
Parses DFT-format digisonde outputs.
pynasonde.digisonde.parsers.dft
¶
DFT parser utilities for Digisonde DFT-format files.
This module provides :class:DftExtractor, a compact reader that
unpacks Digisonde DFT binary blocks into the lightweight dataclasses
defined in :mod:pynasonde.digisonde.datatypes.dftdatatypes.
The implementation focuses on bit-level unpacking and construction of
DftHeader, DopplerSpectra and DopplerSpectralBlock objects
so the parsed records can be consumed by higher-level tooling or used
directly in documentation examples.
DftExtractor
¶
Bases: object
Low-level reader for DFT-format files.
This class provides a minimal API to read a DFT-format file and produce block-level containers. It intentionally avoids complex dependence on external libraries beyond numpy so it can be used in lightweight docs and tests.
Source code in pynasonde/digisonde/parsers/dft.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
__init__(filename, extract_time_from_name=False, extract_stn_from_name=False, DATA_BLOCK_SIZE=4096, SUB_CASE_NUMBER=16)
¶
Create a DftExtractor instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename |
str
|
str Path to the DFT-format file to read. |
required |
extract_time_from_name |
bool
|
bool, optional If True, attempt to parse a timestamp from the filename. |
False
|
extract_stn_from_name |
bool
|
bool, optional If True, attempt to parse a station code from the filename. |
False
|
DATA_BLOCK_SIZE |
int
|
int, optional Block size in bytes used by the DFT format. |
4096
|
SUB_CASE_NUMBER |
int
|
int, optional Number of sub-cases per block. |
16
|
Source code in pynasonde/digisonde/parsers/dft.py
extract()
¶
Read the DFT file and construct DopplerSpectralBlock objects.
Iterates over all blocks in the file and stores each parsed
:class:DopplerSpectralBlock in :attr:blocks. Each block holds a
:class:DftHeader (decoded from LSBs of the amplitude bytes) and a
list of 16 :class:DopplerSpectra objects — one per sub-case (height
bin). Call :meth:to_pandas after extract() to obtain a flat
DataFrame suitable for plotting.
Populates :attr:blocks (list of :class:DopplerSpectralBlock).
Source code in pynasonde/digisonde/parsers/dft.py
to_pandas()
¶
Flatten all parsed DFT blocks into a tidy DataFrame.
Each row corresponds to one (block, sub-case, Doppler-bin) triplet.
Heights are estimated from the block header fields
(bottom_height, height_resolution) using typical DPS4D unit
conventions (5 km per raw height-resolution unit, 80 km baseline).
The Doppler axis is expressed as a signed bin offset centred at bin 64, so negative values correspond to downward (approaching) motion and positive values to upward (receding) motion.
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
Source code in pynasonde/digisonde/parsers/dft.py
extract_header_from_amplitudes(amplitude_bytes)
¶
Decode header bits embedded in the amplitude LSBs.
The DFT format stores header bits spread across the least
significant bits of amplitude bytes. This routine reconstructs
the bitstring and converts the bit fields into a
:class:DftHeader dataclass instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
amplitude_bytes |
list
|
list
Sequence of 1-byte objects (as returned by |
required |
Returns:
| Type | Description |
|---|---|
DftHeader
|
Populated header dataclass with parsed integer and raw |
DftHeader
|
(hex) fields where applicable. |
Source code in pynasonde/digisonde/parsers/dft.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
to_int(bin_strs, base=2)
¶
Convert a binary string fragment to an integer.
The helper pads the provided bit string to at least 8 bits and converts it to an integer using the provided base.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bin_strs |
str
|
str Bitstring fragment (e.g. '1010'). |
required |
base |
int
|
int, optional Numeric base to use for conversion (default 2). |
2
|
Returns:
| Type | Description |
|---|---|
int
|
Integer representation. |
Source code in pynasonde/digisonde/parsers/dft.py
unpack_7_1(bcd_byte, return_lsb=True)
¶
Unpack a 1-byte packed BCD into 7-bit MSB and 1-bit LSB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bcd_byte |
int
|
int The raw byte value (0-255). |
required |
return_lsb |
bool
|
bool, optional If True return the least-significant-bit, otherwise return the seven most-significant bits. |
True
|
Returns:
| Type | Description |
|---|---|
int
|
Either the LSB (0/1) or the 7-bit MSB integer. |