# `numina.core` — Core classes for Pipelines

## `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)

  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.

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

  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

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

  Result holder for RecipeResult.

## `numina.core.metaclass` — Metaclasses

Base metaclasses

class `numina.core.metaclass.``RecipeInputType`

  Metaclass for RecipeInput.

class `numina.core.metaclass.``RecipeResultType`

  Metaclass for RecipeResult.

class `numina.core.metaclass.``StoreType`

  Metaclass for storing members.

## `numina.core.metarecipes` — Meta class for recipes

Metaclasses for Recipes.

class `numina.core.metarecipes.``RecipeType`

  Metaclass for Recipe.

`numina.core.metarecipes.``generate_docs`(klass)

  Add documentation to generated classes

## `numina.core.oresult` — Observation Result

Results of the Observing Blocks

class `numina.core.oresult.``ObservationResult`(instrument='UNKNOWN', mode='UNKNOWN')

  The result of a observing block.

  `get_sample_frame`()

    Return first available image in observation result

`numina.core.oresult.``dataframe_from_list`(values)

  Build a DataFrame object from a list.

`numina.core.oresult.``obsres_from_dict`(values)

  Build a ObservationResult object from a dictionary.

## `numina.core.pipeline` — Pipeline classes

DRP related classes

class `numina.core.pipeline.``InstrumentDRP`(name, configurations, modes, pipelines, products=None, datamodel=None, version='undefined')

  Description of an Instrument Data Reduction Pipeline

  Parameters: | name (str) – Name of the instrument configurations (dict of InstrumentConfiguration) – modes (dict of ObservingModes) – pipeline (dict of Pipeline) –

  `get_recipe_object`(mode_name, pipeline_name='default')

    Build a recipe object from a given mode name

  `iterate_mode_provides`(modes, pipeline)

    Return the mode that provides a given product

  `query_provides`(product, pipeline='default', search=False)

    Return the mode that provides a given product

  `search_mode_provides`(product, pipeline='default')

    Search the mode that provides a given product

  `select_configuration`(obresult)

    Select instrument configuration based on OB

class `numina.core.pipeline.``ObservingMode`

  Observing modes of an Instrument.

class `numina.core.pipeline.``Pipeline`(instrument, name, recipes, version=1, products=None, provides=None)

  Base class for pipelines.

  `depsolve`()

    Load all recipes to search for products

  `get_recipe_object`(mode)

    Load recipe object, according to observing mode

  `load_product_class`(mode)

    Load recipe object, according to observing mode

  `load_product_object`(name)

    Load product object, according to name

  `load_recipe_object`(mode)

    Load recipe object, according to observing mode

  `provides`(mode_label)

    Return the ProductEntry for some mode

  `query_recipe`(mode)

    Recursive query of all calibrations required by a mode

  `who_provides`(product_label)

    Return the ProductEntry for some requirement

## `numina.core.pipelineload` — Build pipelines from files

Build a LoadableDRP from a yaml file

`numina.core.pipelineload.``check_section`(node, section, keys=None)

  Validate keys in a section

`numina.core.pipelineload.``drp_load`(package, resource, confclass=None)

  Load the DRPS from a resource file.

`numina.core.pipelineload.``drp_load_data`(package, data, confclass=None)

  Load the DRPS from data.

`numina.core.pipelineload.``load_mode`(node)

  Load one observing mdode

`numina.core.pipelineload.``load_mode_builder`(obs_mode, node)

  Load observing mode OB builder

`numina.core.pipelineload.``load_mode_tagger`(obs_mode, node)

  Load observing mode OB tagger

`numina.core.pipelineload.``load_mode_validator`(obs_mode, node)

  Load observing mode validator

`numina.core.pipelineload.``load_modes`(node)

  Load all observing modes

## `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)

  The result of a Recipe.

class `numina.core.recipeinout.``RecipeResultQC`(*args, **kwds)

class `numina.core.recipeinout.``define_input`(inputClass)

  Recipe decorator.

`numina.core.recipeinout.``define_requirements`

  alias of `numina.core.recipeinout.define_input`

class `numina.core.recipeinout.``define_result`(resultClass)

  Recipe decorator.

## `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`

    ObservationResult, requirement

  `qc`

    QualityControl, result, QC.GOOD by default

  `logger`

    recipe logger

  class `RecipeInput`(*args, **kwds)

    RecipeInput base class

  class `RecipeResult`(*args, **kwds)

    The result of a Recipe.

  `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.requirements` — Recipe requirements

Recipe requirement holders

class `numina.core.requirements.``InstrumentConfigurationRequirement`

  The Recipe requires the configuration of the instrument.

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

  The Recipe requires the result of an observation.

## `numina.core.taggers` — Extract information from OBs

Function to retrieve tags from Observation results.

`numina.core.taggers.``get_tags_from_full_ob`(ob, reqtags=None)

  Parameters: | (ObservationResult) (ob) – (dict) (reqtags) –
  Returns: |
  Return type: | A dictionary

## `numina.core.types` — Types for Recipe IO

Deprecated since version 0.17: Use `numina.types`

## `numina.core.utils` — Utilities

Recipes for system checks.

class `numina.core.utils.``AlwaysFailRecipe`(*args, **kwargs)

  A Recipe that always fails.

  class `RecipeInput`(*args, **kwds)

    RecipeInput base class

  class `RecipeResult`(*args, **kwds)

    The result of a Recipe.

class `numina.core.utils.``AlwaysSuccessRecipe`(*args, **kwargs)

  A Recipe that always successes.

  class `RecipeInput`(*args, **kwds)

    RecipeInput base class

  class `RecipeResult`(*args, **kwds)

    The result of a Recipe.

class `numina.core.utils.``Combine`(*args, **kwargs)
  class `CombineInput`(*args, **kwds)

    CombineInput documentation.

    `field`

      str, requirement, optional, default=image – Extract field of previous result

    `method`

      str, requirement, optional, default=mean – Method of combination

    `obresult`

      ObservationResultType, requirement – Observation Result

  class `CombineResult`(*args, **kwds)

    CombineResult documentation.

    `result`

      DataFrameType, product

  `RecipeInput`

    alias of `numina.core.metaclass.CombineInput`

  `RecipeResult`

    alias of `numina.core.metaclass.CombineResult`

  `build_recipe_input`(obsres, dal)

    Build a RecipeInput object.

class `numina.core.utils.``OBSuccessRecipe`(*args, **kwargs)

  A Recipe that always successes, it requires an OB

  class `OBSuccessRecipeInput`(*args, **kwds)

    OBSuccessRecipeInput documentation.

    `obresult`

      ObservationResultType, requirement – Observation Result

  `RecipeInput`

    alias of `numina.core.metaclass.OBSuccessRecipeInput`

  class `RecipeResult`(*args, **kwds)

    The result of a Recipe.

## `numina.core.validator` — Input output validation

Validator decorator

`numina.core.validator.``as_list`(callable)

  Convert a scalar validator in a list validator

`numina.core.validator.``only_positive`(value)

  Validation error is value is negative

`numina.core.validator.``range_validator`(minval=None, maxval=None)

  Generates a function that validates that a number is within range

  Parameters: | minval (numeric, optional:) – Values strictly lesser than minval are rejected maxval (numeric, optional:) – Values strictly greater than maxval are rejected
  Returns: | A function that returns values if are in the range and raises ValidationError is the values are outside the range

`numina.core.validator.``validate`(method)

  Decorate run method, inputs and outputs are validated