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. tp → 228 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

Metadata

Release files for pymetkit 1.22.0.32

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

Download URL pymetkit-1.22.0.32-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
9be828ecfa00269e0ceed11a9d03bb400cc258683a78fa315e1dc3fad16fae4d
BLAKE2b-256 checksum
How to use checksums
4f5deb2183e3913642520043e7680f69399b8e047175c6ec63a7942ce4423f15
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.22.0.32-cp314-cp314-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.32-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
c3d1bc90420576bd20890b2bc4a553c9d58c64bd108d77952c8cfe87ca01d455
BLAKE2b-256 checksum
How to use checksums
3fcc1e3daa12539774ac53ae2bf11b28f1eacae400548dcbbba1c93a126d38fe
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.22.0.32-cp314-cp314-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.32-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
ccc569d718fbef9ee5e12e79f4788295a39c96c305ea215fbba4ee2ae7a81834
BLAKE2b-256 checksum
How to use checksums
1dabf8f072f26ddffb90046abcae35011d6b5a099ef19ae8a27aa3619a39ca63
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.22.0.32-cp314-cp314-macosx_15_0_arm64.whl

Download URL pymetkit-1.22.0.32-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
863c6ea730ea9bfd1e6b7d62b0efff920e1c928c0a0ffb4c6b5abaa4a503c13a
BLAKE2b-256 checksum
How to use checksums
a7555c5e50bd4cc1e1acc64590c570df3e82d8788d57fec36cbad9da78a3e25d
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.22.0.32-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.22.0.32-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
bbd724492c7d4781ac2344cd8a187cd996f02b3bd731ca13cf7d51bb99b67397
BLAKE2b-256 checksum
How to use checksums
e3ab07df6d57e566cf1da6dba9acbc8d3b7d5cb712f455ebb64835a839911a5a
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.22.0.32-cp313-cp313-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.32-cp313-cp313-manylinux_2_28_aarch64.whl
Size 610.4 kB
Tags CPython 3.13 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
40c598da6ff3622607715316b898209003b6c0c09e09b181d7e149996c0503b6
BLAKE2b-256 checksum
How to use checksums
d0ef43ce369f3186ef905de719a1ede473fcfe459a9cfccd771bb22023271cc5
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.22.0.32-cp313-cp313-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.32-cp313-cp313-macosx_15_0_x86_64.whl
Size 628.9 kB
Tags CPython 3.13 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
3a214b582ef64d26f19a84ba4ec387ad22782b2202e71484e54d633e0b7cc8e6
BLAKE2b-256 checksum
How to use checksums
abf86194442790adb38a32e4a5e49d5c3bfdf1ab8ba92e207d4e21d18ccbc7ea
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.22.0.32-cp313-cp313-macosx_15_0_arm64.whl

Download URL pymetkit-1.22.0.32-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
e35e91d170316b343b71b9806398a499f1469c49f2899f7bda8c549ef6d7df25
BLAKE2b-256 checksum
How to use checksums
5c6bf448f8c198dd181467894ebc69afcc7fb4590c7761b15a498df56fcc9632
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.22.0.32-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.22.0.32-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
df03980a2fc8614eb53f32a27fdbee249de0f05d27b2b3432408ac5945d02b3a
BLAKE2b-256 checksum
How to use checksums
4e39a1599f50889455473f7f3bed12d0a020751c24313f5c7b6d3448409f1598
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.22.0.32-cp312-cp312-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.32-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
e3ca144a4584f9d84c014f8104321bfa57bca42700b86f4dac47ea1e9eed8ad2
BLAKE2b-256 checksum
How to use checksums
1ebc9f1cbbcebf9ebf23d65bb38e0a3dc34bd68c2c9452b61b73023e8ad4e909
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.22.0.32-cp312-cp312-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.32-cp312-cp312-macosx_15_0_x86_64.whl
Size 628.8 kB
Tags CPython 3.12 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
f89236486957976e8e74ad4a16242c973ee1f66d65c1b891a5ccba9735ef12e7
BLAKE2b-256 checksum
How to use checksums
b280acc69befca11385ac5a530674c997ca2825bd17c4a83b424a54a9e89ccb6
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.22.0.32-cp312-cp312-macosx_15_0_arm64.whl

Download URL pymetkit-1.22.0.32-cp312-cp312-macosx_15_0_arm64.whl
Size 620.1 kB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
3660f7582f253107f5da9365c96a5b6a2785d9344474d9842c79047aa9d6cfa3
BLAKE2b-256 checksum
How to use checksums
acc6d99864290905ed707a4d08a298fcc03efafaedb7636e98566582d476b9ed
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.22.0.32-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.22.0.32-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
1930068acfe901d338b881c9df9b21727c29a54d8ccabe992331d5232c7e3d81
BLAKE2b-256 checksum
How to use checksums
f46a8199846f23519b28ea3d48099393f3c2a2fae597fe39000a5ab1da64a804
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.22.0.32-cp311-cp311-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.32-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
24cb1649fe643cc3e4c8b5a3d238126ccea91d3d5cd2eb8322266941e72b8839
BLAKE2b-256 checksum
How to use checksums
b365e973b2c13c5c5c606dacf178619831c1d6ef9590de5f0bd3aa94194cd7ae
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.22.0.32-cp311-cp311-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.32-cp311-cp311-macosx_15_0_x86_64.whl
Size 618.1 kB
Tags CPython 3.11 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
d9dd6089ce9a0578ce5318a6913d1e2f7f852715c2b30cf60149712a7ee77bbd
BLAKE2b-256 checksum
How to use checksums
49254632fdfdf06b3e112101f66cf3b5d8157c4346fb5390cf0433fc79d5f7cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.11

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

Download URL pymetkit-1.22.0.32-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
e08592ca75b34c977fc4cd6720c99b70c786038d9d149037bb03412bc983f118
BLAKE2b-256 checksum
How to use checksums
113482b64c5aa66f2851efbb3cc2c8c433147653d53fbd380469ff20e91108a0
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.22.0.32 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