Skip to main content

pymetkit

Static Badge

[!IMPORTANT] This software is Emerging and subject to ECMWF's guidelines on Software Maturity.

pymetkit is a Python interface to metkit, ECMWF's meteorological toolkit. It exposes the MARS request model in a Pythonic way.

The native libmetkit shared library and its dependencies are located at runtime via findlibs.

Usage

from pymetkit import MarsRequest, parse_mars_request

# Build a request from a verb and a selection
request = MarsRequest(
    "retrieve",
    {
        "class": "od",
        "domain": "g",
        "date": "-1",
        "expver": "0001",
        "step": range(0, 13, 6),
    },
)

# Expand against the MARS language definition
expanded = request.expand()
print(expanded.verb(), dict(expanded))

# Parse requests from a string or a file
requests = parse_mars_request("retrieve,class=od,date=-1,param=129,step=12")

ParamDB — parameter database

ParamDB maps between ECMWF short names, long names and numeric parameter IDs, backed by a bundled parameter_metadata.json or, in mode="online", the ECMWF parameter API.

from pymetkit import ParamDB, AmbiguousParamError

db = ParamDB()                       # mode="offline" by default; data loads lazily

db.shortname_to_param_id("msl")      # 151  — unambiguous
db.param_id_to_shortname(151)        # "msl"
db.shortname_to_longname("2t")       # "2 metre temperature"
db.get_units(167)                    # "K"

Ambiguous short names

Some short names map to more than one parameter ID (e.g. tp228 and 228228). ParamDB never guesses — an ambiguous lookup raises by default:

try:
    db.shortname_to_param_id("tp")
except AmbiguousParamError as exc:
    print(exc.shortname)             # "tp"
    for cand in exc.candidates:      # every ParamIDCandidate, sorted
        print(cand.param_id, cand.table)

You can resolve the ambiguity in three ways:

# 1. Narrow with a MARS context (resolved via the C++ expand engine)
db.shortname_to_param_id("tp", context={"class": "od"})   # 228

# 2. Narrow with hard metadata filters (no MARS request constructed)
db.shortname_to_param_id("tp", table=128)                 # 228

# 3. Accept the canonical (first-sorted, lowest-table/id) candidate
db.shortname_to_param_id("tp", default=True)              # 228

To inspect the options programmatically instead of catching the error, use shortname_to_param_id_candidates, which returns a list of ParamIDCandidate (param_id, table, origin, access, mars_request_context):

for cand in db.shortname_to_param_id_candidates("tp"):
    if cand.hard_filter_selector is not None:
        # A hard-filter selector proven to select exactly this candidate.
        print(cand.param_id, cand.hard_filter_selector)
    else:
        # No hard filter uniquely identifies this candidate (e.g. two ids
        # share the same table, origin and access); use context= instead.
        print(cand.param_id, "no unique hard-filter selector")

Note: hard_filter_selector is either a dict of table/origin/access kwargs proven to select exactly one candidate, or None when no combination of the available hard filters disambiguates it. The API never advertises a selector that would remain ambiguous.

Note: Per-candidate MARS context computation is temporarily deferred, so every returned or raised ParamIDCandidate currently carries mars_request_context=None. Passing context= to narrow a lookup still works; only the advertised selecting context is unavailable for now. The context= path is resolved by the compiled MetKit expand engine, which is always available (pymetkit imports the native pymetkit._internal extension unconditionally).

Command line

python -m pymetkit --print-home        # metkit library home
python -m pymetkit --print-home-deps   # all dependency homes and versions

Technical details

Regenerating bundled parameter metadata

The bundled share/metkit/parameter_metadata.json (and .yaml) are generated by fetching from the ECMWF parameter database API. Run the generator script when the upstream database changes:

python -m pymetkit.paramdb.generate_metadata

This requires network access and the requests and pyyaml packages. It writes the following files relative to the repository root:

File Description
share/metkit/parameter_metadata.json Compact JSON — preferred at runtime (~10-50× faster to load than YAML)
share/metkit/parameter_metadata.yaml Human-readable YAML — fallback if JSON is absent
share/metkit/unit_metadata.yaml Unit definitions
share/metkit/parameter_entry_schema.json JSON Schema for ParameterEntry validation
share/metkit/mars_context_schema.json JSON Schema for MarsRequestContext validation

