rail.creation.engine module

Abstract base classes defining a Creator.

A Creator will create synthetic photometric data and a PosteriorCalculator, which can calculate posteriors for the data with respect to the distribution defined by the Creator.

class rail.creation.engine.Creator(args, comm=None)[source]

Bases: RailStage

Base class for Creators that generate synthetic photometric data from a model.

Creator will output a table of photometric data. The details will depend on the particular engine.

config_options = {'n_samples': <class 'int'>, 'output_mode': <ceci.config.StageParameter object>, 'seed': 12345}
inputs = [('model', <class 'rail.core.data.ModelHandle'>)]
name = 'Creator'
open_model(**kwargs)[source]

Load the model and/or attach it to this Creator.

Keywords

modelobject, str or ModelHandle

Either an object with a trained model, a path pointing to a file that can be read to obtain the trained model, or a ModelHandle providing access to the trained model

returns:

self.model – The object encapsulating the trained model

rtype:

object

outputs = [('output', <class 'rail.core.data.TableHandle'>)]
sample(n_samples: int, seed: int | None = None, **kwargs)[source]

Draw samples from the model specified in the configuration.

This is a method for running a Creator in interactive mode. In pipeline mode, the subclass run method will be called by itself.

Parameters:
  • n_samples (int) – The number of samples to draw

  • seed (int) – The random seed to control sampling

Returns:

table – The samples

Return type:

table-like

Notes

This method puts n_samples and seed into the stage configuration data, which makes them available to other methods.

It then calls the run method, which must be defined by a subclass.

Finally, the DataHandle associated to the output tag is returned.

class rail.creation.engine.Modeler(args, comm=None)[source]

Bases: RailStage

Base class for creating a model of redshift and photometry.

config_options = {'output_mode': <ceci.config.StageParameter object>, 'seed': 12345}
fit_model()[source]

Produce a creation model from which photometry and redshifts can be generated.

Parameters:

approach!] ([The parameters depend entirely on the modeling) –

Returns:

  • [This will definitely be a file, but the filetype and format depend

  • entirely on the modeling approach!]

inputs = [('input', <class 'rail.core.data.DataHandle'>)]
name = 'Modeler'
outputs = [('model', <class 'rail.core.data.ModelHandle'>)]
class rail.creation.engine.PosteriorCalculator(args, comm=None)[source]

Bases: RailStage

Base class for object that calculates the posterior distribution of a particular field in a table of photometric data (typically the redshift).

The posteriors will be contained in a qp Ensemble.

config_options = {'column': <class 'str'>, 'output_mode': <ceci.config.StageParameter object>}
get_posterior(input_data, **kwargs) <MagicMock name='mock.Ensemble' id='140457749595184'>[source]

Return posteriors for the given column.

This is a method for running a Creator in interactive mode. In pipeline mode, the subclass run method will be called by itself.

Parameters:

data (table-like) – A table of the galaxies for which posteriors are calculated

Notes

This will put the data argument input this Stages the DataStore using this stages input tag.

This will put the additional functional arguments into this Stages configuration data.

It will then call self.run() and return the DataHandle associated to the output tag.

inputs = [('model', <class 'rail.core.data.ModelHandle'>), ('input', <class 'rail.core.data.TableHandle'>)]
name = 'PosteriorCalculator'
open_model(**kwargs)[source]

Load the model and/or attach it to this PosteriorCalculator.

Keywords

modelobject, str or ModelHandle

Either an object with a trained model, a path pointing to a file that can be read to obtain the trained model, or a ModelHandle providing access to the trained model

returns:

self.model – The object encapsulating the trained model

rtype:

object

outputs = [('output', <class 'rail.core.data.QPHandle'>)]