Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.1.dev12

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

Total release size: 9.9 MB

Release files / pymetkit-1.21.1.dev12-cp314-cp314-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.1.dev12-cp314-cp314-manylinux_2_28_x86_64.whl
Size 613.1 kB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ac3cbed20723c51bcb2d04e626133dde1ed9bf46359a37393eeddcb83e056f70
BLAKE2b-256 checksum
How to use checksums
1d311304f6506f735ccc8d5e94b5a461bba40e029a2e6dc0f898a588cbde7d8a
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.1.dev12-cp314-cp314-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.1.dev12-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
9383157d43adf96be00d7397c8032a404977d2521088eadd796747897cb24863
BLAKE2b-256 checksum
How to use checksums
7759cfc03b4e9025d1c3cfca650eb71cf130301f8bcede6accc1abf539035aca
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.1.dev12-cp314-cp314-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.1.dev12-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
b0e807d911b738377e61e9a0b7700d51fef98805b19ddd3988d9e935c2a31403
BLAKE2b-256 checksum
How to use checksums
b302b27153d844c81d970e7c402b220b182ff13263e59cb5e1d25a8cbfae55ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.14.0b3

Release files / pymetkit-1.21.1.dev12-cp314-cp314-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.1.dev12-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
d78299a85a4d635f3b2396dc48b5cb94f690cace1c1fb1b142368f43f9035ddf
BLAKE2b-256 checksum
How to use checksums
b9eb2d73a63a582e6dc86f56a628d24e63794da61474974e858d35b4e87251bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.14.7

Release files / pymetkit-1.21.1.dev12-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.1.dev12-cp313-cp313-manylinux_2_28_x86_64.whl
Size 613.1 kB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
068c34e594c84734929219b533d9df62b524b859f51948f2870caff2147d98eb
BLAKE2b-256 checksum
How to use checksums
f515921817c4f6d8b6dca32e7ccf2d1895e56054082088a770e58c152038283e
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.1.dev12-cp313-cp313-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.1.dev12-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
2884c4c5a1f6856414f4508251889bdeac30f78258e91ded6f9fbd515507662f
BLAKE2b-256 checksum
How to use checksums
ff5bff7d0dd355e772051f94a619463cd4e40fc949c92f951a843589de7cf7bc
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.1.dev12-cp313-cp313-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.1.dev12-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
2946cfb951796f3999b469de3eea27fc9b7ef09ab4df9cbc0b8b087fe1fb8715
BLAKE2b-256 checksum
How to use checksums
754ec670238fbfd4b7e597e8c60207f152bc040f08bdc0e4a332b24c5bb837c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.2

Release files / pymetkit-1.21.1.dev12-cp313-cp313-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.1.dev12-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
bdb179e6e8644ab98e8d0d6dd24c30deeabe68b255cbc846adf9151163e7fa50
BLAKE2b-256 checksum
How to use checksums
12d39511968a650a0e864f6025480529fdc96552492f9ce40bd02362fb7aaed1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.15

Release files / pymetkit-1.21.1.dev12-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.1.dev12-cp312-cp312-manylinux_2_28_x86_64.whl
Size 613.1 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
94de831a481976a1dff35f1ff60588b17ce469828b820c4e3b9fb929728e0eac
BLAKE2b-256 checksum
How to use checksums
16aae07d5f8a272f0a731c1885c7c04697303755e96ef4c8400475242c706142
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.1.dev12-cp312-cp312-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.1.dev12-cp312-cp312-manylinux_2_28_aarch64.whl
Size 610.4 kB
Tags CPython 3.12 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
f953555590702b96c947ef9f0e2fa1970d0544765a42679b28c8267fb3a16ac9
BLAKE2b-256 checksum
How to use checksums
6994bfc6d9de41333e9b80788a26a3ae4a849cbe90feebfba1244ba04f563fdd
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.1.dev12-cp312-cp312-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.1.dev12-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
40a6cb403718e9a322a06b8ee0dd8de6153b7062e51b5962e6a3be4ec6d026b5
BLAKE2b-256 checksum
How to use checksums
b87fbfc5f8129a8d03cce61799557412a102057d132136bbb193b988d5291e7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.9

Release files / pymetkit-1.21.1.dev12-cp312-cp312-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.1.dev12-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
318a91edf569198629492c47ce8788eb02cdbcf58f5f7db27a26c8a48d75ee1d
BLAKE2b-256 checksum
How to use checksums
34279d741fae2df833f026ece657c17b3e84bea413f0c1e2fd2d2eddccf6fc4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / pymetkit-1.21.1.dev12-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.1.dev12-cp311-cp311-manylinux_2_28_x86_64.whl
Size 612.4 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
edc164252090846fec1978f254ad3f9e4b9be0924903c39198d0c63a3a5f5cf6
BLAKE2b-256 checksum
How to use checksums
ae4b71f0ad8730878f01d130c49cbd84e2d30a6f74b292554a2f575ec674f928
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.1.dev12-cp311-cp311-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.1.dev12-cp311-cp311-manylinux_2_28_aarch64.whl
Size 609.8 kB
Tags CPython 3.11 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
f8eed3e8a9e0a2d7c190df6b03468604779d9979a8bde4e0aa8c9c61a0d1d511
BLAKE2b-256 checksum
How to use checksums
d1513f0d28df1173541bcbf00e4d55a6da6bb64caa47e3d628a28a1c649b3b1c
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.1.dev12-cp311-cp311-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.1.dev12-cp311-cp311-macosx_15_0_x86_64.whl
Size 618.2 kB
Tags CPython 3.11 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
c1b3f84b55742ed61a0a92ff5ae678d5b0cc63355a40112d3fe7c21fe65e2399
BLAKE2b-256 checksum
How to use checksums
120703ab09d9e2f1338986f8aa1973d97c9e676a13a0b8eedcb99a1b3e216817
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.11

Release files / pymetkit-1.21.1.dev12-cp311-cp311-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.1.dev12-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
ecdcd0148a1d39e92b0de652deeedc0125e1bdb02fd5c9c8701045e766499594
BLAKE2b-256 checksum
How to use checksums
4f3aaf96f09d573d489fb388c636ae21d31631ad379cfe986168c337187f471d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.16

Release history Release notifications | RSS feed

This release

1.21.1.dev12 This release

16 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