Python library for parsing DMSP SSM binary files.
Project description
dmsp-ssm
dmsp-ssm is a Python library for reading, validating, and converting DMSP SSM binary data files.
The package accepts single .dat files, gzip-compressed .gz files, and directories of supported files. It returns a ParseResult with parsed records and a validation report. The default output is an xarray.Dataset.
Installation
pip install dmsp-ssm
For local development:
pip install -e .[dev]
Quick Start
from dmsp_ssm import Reader
reader = Reader()
result = reader.parse("path/to/file_or_directory")
dataset = result.records
report = result.report
print(dataset)
print(report.summary)
Output Profiles
Select an output profile with ParseOptions:
from dmsp_ssm import ParseOptions, Reader
reader = Reader()
result = reader.parse(
"path/to/data",
options=ParseOptions(output_profile="xarray"),
)
Supported profiles:
xarray: returns anxarray.Datasetwithrecordandseconddimensions.numpy: returns adict[str, numpy.ndarray].table: returns long-format trace rows aslist[dict[str, object]].
xarray Output
The default xarray profile contains:
- dimensions:
record,second - coordinates:
record_time,second_index - second-level variables:
time,bx,by,bz,valid - record-level variables:
flight_number,year,day_of_year,minute_start_sec_of_day,latitude_deg,longitude_deg,altitude_km
Data variables include units attributes when units are defined by the internal format definition.
Missing second-level measurements are detected by the time == -1000.0 marker. For those positions, time, bx, by, and bz are normalized to NaN, and valid is set to False.
Validation Report
ParseResult.report contains validation status, incidents, and summary counters:
result = Reader().parse("path/to/data")
print(result.report.status)
print(result.report.outcome)
print(result.report.summary)
To include compact missing-minute ranges:
result = Reader().parse(
"path/to/data",
include_missing_minute_ranges=True,
)
For directory inputs, the summary can also include per-file missing-minute diagnostics in missing_minute_ranges_by_file.
API Overview
Reader
Reader(
error_policy="resync",
pre_parse_size_warning_threshold_bytes=256 * 1024 * 1024,
)
Use Reader.parse(path, ...) to parse a file or directory.
ParseOptions
ParseOptions(
recursive=True,
error_policy=None,
include_missing_minute_ranges=False,
output_profile="xarray",
)
output_profile must be one of xarray, numpy, or table.
ParseResult
ParseResult.records contains the selected output artifact.
ParseResult.report contains validation diagnostics.
ParseResult.metadata and ParseResult.extensions are reserved for optional metadata.
Supported Input
.datfiles.gzfiles containing DMSP SSM binary data- directories containing only one supported file type
- recursive directory traversal when
recursive=True
Directories containing mixed .dat and .gz files are rejected.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dmsp_ssm-1.0.0.tar.gz.
File metadata
- Download URL: dmsp_ssm-1.0.0.tar.gz
- Upload date:
- Size: 34.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37f875d826d5a2b8e1796df41488db950e539bee4b91bb03d47a27cce0b412a8
|
|
| MD5 |
c37c02058aea8416fa9a62fa354c2da0
|
|
| BLAKE2b-256 |
9bc0b96d9e1b237ae360a9eea0a5c0dc12c7e3ed5e081bce23c819aa2eb5319d
|
File details
Details for the file dmsp_ssm-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dmsp_ssm-1.0.0-py3-none-any.whl
- Upload date:
- Size: 53.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9beae33f73309230f4fd70a9139bb6ebbbf6994a613d8ca5bdc9875bb63e2773
|
|
| MD5 |
9aadb9aba6203559e3023f5995e82e2a
|
|
| BLAKE2b-256 |
2a41f31a9815740d30828426304d6c6c05273d9ac621eb9136cc4a17efba5a15
|