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.1
  • 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.1.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

emso_metadata_harmonizer-0.4.1-py3-none-any.whl (46.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for emso_metadata_harmonizer-0.4.1.tar.gz
Algorithm Hash digest
SHA256 d14144e1d672095669eafc28f391355a0eaa05cc24cc4ae7872dde7b5c208e44
MD5 739a23a5cab700833b227a4160299d20
BLAKE2b-256 b8adaf18faab392531c57958685fc9882c84b3d052caa2170167f44e9a4d4ce9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for emso_metadata_harmonizer-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 90ab392ceddce956574497bfbb572104b9ee3057e51a19863733e572b9cc3a5a
MD5 727e7185832e132aec0215b36c8a8b5b
BLAKE2b-256 66e42cdff2a48a7893afd4b36365f4ab7ab828c5c69c7a6488317aa5ac5feada

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