megaradrp.validators — MEGARA validators

Validation of MEGARA images and calibrations

There are two kinds of validators:

  • The validators of the observing modes (validator in drp.yaml), that check the observation result as a whole, for example validate_arc().

  • The checkers of the images and structured calibrations of each MegaraDataType, collected in check_as_datatype. They validate the headers with the JSON schemas baseimage.json and basestruct.json of megaradrp.schemas, and then do additional checks in Python.

The checkers are used by megaradrp.datamodel.check_obj_megara(), the checker of the MEGARA DRP, used by numina.core.config.check.

class megaradrp.validators.BaseChecker(validator)

Base class of ExtChecker

class megaradrp.validators.CheckAsDatatype

The checkers of each MegaraDataType.

The checkers use the schemas baseimage.json, for images, and basestruct.json, for structured calibrations. Calling the object with a datatype returns its checker. The instance used by the DRP is check_as_datatype.

class megaradrp.validators.Checker(validator)

Base class of the checkers of objects with a JSON schema.

A checker is called with the object, and returns True or raises an exception if the object is not valid. level is not used.

Parameters:
validatorjsonschema validator

The validator of the schema.

check(obj, level=None)

Check obj, only with check_post()

check_post(hdulist, level=None)

Additional checks after the schema, nothing by default

class megaradrp.validators.CompImageChecker(validator)

Checker of raw arc images, with two HDUs

check_post(hdulist, level=None)

Check the lamps: all incandescent OFF, some comparison ON

class megaradrp.validators.ExtChecker(validator, definitions, n_ext=None)

Checker of images with definitions of the schema for the primary HDU.

The image is validated with the full schema and then the values of the primary header with each of the definitions.

Parameters:
validatorjsonschema validator

The validator of baseimage.json.

definitionslist of str

Names of definitions of the schema, for example “raw_hdu_values”.

n_extint, optional

The number of HDUs of the image, if it is fixed.

check_dheaders(dheaders, level=None)

Check the number of HDUs, the full schema and the definitions

class megaradrp.validators.FlatImageChecker(validator)

Checker of raw flat images, with two HDUs

check_post(hdulist, level=None)

Check the lamps: some incandescent ON, all comparison OFF

class megaradrp.validators.ImageChecker(validator)

Checker of images, validates the headers of all the HDUs with the schema

check(hdulist, level=None)

Check the headers with check_dheaders(), and then check_post()

check_dheaders(dheaders, level=None)

Validate the converted headers with the schema.

In images with two HDUs, the FIBERS extension is also checked with check_header_additional().

class megaradrp.validators.MasterFlatRSSChecker(validator)

Checker of master fiber flats, RSS with three HDUs

class megaradrp.validators.MasterSensitivityChecker(validator)

Checker of master sensitivities, spectra with one HDU

class megaradrp.validators.StructChecker(validator)

Checker of structured calibrations, serialized as dictionaries

check(obj, level=None)

Check obj, only with check_post()

class megaradrp.validators.TargetImageChecker(validator)

Checker of raw images of targets, with two HDUs

check_post(hdulist, level=None)

Check the lamps: all incandescent and comparison OFF

megaradrp.validators.check_as_datatype = <megaradrp.validators.CheckAsDatatype object>

The checkers of each MegaraDataType

megaradrp.validators.check_header_additional(values_primary, values_fibers)

Checks of the FIBERS extension that can’t be done with the schema.

INSMODE must be the same in the primary header and in FIBERS, and FIBERS must have the keywords of every bundle and fiber of the mode. The names of the fibers (FIBxxx_N) are optional, a warning is logged if they are missing.

Raises:
numina.exceptions.ValidationError

If the extension is not valid.

megaradrp.validators.check_invalid(obj, level=None)

A checker that rejects every object

megaradrp.validators.check_null(obj, level=None)

A checker that accepts every object

megaradrp.validators.convert_header(header)

Convert a FITS header to a dictionary that can be validated with a JSON schema.

The dictionary has the keys “values” and “comments”, with the values and comments of each keyword, and “ordering”, the list of keywords.

megaradrp.validators.convert_headers(hdulist)

Convert the headers of hdulist to a list of dictionaries, see convert_header()

megaradrp.validators.definition_validator(validator, name)

Validator of the definition name of the schema of validator

The other definitions are included, so that the references of the definition can be resolved.

megaradrp.validators.lamps_on(header, kind)

Keywords of the lamps of kind that are ON

kind is “I” for the incandescent lamps and “S” for the comparison lamps.

megaradrp.validators.relevant_error(error)

The most relevant leaf error of a schema error

In an error of anyOf or oneOf, the relevant alternative is the one that fails deepest in the instance, with fewer errors.

megaradrp.validators.validate_arc(mode, obresult)

Validate the observation result of the mode MegaraArcCalibration.

All the frames must have the same SPECLAMP, see validate_key().

megaradrp.validators.validate_flat(mode, obresult)

Validate the observation result of the mode MegaraFiberFlatImage.

Nothing is checked, apart from the raw images.

megaradrp.validators.validate_focus(mode, obresult)

Validate the observation result of the mode MegaraFocusSpectrograph.

The frames must have a numeric FOCUS, with at least two different values.

Raises:
numina.exceptions.ValidationError

If the observation result is not valid.

megaradrp.validators.validate_key(mode, obresult, key)

Validate that all the frames have the same value of the keyword key.

Raises:
numina.exceptions.ValidationError

If a frame does not have the keyword, or the values are different.

megaradrp.validators.validate_keyword_any_value(header, key, any_expected)

Validate that keyword has any of allowed values

megaradrp.validators.validate_keyword_exists(header, key)

Verify that the keyword exists

megaradrp.validators.validate_keyword_value(header, key, expected)

Validate that the keyword has the value expected

megaradrp.validators.validate_schema(validator, instance, hdu=None)

Validate instance with validator, raise ValidationError with a short message

The message names the HDU and the keyword, for example “HDU 0, keyword EXPTIME: …”, using the most relevant error, see relevant_error(). hdu is the index of the HDU when instance are the values of its header.

Raises:
numina.exceptions.ValidationError

If instance is not valid.