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

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

Download URL pymetkit-1.21.0.28-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
9a0eadc9f9ed0e53d6e1cf80e3bda7c21f764ae8268aa46deb2612549f5785fe
BLAKE2b-256 checksum
How to use checksums
2112a1c928f414baaef4feb51376cd402323bd24c0710fbe96d78cd258be7c4a
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.28-cp314-cp314-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.28-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
515045b2820aa8a48abf758bf90f5f4a1e1672f5406a0a5f71f5595b0d50a53d
BLAKE2b-256 checksum
How to use checksums
5d43c9f3c3b85a9762276f25c35bebc6a271919b5acfb8d989619956f87edbb8
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.28-cp314-cp314-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.0.28-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
a39a70bbe768c5a1a60aa20a42769fced1a665f889f87206a0f3a871f1d11829
BLAKE2b-256 checksum
How to use checksums
9c952e8bc79787041b3aaeea6a8d36d4ef691e9238007527820655f45861da46
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.0.28-cp314-cp314-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.0.28-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
fd0011232dc5139cc7e8b9f89e9bc085e100f7e54eaf00e6b327fa97ea071aca
BLAKE2b-256 checksum
How to use checksums
ab46065523047cb96b3696b2c378878a4a5e666f61c48353ee036fa9499072d6
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.28-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.0.28-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
21827401ac82a50fadc0dc55aa10bdd7a41af0c952f47d24c8e33c5e03fe9b98
BLAKE2b-256 checksum
How to use checksums
6a8d11d2eabd4bd63219972990dfee30aa3e7008b5a8bfcef13791f761727cda
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.28-cp313-cp313-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.28-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
ab444917df7f7c67b0f9a183b84e1fdf67f8e3fef8bc7a1e6cc6949af1acb9f9
BLAKE2b-256 checksum
How to use checksums
44a50890acb1b1c782f5ec0b5abb9f1c5193a3669f9214583e9385026004e500
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.28-cp313-cp313-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.0.28-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
9e7fbf8ba69f7f7ccee353ded52b0be15c5f9fad319a9ad5e61009552464225b
BLAKE2b-256 checksum
How to use checksums
28c601df78bd7da5ca2af91d150180db72ce1f76d51c72f8f11aa5846cd24978
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.28-cp313-cp313-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.0.28-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
8a6360d2fda4dbc384003218f65c6d468a734e35246dd04acb708161bccc6212
BLAKE2b-256 checksum
How to use checksums
268d5895796b5331a3c56c41aac3cf6a2cb0c6e30bd10650a82b44938aee665f
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.28-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.0.28-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
54d23d11ce0aae8565fba21adea0673f1d92817130c98930def2b8b3cbb646d9
BLAKE2b-256 checksum
How to use checksums
efefd6c5b63af25b324c973b0721a9fe42093c168b6c2ad689e88ee73610f20a
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.28-cp312-cp312-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.28-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
4f6c31932879f4f1ec5ee58f652ee3f26131e30ab086851a9b00595d4c3818e2
BLAKE2b-256 checksum
How to use checksums
a6179ce42dc914023363dc7a98a35dde4074b496a27a7196631de6eff4eb518c
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.28-cp312-cp312-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.0.28-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
ce4685f9923c9a0be6ce7a86ac7b0d7c9835cce99987e9514bd2a563342208d2
BLAKE2b-256 checksum
How to use checksums
e74f7bceb2eb166c166fbf04a35d4123784d1350b653bc95792070f09e296abb
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.28-cp312-cp312-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.0.28-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
7b0bd4929164484fc6aceb0009f515c978c3a16670d40a740c2e06576cafa58a
BLAKE2b-256 checksum
How to use checksums
85b110f47ef18d09727488717a8783dceb139ba53b11069964d92b652cc626b5
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.0.28-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.21.0.28-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
32049de4b6f1658907fd2630efeb5b6c32cffa5a93b94deaf22cb7c324d0b305
BLAKE2b-256 checksum
How to use checksums
1c5bfb36a726f1add10b87ac2a9d2772d52894418089da17db8e2a3b0080a781
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.28-cp311-cp311-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.21.0.28-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
2dd4ee3725677a5fac3ada8acf0a7be567bc3d0ceba690fc75d22b634b7d7bc5
BLAKE2b-256 checksum
How to use checksums
f32a67899f51fda64df5d07e25f013e8b1be3aeacf2baca9eeb2350b4ceb901c
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.28-cp311-cp311-macosx_15_0_x86_64.whl

Download URL pymetkit-1.21.0.28-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
d3e60274d6abf82409bd475168c839423ade904b3a33aaae5b55180ad7b570f9
BLAKE2b-256 checksum
How to use checksums
5f60b34215363af3b8be02e9084ea2e24ef071fdc48853a796368c361fbad208
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.28-cp311-cp311-macosx_15_0_arm64.whl

Download URL pymetkit-1.21.0.28-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
83402e0c7a867ea62ef36345a9289ca5ade3e73276b1d529621935125e6b1eb3
BLAKE2b-256 checksum
How to use checksums
79e76a42890542ffbf7923ca6cf3c84742406354348845d806f390774e731065
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.28 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