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.csvand.yamlfilesemh.erddap_config(): integrates NetCDF files into an ERDDAP serveremh.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:
- Prepare CSV data and YAML metadata
- Generate EMSO-compliant NetCDF files using
generate_dataset() - Integrate datasets into your ERDDAP deployment using
erddap_config() - 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")
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")
📈 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.0.9
- organization: Universitat Politècnica de Catalunya (UPC)
- contact: enoc.martinez@upc.edu
Release files for emso-metadata-harmonizer 1.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| emso_metadata_harmonizer-1.0.9.tar.gz | 68.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| emso_metadata_harmonizer-1.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 135.6 kB
Release files / emso_metadata_harmonizer-1.0.9.tar.gz
| Download URL | emso_metadata_harmonizer-1.0.9.tar.gz |
|---|---|
| Size | 68.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08f397ad4fbd8675b622a89de914cc5303bd2b7863f4f3805c7653835425aece
|
|
BLAKE2b-256 checksum How to use checksums |
b5e7f79f4c854d8fb6b59a8cf754eec3eee246a98f81ffef62122ddd3a066fc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / emso_metadata_harmonizer-1.0.9-py3-none-any.whl
| Download URL | emso_metadata_harmonizer-1.0.9-py3-none-any.whl |
|---|---|
| Size | 67.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aa8ea2519bef1cd21db2298ded6df6d8872caa4e1c10a0a7c3443d7671758fd1
|
|
BLAKE2b-256 checksum How to use checksums |
c9fbcd355c1af1025608f0c45317d98beb263f33595c5a9e0b40b47a7354ab66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|