rail.interfaces package

class rail.interfaces.PZFactory

Bases: object

Factory class to provide a unified interface to rail p(z) estimation algorithms.

classmethod build_cat_estimator_stage(stage_name, class_name, module_name, model_path, data_path='none', **config_params)

Build and configure an estimator that can evalute p(z) given an input catalog

Parameters:
  • stage_name (str) – Name of the stage instance, used to construct output file name

  • class_name (str) – Name of the class, e.g., TrainZEstimator, used to find the class

  • module_name (str) – Name of the python module that constains the class, used to import it

  • model_path (str) – Path to the model file used by this estimator

  • data_path (str) – Path to the input data, defaults to ‘none’

  • config_params (dict) – Configuration parameters for the stage

Returns:

stage_obj – Newly constructed and configured Estimator instance

Return type:

CatEstimator

classmethod build_stage_instance(stage_name, stage_class, model_path, data_path='none', **config_params)

Build and configure an estimator that can evalute p(z) given an input catalog

Parameters:
  • stage_name (str) – Name of the stage instance, used to construct output file name

  • stage_class (type) – Python class for the stage

  • model_path (str| dict) – Path to the model file used by this estimator, or the model itself

  • data_path (str) – Path to the input data, defaults to ‘none’

  • config_params (dict) – Configuration parameters for the stage

Returns:

stage_obj – Newly constructed and configured Estimator instance

Return type:

CatEstimator

static estimate_single_pz(stage_obj, data_table, input_size=1)

Run a p(z) estimator on some objects

Parameters:
  • stage_obj (CatEstimator) – Object that will do the estimation

  • data_table (dict) – Input data presented as dict of numpy arrays objects

  • input_size (int) – Number of objects in the input table

Returns:

pz – Output pz

Return type:

qp.Ensemble

classmethod get_cat_estimator_stage(stage_name)

Return a cached p(z) estimator

Parameters:

stage_name (str)

Return type:

CatEstimator

classmethod reset()

Reset the dictionary of cached stage objects

Return type:

None

static run_cat_estimator_stage(stage_obj, data_path)

Run a p(z) estimator on an input data file

Parameters:
  • stage_obj (CatEstimator) – Object that will do the estimation

  • data_path (str)

Returns:

data_handle – Object that can give access to the data

Return type:

DataHandle

class rail.interfaces.ToolFactory

Bases: object

Factory class to provide a unified interface to rail tool stages

classmethod build_stage_instance(stage_name, stage_class, data_path='none', **config_params)

Build and configure a rail tool stage

Parameters:
  • stage_name (str) – Name of the stage instance, used to construct output file name

  • stage_class (type) – Python class for the stage

  • data_path (str) – Path to the input data, defaults to ‘none’

  • config_params (dict) – Configuration parameters for the stage

Returns:

stage_obj – Newly constructed and configured RailStage instance

Return type:

RailStage

classmethod build_tool_stage(stage_name, class_name, module_name, data_path='none', **config_params)

Build and configure a rail tool stage

Parameters:
  • stage_name (str) – Name of the stage instance, used to construct output file name

  • class_name (str) – Name of the class, used to find the class

  • module_name (str) – Name of the python module that constains the class, used to import it

  • data_path (str) – Path to the input data, defaults to ‘none’

  • config_params (dict) – Configuration parameters for the stage

Returns:

stage_obj – Newly constructed and configured Estimator instance

Return type:

CatEstimator

classmethod get_tool_stage(stage_name)

Return a tool stage

Parameters:

stage_name (str)

Return type:

RailStage

classmethod reset()

Reset the dictionary of cached stage objects

Return type:

None

static run_tool_stage(stage_obj, data_path)

Run a p(z) estimator on an input data file

Parameters:
  • stage_obj (CatEstimator) – Object that will do the estimation

  • data_path (str)

Returns:

data_handle – Object that can give access to the data

Return type:

DataHandle