Skip to main content

Single source of truth for ESM's EM27 measurement logistics

Project description

EM27 Metadata

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.2.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

em27_metadata-1.2.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: em27_metadata-1.2.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.18.2 CPython/3.12.3 Linux/6.8.0-39-generic

File hashes

Hashes for em27_metadata-1.2.1.tar.gz
Algorithm Hash digest
SHA256 ecbbbcd47f01436bbf89af28128a21bc64bebfc645f7633c496d8a16bed6d831
MD5 fafb3348829b13fe676add0d673f230c
BLAKE2b-256 cf4acb27e36533ce4899a6a168b3a26567a54e57f28153610ace7c3f4e764508

See more details on using hashes here.

File details

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

File metadata

  • Download URL: em27_metadata-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.18.2 CPython/3.12.3 Linux/6.8.0-39-generic

File hashes

Hashes for em27_metadata-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60031936570e89fe5ff6587250d11c296bdee0afa8cbbeafbcf2b4da6b27568c
MD5 faaa6308d5c249cd2b8ef5c093e15806
BLAKE2b-256 48eb89b7243641240665bc6d50b75abadfc57012f992cb964ebe60338f3df75d

See more details on using hashes here.

Supported by

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