popsynth.population_synth module

class popsynth.population_synth.PopulationSynth(spatial_distribution: popsynth.distribution.SpatialDistribution, luminosity_distribution: Optional[popsynth.distribution.LuminosityDistribution] = None, seed: int = 1234)[source]

Bases: object

__init__(spatial_distribution: popsynth.distribution.SpatialDistribution, luminosity_distribution: Optional[popsynth.distribution.LuminosityDistribution] = None, seed: int = 1234)[source]

Basic and generic population synth. One specifies the spatial and luminosity distribution OR derived luminosity distribution and everything is setup.

Parameters:
  • spatial_distribution (SpatialDistribution) – The spatial distribution to sample locations from
  • luminosity_distribution (LuminosityDistribution) – The optional luminosity distribution
  • seed (int) – Random seed
add_auxiliary_sampler(auxiliary_sampler: Union[popsynth.auxiliary_sampler.DerivedLumAuxSampler, popsynth.auxiliary_sampler.AuxiliarySampler])[source]

Add an auxiliary sampler or derived luminosity sampler to the population synth.

Parameters:auxiliary_sampler (Union[DerivedLumAuxSampler, AuxiliarySampler]) – The auxiliary_sampler
add_model_space(name, start, stop, log=True)[source]

Add a model space for stan generated quantities

Parameters:
  • name – Name that Stan will use
  • start – Start of the grid
  • stop – Stop of the grid
  • log – Use log10 or not
add_observed_quantity(auxiliary_sampler: Union[popsynth.auxiliary_sampler.DerivedLumAuxSampler, popsynth.auxiliary_sampler.AuxiliarySampler])[source]

Add an auxiliary sampler or derived luminosity sampler to the population synth

Parameters:auxiliary_sampler (Union[DerivedLumAuxSampler, AuxiliarySampler]) – The auxiliary_sampler
add_spatial_selector(spatial_selector: popsynth.selection_probability.selection_probability.SelectionProbability) → None[source]

Add a spatial selector into the mix

Parameters:spatial_selector (SelectionProbability) – The spatial selector
clean(reset: bool = False)[source]

Clean the auxiliary samplers, selections, etc from the population synth

Parameters:reset (bool) – If True, reset any attached distributions and samplers
display() → None[source]

Display the simulation parameters.

draw_log10_fobs(f, f_sigma, size=1) → numpy.ndarray[source]

Draw the log10 of the the fluxes.

draw_log_fobs(f, f_sigma, size=1) → numpy.ndarray[source]

Draw the log10 of the the fluxes.

draw_survey(flux_sigma: Optional[float] = None, log10_flux_draw: bool = True) → popsynth.population.Population[source]

Draw the total survey and return a Population object.

This will sample all attached distributions and apply selection functions.

If a value of flux_sigma is given, the log10 observed fluxes are sampled with measurement error.

Parameters:
  • flux_sigma (Optional[float]) – The homoskedastic sigma for the flux in log10 space
  • log10_flux_draw (bool) – if True, fluxes are drawn in log space
Returns:

a Population object

Return type:

Population

classmethod from_dict(input: Dict[str, Any]) → popsynth.population_synth.PopulationSynth[source]

Build a PopulationSynth object from a dictionary

Parameters:input (Dict[str, Any]) – the dictionary from which to build
Returns:Popsynth object
Return type:PopulationSynth
classmethod from_file(file_name: str) → popsynth.population_synth.PopulationSynth[source]

read the population in from a yaml file

Parameters:file_name – the file name of the population synth
graph
luminosity_distribution
name
set_distance_selection(selector: popsynth.selection_probability.selection_probability.SelectionProbability) → None[source]

Set the selection type for the distance.

Parameters:selector (SelectionProbability) – The selector
set_flux_selection(selector: popsynth.selection_probability.selection_probability.SelectionProbability) → None[source]

Set the selection type for the flux

Parameters:selector (SelectionProbability) – The selector
spatial_distribution
to_dict() → Dict[str, Any][source]

Convert the population synth to a dictionary

Returns:Popsynth dict
Return type:Dict[str, Any]
write_to(file_name: str) → None[source]

Write the population synth to a YAML file.

Parameters:file_name (str) – the file name of the output YAML