Skip to main content

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 an xarray.Dataset with record and second dimensions.
  • numpy: returns a dict[str, numpy.ndarray].
  • table: returns long-format trace rows as list[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

  • .dat files
  • .gz files 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dmsp_ssm-1.0.1.tar.gz (35.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dmsp_ssm-1.0.1-py3-none-any.whl (53.8 kB view details)

Uploaded Python 3

File details

Details for the file dmsp_ssm-1.0.1.tar.gz.

File metadata

  • Download URL: dmsp_ssm-1.0.1.tar.gz
  • Upload date:
  • Size: 35.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for dmsp_ssm-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1bb7126e64ca92bd80ac679bbf2953e935f554db0fa080699779d92e45a9b2ca
MD5 a5ecccddfcd9e02d96c0ce56b26df5e2
BLAKE2b-256 15ad7f91815e5151cdb6ba4f983be1e08be7e1b5d5456b47c06997032e0ec000

See more details on using hashes here.

File details

Details for the file dmsp_ssm-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: dmsp_ssm-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 53.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for dmsp_ssm-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9b378f7a79616320e4da07f50e035bcceb8d4e57f28f3169e84ed3498c26c244
MD5 8e6780248fc8e2538c98c455e0d4bb4e
BLAKE2b-256 8dfbb65b6527d994445a90c2fdec2913ff389a26cb78b5486c26ba034a8d516c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page