GRM Parser¶
pynasonde.digisonde.parsers.grm
¶
GRM archive splitter for Digisonde batch files from GIRO DIDBase.
GRM files are raw concatenations of 4096-byte ionogram blocks downloaded
from GIRO DIDBase. Each ionogram type is identified by block[0]
(the record-type byte):
RSF → 7 SBF → 3 MMM → 9
This module exposes :class:GrmSplitter, which can:
- auto-detect the ionogram format from the file itself
- split the archive to individual files on disk (parallel-safe)
- load each ionogram as a lazily-constructed parser object
- load_dataframes – extract all ionograms and return a flat DataFrame (parallel-safe)
Parallelism strategy¶
All three methods use a two-phase design:
_scan_offsets()— sequential linear scan that records only(datetime, byte_offset, byte_length)per ionogram. No ionogram data is copied.-
Worker functions — parallel, each opens the file independently and
seek()-s to its own slice, so no large bytes objects are pickled across process/thread boundaries. -
split()→ I/O-bound → :class:ThreadPoolExecutor load_dataframes()→ CPU-bound → :class:ProcessPoolExecutorload()→ creates lazy wrappers, stays sequential
Usage::
spl = GrmSplitter("AU930_20171470000.GRM")
print(spl.fmt) # "MMM"
paths = spl.split("/tmp/out/") # sequential
paths = spl.split("/tmp/out/", n_workers=4) # parallel (threads)
df = spl.load_dataframes() # sequential
df = spl.load_dataframes(n_workers=4) # parallel (processes)
objs = spl.load() # list[_LazyExtractor]
objs[0].extract(); objs[0].to_pandas()
GrmSplitter
¶
Split or load a GRM batch archive from GIRO DIDBase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
Union[str, Path]
|
Path to the |
required |
fmt |
Optional[str]
|
Force a specific format ( |
None
|
station |
Optional[str]
|
Five-character station code used in output filenames. Defaults to the first five characters of the filename. |
None
|
Source code in pynasonde/digisonde/parsers/grm.py
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 342 343 344 345 346 347 348 349 350 351 | |
fmt: str
property
¶
Detected or user-specified ionogram format.
__init__(path, fmt=None, station=None)
¶
Create a GRM archive splitter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
Union[str, Path]
|
Path to the |
required |
fmt |
Optional[str]
|
Optional forced format, one of |
None
|
station |
Optional[str]
|
Station code used when writing split files. |
None
|
Source code in pynasonde/digisonde/parsers/grm.py
detect_format(path)
staticmethod
¶
Scan the first matching block and return the format string.
Raises:
| Type | Description |
|---|---|
ValueError
|
if no known record-type byte is found. |
Source code in pynasonde/digisonde/parsers/grm.py
split(out_dir, n_workers=1)
¶
Write each ionogram to a separate file in out_dir.
Files are named <station>_<YYYYDDDHHMMSS>.<fmt>.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_dir |
Union[str, Path]
|
Output directory (created if it does not exist). |
required |
n_workers |
int
|
Number of threads for parallel file writes.
|
1
|
Returns:
| Type | Description |
|---|---|
List[Path]
|
List of :class: |
List[Path]
|
in ionogram order. |
Source code in pynasonde/digisonde/parsers/grm.py
load()
¶
Return lazy extractor wrappers — one per ionogram.
Each object is cheap to construct. Call .extract() and
.to_pandas() to materialise the data. Loading is always
sequential since the wrappers themselves hold no data.
Returns:
| Type | Description |
|---|---|
List[_LazyExtractor]
|
Ordered list of :class: |
Source code in pynasonde/digisonde/parsers/grm.py
load_dataframes(n_workers=1)
¶
Extract all ionograms and return a single concatenated DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_workers |
int
|
Number of processes for parallel extraction.
|
1
|
Returns:
| Name | Type | Description |
|---|---|---|
Combined |
pd.DataFrame
|
class: |