popsynth package

Subpackages

Module contents

class popsynth.AuxiliarySampler(name: str, observed: bool = True, uses_distance: bool = False, uses_luminosity: bool = False, uses_sky_position: bool = False)[source]

Bases: object

__init__(name: str, observed: bool = True, uses_distance: bool = False, uses_luminosity: bool = False, uses_sky_position: bool = False) → None[source]

Base class for auxiliary samplers.

Parameters:
  • name (str) – Name of the sampler
  • observed (bool) – True if the property is observed, False if it is latent. Defaults to True
  • uses_distance (bool) – True if sampler uses distance values
  • uses_luminosity (bool) – True if sampler uses luminosities
  • uses_sky_position (bool) – True if sampler uses sky positions
display()[source]
draw(size: int = 1)[source]

Draw the primary and secondary samplers. This is the main call.

Parameters:size (int) – The number of samples to draw
get_secondary_objects(recursive_secondaries: Optional[Dict[str, Any]] = None) → Dict[str, Any][source]

Get secondary objects.

Parameters:recursive_secondaries – Recursive dict of secondaries
Returns:Dict of objects
Return type:Dict[str, Any]
get_secondary_properties(graph=None, primary=None, spatial_distribution=None) → popsynth.auxiliary_sampler.SecondaryStorage[source]

Get properties of secondary samplers.

Parameters:
  • graph – Graph
  • primary – Primary sampler
  • spatial_distribution – Spatial Distribution
Returns:

Dict of samplers

Return type:

SamplerDict

has_secondary

if this sampler has a secondary :returns:

is_secondary

If another sampler depends on this

Returns:
luminosity_distance

luminosity distance if needed.

make_secondary(parent_name: str) → None[source]

sets this sampler as secondary for book keeping

Parameters:parent_name (str) –
Returns:
name

The name of the sampler

Returns:
obs_name
obs_values

The values obscured by measurement error.

Returns:
observation_sampler(size: int = 1) → numpy.ndarray[source]
observed

if this sampler is observed

Returns:
parents

The parents of this sampler

reset()[source]

Reset all the selections.

secondary_samplers

Secondary samplers. :returns: Dict of secondary samplers :rtype: SamplerDict

selection

The selection booleans on the values

Returns:
selector

The selection probability object

Returns:
set_luminosity(luminosity: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]]) → None[source]

Set the luminosity values.

Parameters:luminosity (ArrayLike) – Luminosity
set_secondary_sampler(sampler: popsynth.auxiliary_sampler.AuxiliarySampler) → None[source]

Add a secondary sampler upon which this sampler will depend. The sampled values can be accessed via an internal dictionary with the samplers ‘name’

self._secondary_sampler[‘name’].true_values self._secondary_sampler[‘name’].obs_values

Parameters:sampler ("AuxiliarySampler") – An auxiliary sampler
Returns:
set_selection_probability(selector: popsynth.selection_probability.selection_probability.SelectionProbability) → None[source]

Set a selection probabilty for this sampler.

Parameters:selector (SelectionProbability) – A selection probability oobject
Returns:
set_spatial_values(value: popsynth.distribution.SpatialContainer) → None[source]

Set the spatial values.

Parameters:value (SpatialContainer) – Spatial values
true_sampler(size: int = 1)[source]
true_values

The true or latent values

Returns:
truth

A dictionary containing true paramters used to simulate the distribution

uses_distance

If this uses distance

Returns:
uses_luminosity

If this uses luminosity

Returns:
uses_sky_position

If this uses sky position

Returns:
class popsynth.DerivedLumAuxSampler(name: str, uses_distance: bool = False)[source]

Bases: popsynth.auxiliary_sampler.AuxiliarySampler

__init__(name: str, uses_distance: bool = False)[source]

Base class for generating luminosity from other properties.

Parameters:
  • name (str) – Name of the sampler
  • uses_distance (bool) – True if sampler uses distance values
compute_luminosity()[source]
class popsynth.Population(luminosities: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], distances: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], known_distances: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], known_distance_idx: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], unknown_distance_idx: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], fluxes: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], flux_obs: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], selection: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], flux_sigma: float, r_max: float, n_model: int, lf_params: Dict[str, Any], spatial_params: Optional[Dict[str, Any]] = None, model_spaces: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]], None] = None, seed: int = 1234, name: Optional[str] = None, spatial_form: Optional[Dict[str, Any]] = None, lf_form: Optional[Dict[str, Any]] = None, auxiliary_quantities: Optional[popsynth.auxiliary_sampler.SecondaryStorage] = None, truth: Dict[str, float] = {}, graph: Optional[Dict[str, Any]] = None, theta=None, phi=None, pop_synth: Optional[Dict[str, Any]] = None)[source]

Bases: object

__init__(luminosities: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], distances: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], known_distances: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], known_distance_idx: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], unknown_distance_idx: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], fluxes: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], flux_obs: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], selection: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]], flux_sigma: float, r_max: float, n_model: int, lf_params: Dict[str, Any], spatial_params: Optional[Dict[str, Any]] = None, model_spaces: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]], None] = None, seed: int = 1234, name: Optional[str] = None, spatial_form: Optional[Dict[str, Any]] = None, lf_form: Optional[Dict[str, Any]] = None, auxiliary_quantities: Optional[popsynth.auxiliary_sampler.SecondaryStorage] = None, truth: Dict[str, float] = {}, graph: Optional[Dict[str, Any]] = None, theta=None, phi=None, pop_synth: Optional[Dict[str, Any]] = None) → None[source]

