Implementation of IRIS StationXML validation rules
Project description
IRIS-validator
iris-validator is a small python module for validation stationxml files against the IRIS StationXML Validation Rules found at:
https://github.com/iris-edu/stationxml-validator/wiki/StationXML-Validation-Rule-List
It has a limited API and a command-line script
Installation
Requirements
obspy >= 1.2
These requirements should be automatically installed for you (see below).
Install
Easy install from pypi:
>pip install iris-validator
Alternatively, you can Clone the repository and install:
>git clone https@gitlab.isti.com:mhagerty/iris-validator.git
>cd iris-validator
>pip install .
Usage:
Once you have installed it, you should be able to run it as a python module from any directory.
iris-validator can either test your own xml against the iris validation rules (--infile /path/to/your.xml) or it can run through a suite of tests that test known xml snippets against each rule (--run-tests). The tests are mainly there to confirm that the iris rules are being applied correctly (e.g., to test the code itself).
>iris-validator
usage: iris-validator [-h] (--infile INFILE | --run-tests)
required arguments: // One of these is required
--infile INFILE // path-to StationXML file, e.g., --infile=/path/to/foo.xml
--run-tests // Run IRIS Validator Test Files
> iris-validator --run-tests
Check file:F1_101.xml against Rule:101
SUCCESS: xmlfile=[F1_101.xml] FAILED as expected
Check file:F1_110.xml against Rule:110
SUCCESS: xmlfile=[F1_110.xml] FAILED as expected
Check file:F2_110.xml against Rule:110
SUCCESS: xmlfile=[F2_110.xml] FAILED as expected
...
Check file:P1_112.xml against Rule:112
SUCCESS: xmlfile=[P1_112.xml] PASSED as expected
...
Check file:F1_422.xml against Rule:422
SUCCESS: xmlfile=[F1_422.xml] FAILED as expected
Check file:F1_423.xml against Rule:423
SUCCESS: xmlfile=[F1_423.xml] FAILED as expected
Additional cmd line options:
usage: iris-validator [-h] (--infile INFILE | --run-tests)
[-s STATION] [-c CHANNEL] [-n NETWORK] [-l LOCATION] [-def] [-i IGNORE [IGNORE ...]]
options:
-h, --help show this help message and exit
-s STATION, --station STATION, --sta STATION
Specify a station code, wildcards are allowed
-c CHANNEL, --channel CHANNEL, --cha CHANNEL
Specify a channel code, wildcards are allowed
-n NETWORK, --network NETWORK, --net NETWORK
Specify a network code, wildcards are allowed
-l LOCATION, --location LOCATION, --loc LOCATION
Specify a location code, wildcards are allowed
-def, --seismic-only, --seismic_only
Only scan default_seismic_channels in: {[BEHSG][HNL][123ENZ]}
-i IGNORE [IGNORE ...], --ignore IGNORE [IGNORE ...]
Specify list of rule codes to ignore
For example, to ignore specific rule checks you can do:
>iris-validator --infile /path/to/file.xml -i 321,420 421 422 ...
-n, -s, -c, -l flags can be used to select only these channels for scanning
API
To use the module from within your own python script, follow the example below:
from iris_validator import stationxml_validator
validator = stationxml_validator('path/to/some/stationxml.xml')
validator.validate_inventory()
print("[ERRORS]:\n")
for msgs in validator.errors:
for i, msg in enumerate(msgs):
if i == 0:
print(msg)
else:
print("%7s %s" % (' ', msg))
print("\n[WARNINGS]:\n")
for msgs in validator.warnings:
for i, msg in enumerate(msgs):
if i == 0:
print(msg)
else:
print("%7s %s" % (' ', msg))
Note some other things you can do include:
validator.validate_rule('420') // You can test your stationxml file against one rule at a time
Project details
Release history Release notifications | RSS feed
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 iris-validator-0.0.3.tar.gz
.
File metadata
- Download URL: iris-validator-0.0.3.tar.gz
- Upload date:
- Size: 537.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
82f85b7cb2db4a4d7a3777c1055f8791062b2964c2dbe93140b5bf4c17fd184c
|
|
MD5 |
0330981cb8be7eb5c9895159003feaca
|
|
BLAKE2b-256 |
fa00805b04e154901e5b1dd2324c6d9293ecdec9a7e6ade973de4bb496360375
|
File details
Details for the file iris_validator-0.0.3-py2.py3-none-any.whl
.
File metadata
- Download URL: iris_validator-0.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 686.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
509126270bd2203266930d130e0d75d3dd6b3c0bd29c00a4a194d67c80d1c2c5
|
|
MD5 |
d7e118b3bf28c369b088783124f5e95c
|
|
BLAKE2b-256 |
4a3d13a33fb849e052ad0698c4bc7b11e15bf90554915cc7fd6862a9fd461138
|