Commit the updated files to keep the bundled metadata in sync with the upstream database.

Documentation

For implementation details and tooling, see the Metkit project pages.

To build the latest documentation locally, follow the guide at Metkit.

License

License

Release files for pymetkit 1.21.0.30

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 pymetkit 1.21.0.30
File
pymetkit-1.21.0.30-cp314-cp314-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64 Details
pymetkit-1.21.0.30-cp314-cp314-manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ ARM64 Details
pymetkit-1.21.0.30-cp314-cp314-macosx_15_0_x86_64.whl CPython 3.14 CPython 3.14 macOS 15.0+ x86-64 Details
pymetkit-1.21.0.30-cp314-cp314-macosx_15_0_arm64.whl CPython 3.14 CPython 3.14 macOS 15.0+ ARM64 Details
pymetkit-1.21.0.30-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details
pymetkit-1.21.0.30-cp313-cp313-manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ ARM64 Details
pymetkit-1.21.0.30-cp313-cp313-macosx_15_0_x86_64.whl CPython 3.13 CPython 3.13 macOS 15.0+ x86-64 Details
pymetkit-1.21.0.30-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details
pymetkit-1.21.0.30-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
pymetkit-1.21.0.30-cp312-cp312-manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ ARM64 Details
pymetkit-1.21.0.30-cp312-cp312-macosx_15_0_x86_64.whl CPython 3.12 CPython 3.12 macOS 15.0+ x86-64 Details
pymetkit-1.21.0.30-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details
pymetkit-1.21.0.30-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
pymetkit-1.21.0.30-cp311-cp311-manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ ARM64 Details
pymetkit-1.21.0.30-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details

Total release size: 9.3 MB

Release files / pymetkit-1.21.0.30-cp314-cp314-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.0.30-cp314-cp314-manylinux_2_28_x86_64.whl
Size 613.0 kB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
4837571c93927eee02ee17db7abd1f5f63a7e7ebfafbb92b94a904c15b834785
BLAKE2b-256 checksum
How to use checksums
7499a720b87aa8463d03196696087b662b55c7e1fc088074419d95323821a5c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / pymetkit-1.21.0.30-cp314-cp314-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.30-cp314-cp314-manylinux_2_28_aarch64.whl
Size 610.5 kB
Tags CPython 3.14 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
28bb8c248acf3dc40b325c80a3643b2498b1866762eebeac68c211b0f9dad675
BLAKE2b-256 checksum
How to use checksums
b581a540154645f933e4e5c7373fcd8ad20ac34503a831d00fec8bd7842beb09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / pymetkit-1.21.0.30-cp314-cp314-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.0.30-cp314-cp314-macosx_15_0_x86_64.whl
Size 630.8 kB
Tags CPython 3.14 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
fa02f2c5745708eb44cb1ce6f6a43a6fd8d481b84d5d852663689003390358e1
BLAKE2b-256 checksum
How to use checksums
6057a548e4062c7da2c540c34e0fb32c67b6c610548d564338a88854ba388c57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0b3

