Skip to main content

DKIST data validator

Project description

An interface containing a validator, and a spec translator for DKIST specs:

  • SPEC-0122 Rev C: Data received from the summit

  • SPEC-0214 Rev ?: Data published by the Data Center (incomplete)

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 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')

To validate and translate data to spec214:

>>> from dkist_header_validator import spec122_validator, Spec122ValidationException

>>> spec122_validator.validate_and_translate_to_214('dkist_rosa0181200000_observation.fits')
Within the validate and both 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

  1. 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)
  1. 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')
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dkist-header-validator-2.0.7.tar.gz (22.2 kB view details)

Uploaded Source

File details

Details for the file dkist-header-validator-2.0.7.tar.gz.

File metadata

  • Download URL: dkist-header-validator-2.0.7.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for dkist-header-validator-2.0.7.tar.gz
Algorithm Hash digest
SHA256 3e535e76206e147e15486be80402109d7bd1204d054592d66b8c6dd932c540d2
MD5 5cf6cbe15d0d7b2b1311fa612effa078
BLAKE2b-256 537867765e4f1ccb42801e7d0a68426648fedf85f6520b2852f4a1919a3248f5

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page