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

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

Download URL pymetkit-1.21.0.29-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
aec9a180fd07ad6bf0a35bf5a76b8d3909ff0ca8e491b8402c85fc0a8e1b027b
BLAKE2b-256 checksum
How to use checksums
a19ac0a8dbc700f2a536377eb192e30c313ef8ca70a56a1d076704bacbec30a9
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.29-cp314-cp314-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.29-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
71e32c6a180ba3726cc110c4ed4aad90fb1325671956a931721cce49a9129e0a
BLAKE2b-256 checksum
How to use checksums
cc4ba22befdd97ad4f26675a5b5b73605371a860232167ec9bd6c5e73011d275
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.29-cp314-cp314-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.0.29-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
b84980094a4de73cefa30c416a8ec2f173ff1865f8adf741b8e449299d9575c3
BLAKE2b-256 checksum
How to use checksums
c9e9d2dd489776c0e73db4b3379e50b4d9fc589b8097d566f7a5c8f46a4f830e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.14.5

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

Download URL pymetkit-1.21.0.29-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
eb1e0d48f4e128fe271909be710de06db40fa953820c81a069799d6cdcf58c90
BLAKE2b-256 checksum
How to use checksums
cede351f460d4ecfc7a8dc50067f8c0f6d3cd3dcc64493346a9e4fbf6d8d0ef4
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.0.29-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.0.29-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
1151cf9ad838c6fb52b8f964054d11bd9fb17e5e0bb80140c42417509083668a
BLAKE2b-256 checksum
How to use checksums
5fbbc82a805fc8be28437acef7234c064e1c9abff0b6679256c74516f4d42982
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.29-cp313-cp313-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.29-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
c6852aa6a96d325cf5d6f23b6a02721eb1f9a0ba062d61c78a180aed7d640bba
BLAKE2b-256 checksum
How to use checksums
ccb242bf47f077962ac0552471d10df186e3ac949181d78d176c59add79e048e
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.29-cp313-cp313-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.0.29-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
aed5a465f0d084013dc528dfc663c7e072f82e2db75968a005f8c9eaded80905
BLAKE2b-256 checksum
How to use checksums
047d9b3a40c3b3176c05533cc5b464991885ffc85f0b8e71bba5060728a50690
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.0.29-cp313-cp313-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.0.29-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
f83f9e528364b87440085ea40832586e3400dabf889fc0e61895fadf4cc617a1
BLAKE2b-256 checksum
How to use checksums
727a33ba049fc85d351ae9d27efb61bb147c9d7954a0117869a24a85711359d2
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.0.29-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.0.29-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
ba4831e4fef080ef35b8da9a4edbba82963743788ce9774b6c922d80e0eb321d
BLAKE2b-256 checksum
How to use checksums
355d19d636d5f4b34390c2aaf63453876f8d6370a9b424db12c71f94e2395d2a
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.29-cp312-cp312-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.29-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
2c22911950aae8456b0766c9ad9726b5c09e276b848a06f1b12e4fb553832608
BLAKE2b-256 checksum
How to use checksums
f6d8455dd58aeae0b15385fd12ec2116487ff6d304eb8ac2e00a287fd84a0cf9
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.29-cp312-cp312-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.0.29-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
98078b9d8c3a09d99e7dfcc63ca927625ed1790bce94c74127eae5369af34655
BLAKE2b-256 checksum
How to use checksums
c81775600c74d12aae443cacde4e086197f7d4c90918edcf369310f7a426c1ac
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.0.29-cp312-cp312-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.0.29-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
b17963f82983d65c156874a856fe2c95fd4b34c95fc6577a69214dbbb58b3703
BLAKE2b-256 checksum
How to use checksums
4384c5674864a752e9714cde2c89da709d3caec2abe660ffb3a3a47539de423a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.14

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

Download URL pymetkit-1.21.0.29-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
71e45f46596eddee3371ce1b87aca5296846992ba87299a7ff98c6d89714cc3f
BLAKE2b-256 checksum
How to use checksums
56da358915a6d82e88b681d68af163394c2e94804e0906b2335cab3ddd272fd1
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.29-cp311-cp311-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.29-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
784ccc5e9b7cb71cdb0a809c4bb214f018f700622a6f31149d5eb8dfbdc89335
BLAKE2b-256 checksum
How to use checksums
2871d9fd5cd82d72ca79804fa26ddf244a57118419d694850c82ece546bb6d52
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.29-cp311-cp311-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.0.29-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
136005ccb618153067cc7691b10913b3911426bab81adc1e8bbaf672e7fee773
BLAKE2b-256 checksum
How to use checksums
a465439acefe66d988717cd3c1a0ec3116b3a19f3e1e97d82a05ea5f83724005
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.0.29-cp311-cp311-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.0.29-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
c9fdac5cd3852fb19f00d548b8052b7a85befec8e48c1a215067fab3d804a41a
BLAKE2b-256 checksum
How to use checksums
d745abc94ed456d784e6ac3e10756182450b5e35383460a277a7371095a3bb6e
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.0.29 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