A population container for all the properties of the population.

Parameters:
  • luminosities (ArrayLike) – The luminosities
  • distances (ArrayLike) – The distances
  • known_distances (ArrayLike) – The known distances
  • known_distance_idx (ArrayLike) – The index of the known distances
  • unknown_distance_idx (ArrayLike) – The index of the unknown distances
  • fluxes (ArrayLike) – The latent fluxes
  • flux_obs (ArrayLike) – The observed fluxes
  • selection (ArrayLike) – The selection vector
  • flux_sigma (float) – The uncertainty on the observed flux
  • r_max (float) – The maximum distance of the survey
  • n_model (int) – Number of models
  • lf_params (Dict[str, Any]) – Luminosity function parameters
  • spatial_params (Optional[Dict[str, Any]]) – Spatial distribution parameters
  • model_spaces (ArrayLike) – Model spaces
  • seed (int) – Random seed
  • name (str) – Name of the population
  • spatial_form (Optional[Dict[str, Any]]) – Form of the spatial distribution
  • lf_form (Optional[Dict[str, Any]]) – Form of the luminosity function
  • auxiliary_quantities (Optional[Dict[str, Any]]) – Dict of auxiliary quantities
  • truth (Dict[str, float]) – Dict of true values
  • graph (Optional[Dict[str, Any]]) – Graph of generative model
  • theta – Theta
  • phi – Phi
  • pop_synth (Optional[Dict[str, Any]]) – Population synth
addto(file_name: str, group_name: str) → None[source]

Write population to a group in an existing HDF5 file.

Parameters:
  • file_name (str) – Name of the file
  • group_name (str) – Name of the group
dec

The declination of the objects

display()[source]

Display the simulation parameters.

display_distances(ax=None)[source]

Display the distances

Parameters:ax – Axis on which to plot
display_flux_sphere(seen_cmap='Reds', unseen_cmap='Blues', distance_transform=None, use_log=False, background_color='white', **kwargs)[source]
display_fluxes(ax=None, true_color='#dec3c3', obs_color='#8F2727', arrow_color='k', with_arrows=True, **kwargs)[source]

Display the fluxes.

Parameters:
  • ax – Axis on which to plot
  • true_color – Color of true values
  • obs_color – Color of obs values
  • arrow_color – Color of arrows
  • with_arrows – If True, display arrows
display_hidden_fluxes_sphere(cmap='magma', distance_transform=None, use_log=False, background_color='white', show=True, **kwargs)[source]
display_luminosities(ax=None, true_color='#dec3c3', obs_color='#8F2727', **kwargs)[source]

Display the luminosities

Parameters:
  • ax – Axis on which to plot
  • true_color – Color of true values
  • obs_color – Color of obs values
display_obs_fluxes(ax=None, flux_color='#8F2727', **kwargs)[source]

Display the observed fluxes.

Parameters:
  • ax – Axis on which to plot
  • flux_color – Color of fluxes
display_obs_fluxes_sphere(cmap='magma', distance_transform=None, use_log=False, background_color='white', show=True, **kwargs)[source]
display_true_fluxes(ax=None, flux_color='#8F2727', **kwargs)[source]

Display the fluxes.

Parameters:
  • ax – Axis on which to plot
  • flux_color – Color of fluxes
distance_probability
distances

The distances to the objects

flux_sigma

The simulated flux sigma

fluxes_latent

The latent fluxes of the objects

fluxes_observed

All of the observed fluxes, i.e., scattered with error

classmethod from_file(file_name: str)[source]

Load a population from a file.

Parameters:file_name (str) – Name of the file
classmethod from_group(file_name: str, group_name: str)[source]

Load a population from a group in a file.

Parameters:
  • file_name (str) – Name of the file
  • group_name (str) – Name of the group
graph

The networkx graph of the population

Returns:
hard_cut
has_detections

If the population has detections

hidden_distances

The distances that are hidden by the selection

hidden_fluxes_latent

The latent fluxes that are hidden by the selection

hidden_fluxes_observed

The observed fluxes that are hidden by the selection

known_distances

The observed distances

luminosities_latent

The true luminosities of the objects. These are always latent as one cannot directly observe them.

luminosity_parameters
n_detections

The number of DETECTED objects in the population

n_non_detections

The number of NON-DETECTED objects in the population

n_objects

The number of objects in the population

phi

The phi angle of the objects

pop_synth

Dictionary population synth used to create this population

ra

The right ascension of the objects

selected_distances

The selected distances. Note, this is different than the KNOWN distances.

selected_fluxes_latent

The selected latent fluxes

selected_fluxes_observed

The selected obs fluxes

selection

The selection vector

spatial_parameters

spatial parameters

Returns:
theta

The polar angle of the objects

to_stan_data() → dict[source]

Create Stan input

to_sub_population(observed: bool = True) → popsynth.population.Population[source]

Create a population that is down selected from either the observed or unobserved population

Parameters:observed (bool) – Extract the observed or unobserved object
Returns:A new population object
Return type:Population
truth

The simulated truth parameters

writeto(file_name: str) → None[source]

Write population to an HDF5 file

Parameters:file_name (str) – Name of the file
class popsynth.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