Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Metadata Harmonizer Toolbox

This repository contains a set of tools that can be used to create NetCDF files, integrate them into an ERDDAP server and to ensure the compliance with the EMSO Metadata Specifications. The tools provided here are:

  • emh.generate_dataset(): creates EMSO-compliant NetCDF files from .csv and .yaml files
  • emh.erddap_config(): integrates NetCDF files into an ERDDAP server
  • emh.metadata_report(): check the compliance of a dataset with the specifications.

In order to create and publish an EMSO-compliant dataset, the typical workflow is:

  1. Prepare CSV data and YAML metadata
  2. Generate EMSO-compliant NetCDF files using generate_dataset()
  3. Integrate datasets into your ERDDAP deployment using erddap_config()
  4. Validate metadata and operational compliance using metadata_report()

Installation

To install as a PyPi package:

pip3 install emso_metadata_harmonizer

🛠 NetCDF Generator

To generate a NetCDF dataset from data (csv) and metadata (yaml) files:

import emso_metadata_harmonizer as emh

emh.generate_dataset(["data.csv"], ["meta.yaml"], output="dataset.nc")

generate_dataset() also accepts in-memory objects instead of file paths, to skip the disk round-trip when data is already loaded:

  • data_files accepts a pandas.DataFrame (or a list mixing paths and DataFrames) in place of a CSV/NetCDF path. All required fields (time, depth, sensor_id, platform_id, variables) must be regular columns, not the DataFrame index — if time is in the index instead of a column, generation fails with Could not find valid time key!. Call .reset_index() first if needed.
  • metadata_files accepts a dict (or a list mixing paths and dicts) in place of a YAML path.
import emso_metadata_harmonizer as emh
import pandas as pd

df = pd.DataFrame({
    "time": pd.to_datetime(["2024-01-01T00:00:00", "2024-01-01T01:00:00"]),
    "depth": [10.0, 10.0],
    "sensor_id": ["SBE16", "SBE16"],
    "platform_id": ["OBSEA", "OBSEA"],
    "TEMP": [15.2, 15.3],
})  # data in columns, not in the index

meta = {"sensors": {...}, "platforms": {...}, "global": {...}, "variables": {...}}

emh.generate_dataset([df], [meta], output="dataset.nc")

Full example with data and metadata from the example 2

import emso_metadata_harmonizer as emh
import urllib

# Download data and metadata from the example 2 in the metadata-harmonizer repository
data_url = "https://raw.githubusercontent.com/emso-eric/metadata-harmonizer/refs/heads/develop/examples/02/SBE16.csv"
meta_url = "https://raw.githubusercontent.com/emso-eric/metadata-harmonizer/refs/heads/develop/examples/02/meta.yaml"
urllib.request.urlretrieve(data_url, "data.csv")
urllib.request.urlretrieve(meta_url, "meta.yaml")

# Generate dataset from one data file
emh.generate_dataset(["data.csv"], ["meta.yaml"], "dataset.nc")

To generate a dataset from multiple data files:

import emso_metadata_harmonizer as emh
import urllib

# Generate dataset from multiple data files
data1_url = "https://raw.githubusercontent.com/emso-eric/metadata-harmonizer/refs/heads/develop/examples/02/SBE16.csv"
data2_url = "https://raw.githubusercontent.com/emso-eric/metadata-harmonizer/refs/heads/develop/examples/02/SBE37.csv"
meta_url = "https://raw.githubusercontent.com/emso-eric/metadata-harmonizer/refs/heads/develop/examples/02/meta.yaml"
urllib.request.urlretrieve(data1_url, "data1.csv")
urllib.request.urlretrieve(data2_url, "data2.csv")
urllib.request.urlretrieve(meta_url, "meta.yaml")

emh.generate_dataset(["data1.csv", "data2.csv"], ["meta.yaml"], "dataset2.nc")

⚙️ ERDDAP Configurator

The ERDDAP Configurator (erddap_config()) helps prepare ERDDAP dataset definitions for NetCDF files, reducing manual work editing ERDDAP’s XML configurations. It reads NetCDF metadata and generates XML chunk required to register a new dataset.

import emso_metadata_harmonizer as emh

emh.erddap_config("dataset.nc", "MyDatasetIdentifier", "/path/to/dataset/files")

To automatically append a new dataset into an existing ERDDAP deployment, the path to the datasets.xml file should be passed via the datasets_xml_file parameter.

import emso_metadata_harmonizer as emh

emh.erddap_config("dataset.nc", "MyDatasetIdentifier", "/path/to/dataset/files", datasets_xml_file="path/to/datasets.xml")

To append additional variables to ERDDAP's subsetVariables attribute (on top of the ones EMH always adds based on the dataset's featureType), use the subset_variables parameter:

import emso_metadata_harmonizer as emh

emh.erddap_config("dataset.nc", "MyDatasetIdentifier", "/path/to/dataset/files", subset_variables=["depth_qc", "my_variable"])

📈 Metadata Report

The metadata reporting tool assesses the level of compliance of an ERDDAP or NetCDF dataset with the EMSO Metadata Specifications. To test a dataset, use the following syntax:

import emso_metadata_harmonizer as emh
emh.metadata_report("dataset.nc")

Logging

To control the verbosity of the logging messages:

import logging
logging.getLogger("emso_metadata_harmonizer").setLevel(logging.WARN)

Where WARN is the level of logging messages. Check the Python logging documentation for more information.

Contact info

  • author: Enoc Martínez
  • version: v1.1.0
  • organization: Universitat Politècnica de Catalunya (UPC)
  • contact: enoc.martinez@upc.edu

Metadata

Release files for emso-metadata-harmonizer 1.1.2.dev1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for emso-metadata-harmonizer 1.1.2.dev1
File Size Uploaded Provenance Actions
emso_metadata_harmonizer-1.1.2.dev1.tar.gz 77.9 kB Without provenance Details for emso_metadata_harmonizer-1.1.2.dev1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for emso-metadata-harmonizer 1.1.2.dev1
File Interpreter ABI Platform Actions
emso_metadata_harmonizer-1.1.2.dev1-py3-none-any.whl Python 3 none any Details for emso_metadata_harmonizer-1.1.2.dev1-py3-none-any.whl

Total release size: 155.2 kB

Release files / emso_metadata_harmonizer-1.1.2.dev1.tar.gz

Download URL emso_metadata_harmonizer-1.1.2.dev1.tar.gz
Size 77.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dbc43ea676b5be45a0d137304c1e3ae729194ddbe0d0c54bd161996ab3cd2788
BLAKE2b-256 checksum
How to use checksums
ba0cf263bf1e05ecd931768a1b7b2e356d4d9cc5fddee34ff79cd96545f28d65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / emso_metadata_harmonizer-1.1.2.dev1-py3-none-any.whl

Download URL emso_metadata_harmonizer-1.1.2.dev1-py3-none-any.whl
Size 77.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dcd26fd108ab9cfac19db106c7b01f314970ce94c9cb9831bb5de024613dbf73
BLAKE2b-256 checksum
How to use checksums
32b04472c26c10845c785623ae86c145181673a178e7105152853b1b28ede95b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for emso-metadata-harmonizer 1.1.2.dev1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
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