Skip to main content

Toolbox for creating/assessing EMSO-compliant NetCDF datasets and integrate them into 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. This project can be used as a standalone cli tool or as a PyPi package to be integrated with other code.

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

Uploaded Source

Built Distribution

emso_metadata_harmonizer-0.4.6-py3-none-any.whl (48.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for emso_metadata_harmonizer-0.4.6.tar.gz
Algorithm Hash digest
SHA256 b95f543cde512426eb0b0d4e2ebc573ed0c835c3552c1705964269a0372e914d
MD5 af639e172d3ea8ab45f19dfa59307af6
BLAKE2b-256 e615bdcf82714bc355d3a3db816c8761f34015c7813e8713e97e02992bc47c29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for emso_metadata_harmonizer-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e536314cb2be8e4e6a987d02dce444c836128a5634ce2b693bd6a2fdb080e38b
MD5 6f037672ff41af47083d8f08c3d895ee
BLAKE2b-256 8d8725fe27d7188d4c7172ab273aa1825efb555cab95d63fe0e33dee6aa71ccf

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