Release files / pymetkit-1.21.0.30-cp314-cp314-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.0.30-cp314-cp314-macosx_15_0_arm64.whl
Size 622.3 kB
Tags CPython 3.14 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
5b3348956274aedc3779249f80217a7964f8f1e8c4545a33bbb4c90aedd1ede8
BLAKE2b-256 checksum
How to use checksums
7dc53c98a56700fb3905e7768d46aee4b4d0ff8075214af8a200d18bfae8bc15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / pymetkit-1.21.0.30-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.0.30-cp313-cp313-manylinux_2_28_x86_64.whl
Size 613.0 kB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d5c0af53994c3ecc860592fc9dee93afbfd274803c299eb87e392a8e1ccac42a
BLAKE2b-256 checksum
How to use checksums
26220434c9ae030400bad6dea6a29ff5e0196f99812f0af2c207c1c2f04a76b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / pymetkit-1.21.0.30-cp313-cp313-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.30-cp313-cp313-manylinux_2_28_aarch64.whl
Size 610.5 kB
Tags CPython 3.13 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
9bdca43732bb198c13597f2772a81cb33bf92ebe4c3c33c9f6dca71606bb3359
BLAKE2b-256 checksum
How to use checksums
70fb3d4701c65f791597bad2bb05876cbf36d5e2f10a3a0003608b3b239f8f15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / pymetkit-1.21.0.30-cp313-cp313-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.0.30-cp313-cp313-macosx_15_0_x86_64.whl
Size 629.0 kB
Tags CPython 3.13 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
09ddde2b581e85e2cc376b09d9242bf98f086cd063ca8a3c26d86f2ccbeaedbc
BLAKE2b-256 checksum
How to use checksums
7d4e0815ff4a92d7a887870cd6c58929e0da0277d087dee333ea7ac894ac8602
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / pymetkit-1.21.0.30-cp313-cp313-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.0.30-cp313-cp313-macosx_15_0_arm64.whl
Size 620.1 kB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
38a383625bb58918713e7af717f3b50ee912440ebce385303dd7408f0aa5fabe
BLAKE2b-256 checksum
How to use checksums
16b045d1733629f30ac6923345c0c48cda6c9f7934c6a6a6ebb8d1dd29ba3fab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / pymetkit-1.21.0.30-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.0.30-cp312-cp312-manylinux_2_28_x86_64.whl
Size 613.0 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7ac58a69794f3889301c8d53aad973f3047131f2f9441ad374f92f746815b22f
BLAKE2b-256 checksum
How to use checksums
df127345f01bd396aa62b2f2759ad911a4734f1a5694d81a2020f8e5006f32eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release files / pymetkit-1.21.0.30-cp312-cp312-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.30-cp312-cp312-manylinux_2_28_aarch64.whl
Size 610.3 kB
Tags CPython 3.12 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
6dcc9521f37e82108c9915cc6ca66184febc1aad9330e4fb1a8eac2a63614505
BLAKE2b-256 checksum
How to use checksums
bf3679386f71b715361f92b0ced0f99d80eef0e07f88bdbecd165f1a0656db06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release files / pymetkit-1.21.0.30-cp312-cp312-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.0.30-cp312-cp312-macosx_15_0_x86_64.whl
Size 628.9 kB
Tags CPython 3.12 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
76ebe73cd91e3d43c26e8c1d5e3687b997b124dc2f4730a27b956f460e2994c0
BLAKE2b-256 checksum
How to use checksums
729680072389a9c9028fe3db9d24f1c3f472428ca7e43af9620b9edfaec8242f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.9

Release files / pymetkit-1.21.0.30-cp312-cp312-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.0.30-cp312-cp312-macosx_15_0_arm64.whl
Size 620.0 kB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
5c2e5d3353b78a80d7e774ef60ecfcc2293968ef771fa68d082c0c8f9625d214
BLAKE2b-256 checksum
How to use checksums
aa24f7a2ee4e15d6f3dd516a8cbe44665e4aece3448f1ce2eaeeb603588b3e49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / pymetkit-1.21.0.30-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.0.30-cp311-cp311-manylinux_2_28_x86_64.whl
Size 612.3 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9ecb3c2bdc2adf2c84c022775d1837a1a9cd41837f3957437ee995fcb10c372e
BLAKE2b-256 checksum
How to use checksums
93f7584fbc97339a88b0fefe1e95490051e133230bbb90d4fc75a18c65222730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Release files / pymetkit-1.21.0.30-cp311-cp311-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.30-cp311-cp311-manylinux_2_28_aarch64.whl
Size 609.7 kB
Tags CPython 3.11 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
2bd7ffb6d80f920f9ffce7f7d491203d54d1345891e0b10c1b2516b5ab403d0b
BLAKE2b-256 checksum
How to use checksums
0d5609750f34fb0a3cf8781918b36961613895f579e6ea16e80d2b6c85ba4304
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.14

Release files / pymetkit-1.21.0.30-cp311-cp311-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.0.30-cp311-cp311-macosx_15_0_arm64.whl
Size 611.0 kB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
0884dba9ec2ad0906304466e7d0822da0709947013934b08660ad418d580639d
BLAKE2b-256 checksum
How to use checksums
dfecaa70d8a86575477bba09661d8f54e218134b454f50256eab23d75fd8ed16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release history Release notifications | RSS feed

This release

1.21.0.30 This release

15 release files

1.14.3

2 release files

1.14.2

2 release files

1.14.1

2 release files

1.14.0

2 release files

1.13.3

2 release files

1.13.1

2 release files

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