Skip to main content

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

Project description

Metadata Harmonizer

This python project contains the tools to connect to an ERDDAP service and assess if the metadata is compliant with the EMSO Metadata Specifications.

Setup this project

To download this repository:

$ git clone https://github.com/emso-eric/metadata-harmonizer
$ cd metadata-harmonizer
$ pip3 install -r requirements.txt

Metadata Tester

Test o run the test on an ERDDAP dataset:

The metadata_report.py tool tests if the metadata contained within a dataset (ERDDAP, NetCDF or JSON) is compatible with EMSO Metadata Specifications.

To test an erddap dataset:

$ python3 metadata_report.py <erddap url>  --list  # get the list of datasets
$ python3 metadata_report.py <erddap url>  -d <dataset_id>  # Run the test for one dataset

For example, to run tests on dataset with id=EMSO_Western_Ionian_Sea_CTD_2002_2003 from EMSO's central ERDDAP:

$ python3 metadata_report.py https://erddap.emso.eu  -d EMSO_Western_Ionian_Sea_CTD_2002_2003

To run tests on all ERDDAP datasets:

$ python3 metadata_report.py <erddap url> 

To run tests on a NetCDF file

$ python3 metadata_report.py <filename> 

Dataset Generator

The generator.py tool allows to create EMSO-compliant NetCDF files.

Creating a Dataset based on CSV files

To create a NetCDF file from a CSV file, the first step is to generate the minimal metadata template (.min.json) based on the CSV file structure. To generate the template use the following command:

$ python3 generator.py --data <filename> --generate <folder> 

A minimal metadata template (.min.json) file will be created within the folder. Then, it is required to add the metadata within the minimal metadata template. All attributes with a leading * (e.g. *title) are mandatory. Attributes with a leading ~ are optional. If not filled, they will be deduced from default values or other parameters. Fields with a leadig $ will be asked interactively. Once the minimal metadata template is filled we are ready to generate the NetCDF dataset:

$ python3 generator.py --data <filename> --metadata <minimal metadata>  --outfile <output nc file> 

When executing the generator with the --metadata option, the minimal metadata template will be expand the metadata and add all default values and derived attributes. The minimal metadata template will be updated with the user choices and derived options. Additionally, a full metadata file (.full.json) will be generated and stored alongside the minimal metadata template. The data from the CSV file and the generated metadata will be combined into the NetCDF file espcified with the --outfile option.

If some of the default values or derived attributes need to be modified it is possible to modify the full metadata file (.full.json) and re-run the generator:

$ python3 generator.py --data <filename> --metadata <full metadata>  --outfile <output nc file> 

The changes in the full metadata file will be reflected on the output nc file.

Creating a Dataset based on multiple CSV files

Several CSV files can be comined into a single NetCDF file. Assuming that we want combine data1.csv and data2.csv into a single NetCDF file:

# Creates minimal metadata templates data1.min.json and data2.min.json
$ python3 generator.py --data data1.csv data2.csv --generate myfolder

# Edit the minimal metadata files and rerun the generator with the --metadata option
$ python3 generator.py --data data1.csv data2.csv -m myfolder/data1.min.json myfolder/data2.min.json -o all.nc

Now the data from both files is combined into the all.nc file. Note that there is some metadata overlapping in the data1.min.json and data2.min.json. In case of a conflicting attribute the values in the leftmost file will prevail.

Contact info

  • author: Enoc Martínez
  • version: v0.4.2
  • 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-0.4.2.tar.gz (42.3 kB view details)

Uploaded Source

Built Distribution

emso_metadata_harmonizer-0.4.2-py3-none-any.whl (47.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for emso_metadata_harmonizer-0.4.2.tar.gz
Algorithm Hash digest
SHA256 37e482eeb60bb594f32e93c9a14f61cd8d01fcb88264fa57242365c045d47de9
MD5 cc4cad595feb7f8fa5614ab7c5b6d4bb
BLAKE2b-256 20a7f2bd23a2e9d015456b80787a3f5f4c794b3d3944a5e827a992c2606fc850

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for emso_metadata_harmonizer-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 98a8bbdcde4a24459609dd6ebc6677aba5ddcb0aec3de896c966dd0d98fae33c
MD5 6e864119c1d873dcc1421956d669dacf
BLAKE2b-256 6cbf604d8d3ca07e4a676f83738b56027d356d6258b420c0ed2bcf9dc6b8e60e

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