numina.core.recipes — Base class for Recipes

Basic tools and classes used to generate recipe modules.

A recipe is a class that complies with the reduction recipe API:

  • The class must derive from numina.core.BaseRecipe.

class numina.core.recipes.BaseRecipe(*args, **kwargs)

Base class for all instrument recipes

Parameters:

intermediate_results (bool, optional) – If True, save intermediate results of the Recipe

obresult
Type:

ObservationResult, requirement

logger

recipe logger

class RecipeInput(*args, **kwds)

RecipeInput base class

class RecipeResult(*args, **kwds)
build_recipe_input(ob, dal)

Build a RecipeInput object.

classmethod create_input(*args, **kwds)

Pass the result arguments to the RecipeInput constructor

classmethod create_result(*args, **kwds)

Pass the result arguments to the RecipeResult constructor

run_qc(recipe_input, recipe_result)

Run Quality Control checks.

save_intermediate_array(array, name)

Save intermediate array object as FITS.

save_intermediate_img(img, name)

Save intermediate FITS objects.

set_base_headers(hdr)

Set metadata in FITS headers.

validate_input(recipe_input)

“Validate the input of the recipe

validate_result(recipe_result)

Validate the result of the recipe

numina.core.recipes.timeit(method)

Decorator to measure the time used by the recipe

numina.core.recipeinout — Recipe input and output

Recipe inputs and outputs

class numina.core.recipeinout.RecipeInput(*args, **kwds)

RecipeInput base class

class numina.core.recipeinout.RecipeResult(*args, **kwds)
class numina.core.recipeinout.RecipeResultBase(*args, **kwds)

The result of a Recipe.

class numina.core.recipeinout.define_input(input_class)

Recipe decorator.

numina.core.recipeinout.define_requirements

alias of define_input

class numina.core.recipeinout.define_result(resultClass)

Recipe decorator.

numina.core.dataholders — Dataholders

Recipe requirements

class numina.core.dataholders.Parameter(value, description, destination=None, optional=True, choices=None, validation=True, validator=None, accept_scalar=False, as_list=False, nelem=None, alias=None)

The Recipe requires a plain Python type.

Parameters:
  • value (plain python type) – Default value of the parameter, the requested type is inferred from the type of value.

  • description (str) – Description of the parameter. The value is used by numina show-recipes to provide human-readible documentation.

  • destination (str, optional) – Name of the field in the RecipeInput object. Overrides the value provided by the name of the Parameter variable

  • optional (bool, optional) – If False, the builder of the RecipeInput must provide a value for this Parameter. If True (default), the builder can skip this Parameter and then the default in value is used.

  • choices (list of plain python type, optional) – The possible values of the inputs. Any other value will raise an exception

  • validator (callable, optional) – A custom validator for inputs

  • accept_scalar (bool, optional) – If True, when value is a list, scalar value inputs are converted to list. If False (default), scalar values will raise an exception if value is a list

  • as_list (bool, optional:) – If True, consider the internal type a list even if value is scalar Default is False

  • nelem (str or int, optional:) – If nelem is ‘*’, the list can contain any number of objects. If is ‘+’, the list must contain at least 1 element. With a number, the list must contain that number of elements.

  • alias (str, optional) – Alternative name of the field in the RecipeInput object.

convert(val)

Convert input values to type values.

validate(val)

Validate values according to the requirement

class numina.core.dataholders.Product(ptype, description='', validation=True, destination=None, optional=False, default=None, choices=None)

Product holder for RecipeResult.

Deprecated since version 0.16: Product is replaced by Result. It will be removed in 1.0

class numina.core.dataholders.Requirement(rtype, description, destination=None, optional=False, default=None, choices=None, validation=True, query_opts=None, alias=None)

Requirement holder for RecipeInput.

Parameters:
  • rtype (DataType or Type[DataType]) – Object or class repressenting the yype of the requirement, it must be a subclass of DataType

  • description (str) – Description of the Requirement. The value is used by numina show-recipes to provide human-readable documentation.

  • destination (str, optional) – Name of the field in the RecipeInput object. Overrides the value provided by the name of the Requirement variable

  • optional (bool, optional) – If False, the builder of the RecipeInput must provide a value for this Parameter. If True (default), the builder can skip this Parameter and then the default in value is used.

  • default (optional) – The value provided by the Requirement if the RecipeInput builder does not provide one.

  • choices (list of values, optional) – The possible values of the inputs. Any other value will raise an exception

  • alias (str, optional) – Alternative name of the field in the RecipeInput object.

class numina.core.dataholders.Result(ptype, description='', validation=True, destination=None, optional=False, default=None, choices=None)

Result holder for RecipeResult.

numina.core.requirements — Recipe requirements

Recipe requirement holders

class numina.core.requirements.ObservationResultRequirement(query_opts=None)

The Recipe requires the result of an observation.

on_query_not_found_from_type(notfound)
Parameters:

notfound

query(dal, obsres, options=None)
Parameters:
  • dal

  • obsres

  • options

numina.core.tagexpr — Tagger expression

Classes to express tags constraints in recipe requirements

Each type has a series of tag attributes inside the .tags member. Operating with tags creates tag expressions.

>>> tags1 = Tagged(['vph', 'insmode'])
>>> tags1.tags.insmode == "LCB"

When processed, this represents that the insmode key of a particular calibration must be equal to “LCB”.

Most of the time, you don’t need a fixed value, but a value that comes from the observed data

>>> tags1.tags.insmode == tags1.tags.p_("insmode")

In this case, the insmode tag of the calibration must be equal to the value of insmode extracted from the observed data.

Expresions can be nested and make use of the typical logical conectors (AND, OR, NOT), like:

>>> (tags1.tags.insmode == tags1.tags.p_("insmode")) & (tags1.tags.vph == tags1.tags.p_("vph"))

Where & represents AND, | represents OR and ~ represents NOT

class numina.core.tagexpr.AtomicExpr(name, value)

“Atomic expression

class numina.core.tagexpr.BinaryExpr(lhs, rhs, oper, op_rep)
class numina.core.tagexpr.CompoundExpr(*args)

Compound expression

class numina.core.tagexpr.ConstExpr(value)

A representation of a constant value

class numina.core.tagexpr.ConstraintAdapter(key, value, oper)

For GTC

class numina.core.tagexpr.Expression(*args)

Base class for expressions

fill_placeholders(**kwargs)

Substitute Placeholder nodes by its value in tags

fill_tags(**kwargs)

Substitute Placeholder nodes by its value in tags

is_terminal()

True for leaf nodes

class numina.core.tagexpr.Placeholder(name)

A representation of a value expected to be substituted

class numina.core.tagexpr.PredAnd(lhs, rhs)
class numina.core.tagexpr.PredEq(lhs, rhs)
class numina.core.tagexpr.PredGe(key, value)
class numina.core.tagexpr.PredGt(key, value)
class numina.core.tagexpr.PredLe(key, value)
class numina.core.tagexpr.PredLt(key, value)
class numina.core.tagexpr.PredNe(key, value)
class numina.core.tagexpr.PredNot(pred)
class numina.core.tagexpr.PredOr(lhs, rhs)
class numina.core.tagexpr.TagRepr(name, metadata=None)

A representation of a Tag

class numina.core.tagexpr.UnaryExpr(pred, oper)
numina.core.tagexpr.filter_tree(condition, tree)

Return parts of the tree that fulfill condition

numina.core.tagexpr.map_tree(visitor, tree)

Apply function to nodes