Skip to main content

DKIST data validator

Project description

codecov

An interface containing a validator, and a spec translator for DKIST specs (specifically corresponding to SPEC122 RevE and SPEC214 RevA data):

  • SPEC-0122: Data received from the summit

  • SPEC-0214 l0: Data ingested and parsed by the Data Center

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

The validator references a machine readable version of the DKIST Header Specifications which are defined here, in the dkist-fits-specifications. Unless otherwise specified, the latest version of dkist-fits-specifications package is installed along with the validator. Data can be validated against past revisions of the DKIST Header Specifications if a previous version of the dkist-fits-specifications package is installed. If you are receiving validation errors, please reference the version of the DKIST Header Specifications identified in the dkist-fits-specifications package to make sure that your headers are expected to be compliant with that version.

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

  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-5.3.1.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dkist_header_validator-5.3.1-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file dkist_header_validator-5.3.1.tar.gz.

File metadata

  • Download URL: dkist_header_validator-5.3.1.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for dkist_header_validator-5.3.1.tar.gz
Algorithm Hash digest
SHA256 0f18997f37047e3ff2004e429e01ba30c2795ce51ebd18569466834c986fa0d1
MD5 78869e86d382187e57dd18b2db0608c3
BLAKE2b-256 4f26e0292101302284a0ccd2b4672e6c16514587130bee421e007fa1c7fa7195

See more details on using hashes here.

File details

Details for the file dkist_header_validator-5.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dkist_header_validator-5.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab0a2530f6fc0a94ef6a42669508a5c7db0db6f6554467dcce5121ed8e3e43f6
MD5 e4b61c17840bf8b53b8a2695f04a5550
BLAKE2b-256 ba8aa07979167c3bb6122be5cf1a683998ae787f0e8d08c00efa2353a798eadc

See more details on using hashes here.

Supported by

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