Yet another NetCDF checker
Project description
This command-line program checks that a NetCDF file conforms to a pre-defined specification. It checks if the file contains the specified dimensions and variables; that the dimensions are of the correct size; that the variables have values within range; and that the variables have certain attributes.
Example use
python yanc.py\
--ncfile http://thredds.met.no/thredds/dodsC/meps25files/meps_det_pp_2_5km_latest.nc \
--template templates/meps_det_pp_2_5km.yml
Template
Yanc checks the NetCDF file against specifications in a template file. The template understands the following structure:
dimensions:
- name: time
length: 15
- name: x
min_length: 10
max_length: 20
variables:
- name: air_temperature
min: 200
max: 400
units: K
'% missing': 10
missing_timesteps: [0,1,2]
All attributes are optional, and yanc will not check dimensions/variables/min/max/etc when not specified. Dimensions can be checked for an exact length (by using the work ‘length’) or a range of lengths (inclusively, by using ‘min_length’ and ‘max_length’).
Neither ‘dimensions’ nor ‘variables’ are required to be present in the file.
Installation
The easiest way to install yanc is using pip:
pip install metyanc
To install from source, install like this:
pip install -r requirements.txt
python setup.py install
Return codes
The program returns 0 if the file is valid. Otherwise a non-zero code is returned. If the template file is missing or contains invalid YAML, or if the NetCDF file does not exist or is invalid NetCDF, then a non-zero code is returned.
Missing values
By default, variables are not allowed to have missing values. To allow a missing values, the ‘% missing’ can be added, which means the test will fail if there the percentage of missing values exceeds the allowed value. Some variables (such as precipitation_amount) will have have missing values on the first timestep. Data in timesteps specified by missing_timesteps will not count towards the percentage missing.
For example, the following requires the precipitation_amount variable to have no missing values except for the first time step:
variables:
- name: precipitation_amount
units: m
'% missing': 0
missing_timesteps: 0
missing_timesteps can also be an array like this:
variables:
- name: precipitation_amount
units: m
'% missing': 0
missing_timesteps: [0, 1, 2]
Testing
Running “make test” runs some quick unittests. Running “make testop” checks that the current operational files conform to specifications. This can take 10-15 minutes.
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
Built Distribution
File details
Details for the file metyanc-0.1.4.tar.gz
.
File metadata
- Download URL: metyanc-0.1.4.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c2218c5d625eb9f7dcf29358f1c451bbe062972022b199f57c52288f7855842 |
|
MD5 | 9c0e5fe25094674ae429987b5a4bc2e0 |
|
BLAKE2b-256 | 996cfc00f7027f0178bb093d18f8b8485fbca940ca16603864dd29613ffd17b8 |
File details
Details for the file metyanc-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: metyanc-0.1.4-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4715200b074ed8a4847887b6e8586ed177b61f63a57acbd7d8d604251215660 |
|
MD5 | 5bdb9e4ff48366b8c558e9c7bee4e138 |
|
BLAKE2b-256 | 520f995e8a2ce145e489315f1c7755d26eb940e9b030b623d933b1ca9ae205e7 |