Skip to main content

Yet another NetCDF checker

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.

Metadata

Release files for metyanc 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metyanc 0.1.4
File Size Uploaded
metyanc-0.1.4.tar.gz 17.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metyanc 0.1.4
File Interpreter ABI Platform
metyanc-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 34.9 kB

Release files / metyanc-0.1.4.tar.gz

Download URL metyanc-0.1.4.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2c2218c5d625eb9f7dcf29358f1c451bbe062972022b199f57c52288f7855842
BLAKE2b-256 checksum
How to use checksums
996cfc00f7027f0178bb093d18f8b8485fbca940ca16603864dd29613ffd17b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / metyanc-0.1.4-py3-none-any.whl

Download URL metyanc-0.1.4-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4715200b074ed8a4847887b6e8586ed177b61f63a57acbd7d8d604251215660
BLAKE2b-256 checksum
How to use checksums
520f995e8a2ce145e489315f1c7755d26eb940e9b030b623d933b1ca9ae205e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page