DKIST data validator
Project description
An interface containing a validator, and a spec translator for DKIST specs:
SPEC-0122 Rev E: Data received from the summit
SPEC-0214 l0: Data ingested and parsed by the Data Center
SPEC-0214 Rev A: Data published by the Data Center (incomplete)
The validator references this machine readable version of the DKIST specs. If you are receiving validation errors, please reference this repo to make sure that your headers match the current spec.
Features
Uses voluptuous schemas to validate a given input header against dkist specifications
3 keyword validations: type validation, required-ness validation, and value validation
Failure exceptions include a dictionary of validation failure causes
SPEC-0122 to SPEC-0214 l0 translation
Installation
pip install dkist-header-validator
Usage
Currently, this package can be used to validate SPEC122 data or SPEC214 data. Please import the corresponding methods (spec122_validator and Spec122ValidationException, or spec214_validator and Spec214ValidationException, or spec214_l0_validator and Spec214ValidationException).
This package can be used for validating data, or for validating and translating data (SPEC122 input only).
- Input data can be one of:
string file path
File like object
HDUList object
fits.header.Header object
Dictionary of header keys and values
To validate data:
>>> from dkist_header_validator import spec122_validator, Spec122ValidationException
>>> spec122_validator.validate('dkist_rosa0181200000_observation.fits')
The cli can also be used to validate data:
>>> dkist-header-validator validate122 "path/to/file.fits"
>>> dkist-header-validator validate214 "path/to/file.fits"
To validate and translate data to spec214 l0:
>>> from dkist_header_validator import spec122_validator, Spec122ValidationException
>>> spec122_validator.validate_and_translate_to_214_l0('dkist_rosa0181200000_observation.fits')
- Within the validate and validate_and_translate methods, a series of flags can be set, otherwise they will take their default values:
extra: Default value is true (allow extra keys). This flag determines if extra keywords are allowed in the schema to be validated. Ingest validation should allow extra keys.
return_type: Default value is HDUList. This flag will determine the return type. Can be one of dict, Path, BytesIO, fits.header.Header, HDUList.
Examples
Validate a file:
>>> from dkist_header_validator import spec122_validator, Spec122ValidationException
>>> spec122_validator.validate('dkist_rosa0181200000_observation.fits', return_type=dict)
>>> from pathlib import Path
>>> spec122_validator.validate('dkist_rosa0181200000_observation.fits', return_type=Path)
Validate and translate a file:
>>> from dkist_header_validator import spec122_validator, Spec122ValidationException
>>> spec122_validator.validate_and_translate_to_214_l0('dkist_rosa0181200000_observation.fits')
Validate headers:
>>> from dkist_header_validator import spec122_validator, Spec122ValidationException
>>> from astropy.io import fits
>>> hdus = fits.open('dkist_rosa0181200000_observation.fits')
>>> spec122_validator.validate(hdus[0].header, return_type=dict)
This project is Copyright (c) AURA/NSO.
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
Hashes for dkist-header-validator-2.0.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 288c08138c91d40b57692535ddcf5fc7ea17f3943ac017447c3298038585fda3 |
|
MD5 | e3268386a54433ca8df976b0a36b5049 |
|
BLAKE2b-256 | 9465940151a7f40f511e49f41af855226d0be99eb4eca45e62e752d321dfea7f |