Skip to main content

Toolbox for creating/assessing EMSO-compliant NetCDF datasets and integrate them into ERDDAP services

Project description

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")

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(["data.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.0
  • organization: Universitat Politècnica de Catalunya (UPC)
  • contact: enoc.martinez@upc.edu

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

emso_metadata_harmonizer-1.0.3.tar.gz (54.3 kB view details)

Uploaded Source

Built Distribution

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

emso_metadata_harmonizer-1.0.3-py3-none-any.whl (53.0 kB view details)

Uploaded Python 3

File details

Details for the file emso_metadata_harmonizer-1.0.3.tar.gz.

File metadata

  • Download URL: emso_metadata_harmonizer-1.0.3.tar.gz
  • Upload date:
  • Size: 54.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for emso_metadata_harmonizer-1.0.3.tar.gz
Algorithm Hash digest
SHA256 ae56b87992e77aefea12e1f7dd73361d9a3f1e8737c608a3731b7c655a3e3742
MD5 71fed42e3b6546a2868fee6ce618cd95
BLAKE2b-256 d012a7461d2c2ea89872d83b6c007c2a0a33db5fcd962025d31d8a203f604ed4

See more details on using hashes here.

File details

Details for the file emso_metadata_harmonizer-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for emso_metadata_harmonizer-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 88f7109ba078ac4de4e7aca68f67263cbea34c77a153fc53c3aa32926ab231ad
MD5 ab9ce7867cb6028c94af2b010a13b249
BLAKE2b-256 513c9d3d78cacf6fbd64d25813455daeed9857964bcc17b50a576025a2d155c7

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