Skip to content

Add prototype paramdb api#185

Draft
awarde96 wants to merge 3 commits intodevelopfrom
feature/paramdb-api
Draft

Add prototype paramdb api#185
awarde96 wants to merge 3 commits intodevelopfrom
feature/paramdb-api

Conversation

@awarde96
Copy link

Add prototype paramdb api that allows conversion of ECMWF shortname to param id and vice versa using either the paramdb directly or a local copy.

Adds a ParamDB class to pymetkit.py for resolving ECMWF parameter metadata (shortname ↔ longname ↔ param ID, units) with both online (live API) and offline (bundled YAML) modes.

New files

  • parameter_metadata.yaml — bundled offline parameter data generated from the parameter-database
  • generate_parameter_metadata.py — standalone script to regenerate the YAML from the ECMWF API (python -m pymetkit.generate_parameter_metadata)

Changes

  • pymetkit.py — adds ParamDB class; imports yaml, requests, Path
    *. __init__.py — explicitly exports ParamDB
  • pyproject.toml — adds pyyaml + requests to dependencies; includes parameter_metadata.yaml in package data

Usage

from pymetkit import ParamDB

# Offline (default, uses bundled YAML)
db = ParamDB()
db.shortname_to_longname("2t")        # "2 metre temperature"
db.param_id_to_shortname(129)         # "z"
db.longname_to_param_id("Geopotential")  # 129
db.get_units("tp")                    # "m"
db.get_metadata(167)                  # full dict

# Online (fetches from codes.ecmwf.int)
db = ParamDB(mode="online")

Lookup via get_metadata / get_units accepts param ID (int), shortname, or longname interchangeably.

Description

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

…o param id and vice versa using either the paramdb directly or a local copy
@codecov-commenter
Copy link

codecov-commenter commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.33%. Comparing base (fa88f33) to head (c2b7ee8).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #185   +/-   ##
========================================
  Coverage    62.33%   62.33%           
========================================
  Files          303      303           
  Lines        11601    11601           
  Branches      1036     1036           
========================================
  Hits          7232     7232           
  Misses        4369     4369           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants