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.31

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

Download URL pymetkit-1.22.0.31-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
a3fa0c0652c7489b33c5214194d51614bdbbdd2693414bf555674e8cbd3027f0
BLAKE2b-256 checksum
How to use checksums
92b21e1d75dc320ca55fa0f41974ae17854be3954e1be5f19c4334416963b013
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.31-cp314-cp314-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.31-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
d9aa99d26c3fe4fc5b8e60a19503deefed7887eb094e5349fee82a0e576b789b
BLAKE2b-256 checksum
How to use checksums
92c104da20674a5d316325f0104dbfcb87821fe27f448d951ff5b33d0888d0f1
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.31-cp314-cp314-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.31-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
2feb2044b169882b9a74565d91e0ea2d3028b6fea4d76b1c1ef25009f45edac8
BLAKE2b-256 checksum
How to use checksums
977624cf687e83183a5dd2af6514ff472eef29105027d29d3a11de43f2289b89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

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

Download URL pymetkit-1.22.0.31-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
ffe0c77a2312ec36697442c6f46fa5e8e45207bf63ccf83e483f15536ad6e0cf
BLAKE2b-256 checksum
How to use checksums
1c80bfc0625d0a61220ebaa17e017cf0b6d2e7819fcbf23bd9ce43a3991228c3
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.31-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.22.0.31-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
c919cfb25086c9a4f70dde2f3e2351745ad7db63a2a252eca41ea8bee6f8c2de
BLAKE2b-256 checksum
How to use checksums
00ed3814bbac628d7d27ca364b3783bb12537435d569ac89ee30aa9154e06afb
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.31-cp313-cp313-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.31-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
3cab4209f49db9bd0dbc291bbba737def02904a112d93c8226babfbd1172f9a5
BLAKE2b-256 checksum
How to use checksums
4c945752cf0c0ee487364a385adf614caae3528e8a5653c8b9ae29ccccf40372
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.31-cp313-cp313-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.31-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
211314f8882b563d164aba54d9e0b24f7c93457d9575a252c5ac9f56f554fdb8
BLAKE2b-256 checksum
How to use checksums
1c12cc60295c5fd2f6b179bd723ee205b5abc4516a8fd7df33ba0c069a6e893b
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.31-cp313-cp313-macosx_15_0_arm64.whl

Download URL pymetkit-1.22.0.31-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
4f47152e7f8e2427a256caaadb24e82b2b60ac5e0a700f286283b543f33c6cca
BLAKE2b-256 checksum
How to use checksums
1f6f894f7eb09030fb6bb7b274c30bbb1f6ac2baf6687bf7df45eb30a52977f7
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.31-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.22.0.31-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
f917266b68ec428a854076d493766e34436031300ab41a59897db4702766a176
BLAKE2b-256 checksum
How to use checksums
5c7d309f28d639abf20e30bb1b1cfc989e43ecdd6d7ad3a4df938e919eb3fbfa
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.31-cp312-cp312-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.31-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
474a77dbf3a1f20d9e3473d74acad2c52270346d66736a174dbedb4612e800cf
BLAKE2b-256 checksum
How to use checksums
f4aa11a20e34973a478b004d5746ebd3b0403e37ec16c152eafa2736374af804
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.31-cp312-cp312-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.31-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
860712089eeaeab8a67cacfbc6507c1180b5a16c680b5243635ba47a321b969e
BLAKE2b-256 checksum
How to use checksums
62f3d99c23c96d454f87a9308726d2e30c41a827831565e03efc3c280c6bd550
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.31-cp312-cp312-macosx_15_0_arm64.whl

Download URL pymetkit-1.22.0.31-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
854f0b89792efb3758c7a1e9d7897df0ea6d53970e33138cd5dd3ab870469ec1
BLAKE2b-256 checksum
How to use checksums
076a18e084afe4be0834656744487f2ceb3b0628da02e833255764c25ae3c2fa
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.31-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.22.0.31-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
020f91197e4f86662be2881eb3aac0795ca7a6024f969dd0636f727b60e1e21b
BLAKE2b-256 checksum
How to use checksums
646527f3ded49675647943530c3c3eee61d0270862b1182796f797a7a0d928b8
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.31-cp311-cp311-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.31-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
80a15b2fe8fc2c72f92ee55bb82115ee108cd33167c7397210e5d96ca0daee4e
BLAKE2b-256 checksum
How to use checksums
d650fe1005f1fda2833c47e06bd73c8979169fa4e3ccf49b23717fac7d63d180
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.31-cp311-cp311-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.31-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
d93bfda896d468694f5d1083a116931baae2823a72489d913929f96179ebbc1f
BLAKE2b-256 checksum
How to use checksums
3bc8adbedd9c0cdebdbcb1ca3bdf758712aa931bf8ac0ad909ba52cc21067098
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.31-cp311-cp311-macosx_15_0_arm64.whl

Download URL pymetkit-1.22.0.31-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
ccfe1831c253ea9733e87309d9a77f07776f8451f5386a630259b42ddd9f4898
BLAKE2b-256 checksum
How to use checksums
6681a06310bee5619a4cda76848df28b7dbc3c1295325bb6ffd634d37a5163c7
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.31 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