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

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

Download URL pymetkit-1.22.0.33-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
193fd1333e96014cadfc141b870fe2c073abaef5c75490a7923bcafcfc0f04ca
BLAKE2b-256 checksum
How to use checksums
cac4e4262b87fd60ed42299bc5378d1e57161f8234bde9a6f4cad0ddc28bf4ad
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.33-cp314-cp314-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.33-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
c34566919011cf5ad68662232bbe5c35c61f42472eabb6e20a66901c036e12fe
BLAKE2b-256 checksum
How to use checksums
0343ee2478ef10ad5b20bccbedb33f11a7ab773be366c0c1afe4a084e4a81dda
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.33-cp314-cp314-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.33-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
de5b61d24e406b36a5c39f59a697302ee3a6a93e1ed700c2d09131af68070730
BLAKE2b-256 checksum
How to use checksums
3f47ab149e72d444a4b90f7a9a91ed5a9f9e9ac1a534d3db830bae6b51bdafbf
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.33-cp314-cp314-macosx_15_0_arm64.whl

Download URL pymetkit-1.22.0.33-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
b6f0a3a11a035f069a076c4413a962674e8dd28a3eff796f01490c28f022b158
BLAKE2b-256 checksum
How to use checksums
56782093084b7e10e3c9a3a9a008603fb89e43946f46f1127f977e38653f90bc
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.33-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.22.0.33-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
dc7ca11a8213c1e0f143127c8ef26a1105d0750b5517db8560171c494cec47c7
BLAKE2b-256 checksum
How to use checksums
79ed83a0e17a3780544e8b36881eeca3843ebf45df05dc4d49f4ee930bf0764f
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.33-cp313-cp313-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.33-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
7be77d20d8747acd8b7b44afd96cff724c9626bbf66c11ce21e6e1f6e6fb02d7
BLAKE2b-256 checksum
How to use checksums
3255f09d86e3ef56ffc2f216b89495830b39fe1aa486a051ac12efaecf7398d5
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.33-cp313-cp313-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.33-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
845291c1bb549f228c74cedbb0ad49c8d885f1eb8d2e12e8d403d8cfe12f663d
BLAKE2b-256 checksum
How to use checksums
5e7b686568fec36b8ad18673d76e4964d80c54ecef89de96ac99d48aee65f117
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.33-cp313-cp313-macosx_15_0_arm64.whl

Download URL pymetkit-1.22.0.33-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
ee686a1d70d64933893687107094f5a014ca05fe43879523387430f43a84fb0b
BLAKE2b-256 checksum
How to use checksums
a37fced51fc32d1e1e9b2fc04398694661abe387fc0d1daffe9788cd05fe6e55
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.33-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.22.0.33-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
81097de69e664b9be6407057d0a3bf33e218e68d5ccfc1555fa7cd4ff9e33ba7
BLAKE2b-256 checksum
How to use checksums
d76d1da5458fd39540315775df8e2489937f0b84a49069d81d9086b0f3e29e2b
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.33-cp312-cp312-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.33-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
bd3e26e413e72e5e9874f8794d876c1a8bf57ff9c9592eb5e99208ec5d795726
BLAKE2b-256 checksum
How to use checksums
6a6cb67b1838b6feeecc9450ab0413378efa08245dbdc68764922ec400a92e8d
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.33-cp312-cp312-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.33-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
69845b2b048d85a908b8d1991b6d60ab76e04496c01f51a7c12f85add7f2ad3d
BLAKE2b-256 checksum
How to use checksums
b6143bbc8749d81abca13a034bb71b42e81b2b4ca00a224358d19d9eae545c74
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.33-cp312-cp312-macosx_15_0_arm64.whl

Download URL pymetkit-1.22.0.33-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
1187245a195ccb95b1a771774f423d42d13465ff16138fb17c13d865dbda4b88
BLAKE2b-256 checksum
How to use checksums
7fefdcb6799bd3afb6445583c38be912a70f59f1f8bf907564e84c3cb8785c9e
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.33-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL pymetkit-1.22.0.33-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
7655b0fb866c6eb5e7f7f7ba3fdcf912f5f7b6a36e5c1fcb245f5b86e6dade93
BLAKE2b-256 checksum
How to use checksums
9ca662d702927a62f57f0cb22cc30593076dccc6a12ba089fb59bbc48d1a8cde
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.33-cp311-cp311-manylinux_2_28_aarch64.whl

Download URL pymetkit-1.22.0.33-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
abc6ed309963468af5cdf1041b0d93ba6caab4634d21ae2ccb056dc454d19adb
BLAKE2b-256 checksum
How to use checksums
767692f35e99cb7f71fb47cd792397d70617729488bde87177c1cf4e9597fcbd
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.33-cp311-cp311-macosx_15_0_x86_64.whl

Download URL pymetkit-1.22.0.33-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
0cfc2c021d8023e17c1516d4989fa2432dc08cefbc9a140293cf16a24a487c36
BLAKE2b-256 checksum
How to use checksums
5b86490b1a2a3af29cfe88c3a9ae2b0ff9ec99e2008d920270b8c23e75e2d381
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.33-cp311-cp311-macosx_15_0_arm64.whl

Download URL pymetkit-1.22.0.33-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
3583d11d5be2bc360fd77d1d8ffe55d10e5993c6eb06dc098312663459350278
BLAKE2b-256 checksum
How to use checksums
81575c8dd92182ef8d5f89a5b7583a76e4726dd671eaedfd49f8f916ce745bf3
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.33 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