Skip to main content

Python Bindings for Open Meteo File Format

Python 3.10 | 3.11 | 3.12 | 3.13 | 3.14 PyPI version Build and Test

Features

  • Read Open-Meteo (.om) files directly from cloud storage using Python
  • Traverse the hierarchical data structure
  • Arrays/array slices are returned directly as NumPy arrays
  • Support for fsspec and xarray
  • Chunked data access behind the scenes

Installation

pip install omfiles

Pre-Built Wheels & Platform Support

We provide pre-built wheels for the following platforms:

  • Linux x86_64 (manylinux_2_28_x86_64)
  • Linux aarch64 (manylinux_2_28_aarch64)
  • Linux musl x86_64 (musllinux_1_2_x86_64)
  • Windows x86_64 (win_amd64)
  • Windows ARM64 (win_arm64)
  • macOS x86_64 (macosx_10_12_x86_64)
  • macOS ARM64 (macosx_11_0_arm64)

Reading

Reading Files without Hierarchy

OM files are structured like a tree of variables. The following example assumes that the file test_file.om contains an array variable as a root variable which has a dimensionality greater than 2 and a size of at least 2x100:

from omfiles import OmFileReader

reader = OmFileReader("test_file.om")
data = reader[0:2, 0:100, ...]
reader.close() # Close the reader to release resources

Reading Hierarchical Files, e.g. S3 Spatial Files

import datetime as dt

import fsspec
import numpy as np
from omfiles import OmFileReader

# Example: URI for a spatial data file in the `data_spatial` S3 bucket
# See data organization details: https://github.com/open-meteo/open-data?tab=readme-ov-file#data-organization
MODEL_DOMAIN = "dwd_icon"
# Note: Spatial data is only retained for 7 days. The script uses one file within this period.
date_time = dt.datetime.now(dt.timezone.utc) - dt.timedelta(days=2)
S3_URI = (
    f"s3://openmeteo/data_spatial/{MODEL_DOMAIN}/{date_time.year}/"
    f"{date_time.month:02}/{date_time.day:02}/0000Z/"
    f"{date_time.strftime('%Y-%m-%d')}T0000.om"
)
print(f"Using om file: {S3_URI}")

# Create and open filesystem, wrapping it in a blockcache
backend = fsspec.open(
    f"blockcache::{S3_URI}",
    mode="rb",
    s3={"anon": True, "default_block_size": 65536},  # s3 settings
    blockcache={"cache_storage": "cache"},  # blockcache settings
)
# Create reader from the fsspec file object using a context manager.
# This will automatically close the file when the block is exited.
with OmFileReader(backend) as root:
    # We are at the root of the data hierarchy!
    # What type of node is this?
    print(f"root.is_array: {root.is_array}")  # False
    print(f"root.is_scalar: {root.is_scalar}")  # False
    print(f"root.is_group: {root.is_group}")  # True

    temperature_reader = root.get_child_by_name("temperature_2m")
    print(f"temperature_reader.is_array: {temperature_reader.is_array}")  # True
    print(f"temperature_reader.is_scalar: {temperature_reader.is_scalar}")  # False
    print(f"temperature_reader.is_group: {temperature_reader.is_group}")  # False

    # What shape does the stored array have?
    print(f"temperature_reader.shape: {temperature_reader.shape}")  # (1441, 2879)

    # Read all data from the array
    temperature_data = temperature_reader.read_array((...))
    print(f"temperature_data.shape: {temperature_data.shape}")  # (1441, 2879)

    # It's also possible to read any subset of the array
    temperature_data_subset1 = temperature_reader.read_array((slice(0, 10), slice(0, 10)))
    print(temperature_data_subset1)
    print(f"temperature_data_subset1.shape: {temperature_data_subset1.shape}")  # (10, 10)

    # Numpy basic indexing is supported for direct access if the reader is an array.
    temperature_data_subset2 = temperature_reader[0:10, 0:10]
    print(temperature_data_subset2)
    print(f"temperature_data_subset2.shape: {temperature_data_subset2.shape}")  # (10, 10)

    # Compare the two temperature subsets and verify that they are the same
    are_equal = np.array_equal(temperature_data_subset1, temperature_data_subset2, equal_nan=True)
    print(f"Are the two temperature subsets equal? {are_equal}")

Writing

Single Array

import numpy as np
from omfiles import OmFileWriter

# Create sample data
data = np.random.rand(100, 100).astype(np.float32)

# Initialize writer
writer = OmFileWriter("simple.om")

# Write array with compression
array_variable = writer.write_array(
    data,
    chunks=[50, 50],
    scale_factor=1.0,
    add_offset=0.0,
    compression="pfor_delta_2d",
    name="data"
)

# Finalize the file using array_variable as entry-point
writer.close(array_variable)

Hierarchical Structure

import numpy as np
from omfiles import OmFileWriter

# Create sample data
features = np.random.rand(1000, 64).astype(np.float32)
labels = np.random.randint(0, 10, size=(1000,), dtype=np.int32)

# Initialize writer
writer = OmFileWriter("hierarchical.om")

