ugrid-checks
Version : 0.2.0
A utility to check netcdf files to the UGRID specification.
It tests files against the UGRID conformance rules, and can also produce a summary of the mesh content of a file.
- Installation
- Command Line : checking
- Command Line : structure analysis
- List of Conformance Rules and codes
- Limitations
- Python API
- Runtime Requirements
- Known Issues
- Raising Issues
- Changelog
Installation
Available on PyPI and conda-forge.
To install:
> pip install ugrid-checks
or
> conda create -n ugrid_checker ugrid-checks
Command Line : checking
$ ugrid-checker -h
usage: ugrid-checker [-h] [-q] [-i IGNORE] [-e] [-d MAX_DATASIZE] [-s] [--nonmesh] [-v] [file]
Check a netcdf-CF file for conformance to the UGRID conventions.
positional arguments:
file File to check.
optional arguments:
-h, --help show this help message and exit
-q, --quiet don't print a checking report if there were no problems
-i IGNORE, --ignore IGNORE
a list of errorcodes to ignore.
-e, --errorsonly ignore all warnings ("Axxx"= advise codes), and only report errors ("Rxxx"= require codes).
-d MAX_DATASIZE, --max-datasize MAX_DATASIZE
maximum array-size, above which variable-data checks are skipped. Default=200.0 (Mb).
-s, --summary print a summary of UGRID mesh information found in the file
--nonmesh include a list of non-mesh variables in the summary
-v, --version print version information
$
Basic usage
$ ugrid-checker data_C4.nc
UGRID conformance checks complete.
No problems found.
Done.
$
$ ugrid-checker data_C4_warn_error.nc
UGRID conformance checks complete.
List of checker messages :
*** FAIL R106 : Mesh variable "topology" attribute 'face_coordinates' refers to a variable "longitude", but there is no such variable in the dataset.
*** FAIL R108 : Mesh variable "topology" has face_coordinates="latitude longitude", which is not a list of variables in the dataset.
... WARN A304 : Mesh connectivity variable "edge_nodes" of mesh "topology" has a '_FillValue' attribute, which should not be present on a "edge_node_connectivity" connectivity.
Total of 3 problems logged :
2 Rxxx requirement failures
1 Axxx advisory recommendation warnings
Done.
$
Controlling checks
The -e / --errorsonly option checks only against the requirements (aka "errors"),
and skips the recommendations (aka "warnings").
The -i / --ignore option skips particular checks according to their Axxx/Rxxx codes.
See List of codes.
Example:
$ ugrid-checker data_C4_warn_error.nc --errorsonly --ignore r106,r108
Ignoring codes:
R106, R108
UGRID conformance checks complete.
No problems found.
Done.
$
Command line : structure analysis
The -s / --summary option prints a summary of a file's mesh content.
$ ugrid-checker data_C4.nc --summary --quiet
File mesh structure
-------------------
Meshes
"topology"
node("num_node")
coordinates : "node_lat", "node_lon"
face("dim0")
face_node_connectivity : "face_nodes"
coordinates : "latitude", "longitude"
Mesh Data Variables
"sample_data"
mesh : "topology"
location : "face"
$
List of Conformance Rules and codes
All the error/warning codes used are defined in the UGRID conformance rules. Each has an identifying code : "Rxxx" for requirements or "Axxx" for advisory rules.
See the list here : UGRID Draft Conformance Rules
Note : these are currently only available in this preliminary draft version, not yet accepted into the UGRID spec.
Limitations
No 3-D / Volume support
The draft conformance rules do not currently cover 3-d meshes, so neither does the checker code.
There is also an ongoing discussion whether it is needed to "fix" this feature, or even to remove it in a future release of UGRID.
See this developer discusssion.
Alternatively, this can be added in future.
Python API
The checker is provided as an importable module "ugrid_checks".
Running the module directly calls the command-line interface,
e.g. $ python -m ugrid_checks file.nc is the same as $ ugrid-checker file.nc.
Within Python, the module can be used like this :
>>> from ugrid_checks.check import check_dataset
>>> print(check_dataset.__doc__)
Run UGRID conformance checks on a file.
Optionally print a result summary.
Optionally ignore errors below a logging level.
Returns a checker object with a file analysis and checking log records.
Parameters
----------
file : string, Path or :class:`NcFileSummary`
path to, or representation of a netcdf input file
print_summary : bool, default=True
print a results summary at the end
omit_advisories : bool, default False
If set, log only 'requirements' Rxxx statements, and ignore the
advisory 'Axxx' ones.
ignore_codes : list(str) or None, default None
A list of error codes to ignore.
max_data_mb : float, default 200.0
A rough size threshold (in Mb), beyond which we will skip data checks.
Set to 0 for no checking, or -1 for no size limit.
Returns
-------
checker : Checker
A checker for the file.
>>>
>>> checker = check_dataset('data_C4_warn.nc', print_summary=False)
>>>
>>> type(checker)
<class 'ugrid_checks.check.Checker'>
>>>
>>> print(checker.checking_report())
UGRID conformance checks complete.
List of checker messages :
... WARN A304 : Mesh connectivity variable "edge_nodes" of mesh "topology" has a '_FillValue' attribute, which should not be present on a "edge_node_connectivity" connectivity.
Total of 1 problems logged :
0 Rxxx requirement failures
1 Axxx advisory recommendation warnings
Done.
>>>
>>> print(checker.structure_report())
Meshes
"topology"
node("num_node")
coordinates : "node_lat", "node_lon"
face("dim0")
face_node_connectivity : "face_nodes"
coordinates : "latitude", "longitude"
Mesh Data Variables
"sample_data"
mesh : "topology"
location : "face"
>>>
For the time being, there is no built API documentation : Please refer to code docstrings for more detail.
Runtime Requirements
- Python >= 3.7
- netCDF4
Known Issues
- none known
Raising Issues
Please create an issue in : https://github.com/pp-mo/ugrid-checks
Changelog
-
TODO: move to separate file ?
-
- release 2022-02-27
- #36 fix to A304
allow face-node-connectivity to have a _FillValue, as this is used for flexible 2d meshes.
- #36 fix to A304
- release 2022-02-27
-
- release 2022-02-09
Metadata
Release files for ugrid-checks 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ugrid-checks-0.2.0.tar.gz | 35.4 kB | Without provenance | Details for ugrid-checks-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ugrid_checks-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for ugrid_checks-0.2.0-py3-none-any.whl |
Total release size: 69.6 kB
Release files / ugrid-checks-0.2.0.tar.gz
| Download URL | ugrid-checks-0.2.0.tar.gz |
|---|---|
| Size | 35.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ef87be311794c664f7d505c7ace20ffffd32078f8098f5f981320351ab5a1040
|
|
BLAKE2b-256 checksum How to use checksums |
61ad83a54e9c5e67daf449a2bbbd280a0d55237073dc7ac0ede97a67e0fe0942
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.8.13
|
Release files / ugrid_checks-0.2.0-py3-none-any.whl
| Download URL | ugrid_checks-0.2.0-py3-none-any.whl |
|---|---|
| Size | 34.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a3be8b163c0e7f7b60d5acd9b67dabb67df26705dca86d1173e7e2d48c09d8bb
|
|
BLAKE2b-256 checksum How to use checksums |
5a46782a74e4e9300263ac6eb8bd5f6854859242a4d8bab1a27efe051fafd3cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.8.13
|
Security for ugrid-checks 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.