Skip to main content

Single source of truth for ESM's EM27 measurement logistics

Project description

EM27 Metadata

Static Badge

The purpose of this library

This repository is the single source of truth for our EM27 measurement logistics: "Where has each station been on each day of measurements?" We selected this format over putting it in a database due to various reasons:

  • Easy to read, modify and extend by selective group members using GitHub permissions
  • Changes to this are more evident here than in database logs
  • Versioning (easy to revert mistakes)
  • Automatic testing of the files integrities
  • Easy import as a statically typed Python library

This tool was developed as part of the EM27 Retrieval Pipeline.


How it works

This repository only contains a Python library to interact with the metadata. The metadata itself is stored in local files or a GitHub repository. The library can load the metadata from both sources and provides a unified interface with static types to access it.


Library Usage

Install as a library:

pdm add em27_metadata
# or
pip install em27_metadata
import datetime
import em27_metadata

em27_metadata_store = em27_metadata.load_from_github(
    github_repository="org-name/repo-name",
    access_token="your-github-access-token",
)

# or load it from local files
em27_metadata_store = em27_metadata.load_from_local_files(
    locations_path="location-data/locations.json",
    sensors_path="location-data/sensors.json",
    campaigns_path="location-data/campaigns.json",
)

metadata = location_data.get(
      sensor_id="sid1",
      from_datetime=datetime.datetime(
          2020, 8, 26, 0, 0, 0, tzinfo=datetime.timezone.utc
      ),
      to_datetime=datetime.datetime(
          2020, 8, 26, 23, 59, 59, tzinfo=datetime.timezone.utc
      ),
  )
  print(metadata)

Prints out something like this:

[
  {
    "sensor_id": "sid1",
    "serial_number": 50,
    "from_datetime": "2020-08-26T00:00:00+0000",
    "to_datetime": "2020-08-26T23:59:59+0000",
    "location": {
      "location_id": "lid1",
      "details": "description of location 1",
      "lon": 10.5,
      "lat": 48.1,
      "alt": 500.0
    },
    "utc_offset": 2.0,
    "pressure_data_source": "LMU-MIM01-height-adjusted",
    "atmospheric_profile_location": {
      "location_id": "lid1",
      "details": "description of location 1",
      "lon": 10.5,
      "lat": 48.1,
      "alt": 500.0
    }
  }
]

The object returned by em27_metadata_store.get() is of type list[em27_metadata.types.SensorDataContext]. It is a Pydantic model (https://docs.pydantic.dev/) but can be converted to a dictionary using metadata.model_dump().

The list will contain one item per time period where the metadata properties are continuous (same setup). You can find dummy data in the data/ folder.


Set up an EM27 Metadata Storage Directory

You can use the repository https://github.com/tum-esm/em27-metadata-storage-template to create your own repository for storing the metadata. It contains a GitHub Actions workflow that automatically validates the metadata on every commit in any branch.

A full reference for the three JSON schemas can be found at https://em27-retrieval-pipeline.netlify.app/api-reference/metadata.


For Developers

Run tests:

# used inside the GitHub CI for this repo
pytest -m "ci"

# used inside the GitHub Actions workflow for storage repos
pytest -m "action"

# can be used for local development (libe "ci", but skips pulling from GitHub)
pytest -m "local"

Publish the Package to PyPI:

poetry build
poetry publish

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

em27_metadata-1.3.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

em27_metadata-1.3.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file em27_metadata-1.3.0.tar.gz.

File metadata

  • Download URL: em27_metadata-1.3.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.0 CPython/3.9.6 Darwin/25.0.0

File hashes

Hashes for em27_metadata-1.3.0.tar.gz
Algorithm Hash digest
SHA256 f90012286b419e7381e166fa0d84b3a254512efb5db6ad6299582452779f92b7
MD5 9998e53870c17b94fc51c0e8e7eaac64
BLAKE2b-256 c50090b1c754a787dac73dc7dee6b5f42ce21adf6148b643004a230e92be46b7

See more details on using hashes here.

File details

Details for the file em27_metadata-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: em27_metadata-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.0 CPython/3.9.6 Darwin/25.0.0

File hashes

Hashes for em27_metadata-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7fb34e2394c9d7033a7387cf6a1d614f353507cf2bf8c19669bb8ce25c6718e
MD5 cbcc292ac63bd3828f5ca99cd55657c6
BLAKE2b-256 2711103e6b3f30dc126e942a411f1705b7bdfd151ecd93202f6365976a6e33e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page