# Write child arrays first
features_var = writer.write_array(features, chunks=[100, 64], name="features", compression="pfor_delta_2d")
labels_var = writer.write_array(labels, chunks=[100], name="labels")
metadata_var = writer.write_scalar(42, name="metadata")

# Create root group with children
root_var = writer.write_group(
    name="root",
    children=[features_var, labels_var, metadata_var],
)
# Finalize the file using root_var as entry-point into the hierarchy
writer.close(root_var)

Examples

There are some examples how to use this library in examples/. They should be run as uv scripts to automatically setup the correct python environment.

uv run examples/plot_map.py

Development

# install the required dependencies in .venv directory
uv sync
# to run the tests
uv run pytest tests/
# to build the wheels
uv run build
# or to trigger maturin directly:
# maturin develop

Tests

cargo test

runs rust tests.

uv run pytest tests/

runs Python tests.

Python Type Stubs

Can be generated from the rust doc comments via

cargo run stub_gen

Metadata

Release files for thk2b-omfiles 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for thk2b-omfiles 1.1.0
File Actions
thk2b_omfiles-1.1.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for thk2b_omfiles-1.1.0-cp310-abi3-win_arm64.whl
thk2b_omfiles-1.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for thk2b_omfiles-1.1.0-cp310-abi3-win_amd64.whl
thk2b_omfiles-1.1.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for thk2b_omfiles-1.1.0-cp310-abi3-musllinux_1_2_x86_64.whl
thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_34_x86_64.whl CPython 3.10 abi3 Linux glibc 2.34+ x86-64 Details for thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_34_x86_64.whl
thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_28_aarch64.whl
thk2b_omfiles-1.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for thk2b_omfiles-1.1.0-cp310-abi3-macosx_11_0_arm64.whl
thk2b_omfiles-1.1.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for thk2b_omfiles-1.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 20.7 MB

Release files / thk2b_omfiles-1.1.0-cp310-abi3-win_arm64.whl

Download URL thk2b_omfiles-1.1.0-cp310-abi3-win_arm64.whl
Size 999.5 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
b1b6601dc6123208ca75c199e97ed7b5eeaf39417616f342911160812662904a
BLAKE2b-256 checksum
How to use checksums
bfd083ec9513274a04a38c726427769ae49bc6462a9570a187b145a2c3227b05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / thk2b_omfiles-1.1.0-cp310-abi3-win_amd64.whl

Download URL thk2b_omfiles-1.1.0-cp310-abi3-win_amd64.whl
Size 820.1 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
270909bfaf8584d4ceee5802efbc7ac872fb8edcb2bc15de1edf1395e1b8d34a
BLAKE2b-256 checksum
How to use checksums
660a2dad7de2c1b79ac30be55f4871736ef6d4edee09c05598a5e3411514d5b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / thk2b_omfiles-1.1.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL thk2b_omfiles-1.1.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 1.2 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
aa1f16ddfe3abcd7bddde4d90abdf5d1a7f73a014421fc9473baedc960a0d1cc
BLAKE2b-256 checksum
How to use checksums
5dd79a39b37762b3bf0364908ce3e7957cc0bb19a1a572e21a3ad96bf248cd7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_34_x86_64.whl

Download URL thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_34_x86_64.whl
Size 13.5 MB
Tags CPython 3.10 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
4305426f7a74b809d65bb9964ca0e43f3b85489f142ba18a585ef9fafce4d1c9
BLAKE2b-256 checksum
How to use checksums
66cf562ba7901188a0c7ff7e13e67416edb18a4d8604c53e44d4fa71967e720d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
Size 1.0 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
cd2ea4f5f935eaa1e7876f7823efcd84821a2e08264e562a23bf3d8406583115
BLAKE2b-256 checksum
How to use checksums
6827eefd7c2698360df49fff9f49a485f01782354e9eee1dab1124aed3e65a75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL thk2b_omfiles-1.1.0-cp310-abi3-manylinux_2_28_aarch64.whl
Size 1.2 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
78a08338412a6372b3a5b8518b89aa6443f03c96d324b4c48fc7113c9bef80a4
BLAKE2b-256 checksum
How to use checksums
166b4643c8bffbedb11c283416ff7a9e7e7bfd393e2dfb91548c646788425b08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / thk2b_omfiles-1.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL thk2b_omfiles-1.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 974.0 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3d2f407602d9d94a7b7e4991cc7444a2309d710fc37a07717fc819fb1f97feea
BLAKE2b-256 checksum
How to use checksums
aeb9493cb18e622a54c8b1e08c6edeb75c6b4ccbcbf079259f34638074ef71a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Release files / thk2b_omfiles-1.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL thk2b_omfiles-1.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 991.0 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
977171187d6c2864339825278fe356f03937822071c9474b797d3590383190f4
BLAKE2b-256 checksum
How to use checksums
7b8f558fd8c37be326c40e908154158bf6f831bf25eb995376b16a7d89e2e932
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.12.6

Security for thk2b-omfiles 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

8 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page