popsynth.auxiliary_sampler module
- class popsynth.auxiliary_sampler.SecondaryContainer(name: str, true_values: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], obs_values: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], selection: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], probability: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]])[source]
Bases:
object
- __init__(name: str, true_values: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], obs_values: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], selection: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], probability: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) None [source]
A container for secondary properties that adds dict and dictionary access
- Parameters
name (str) – the name of the secondary
true_values (ArrayLike) –
obs_values (ArrayLike) –
selection (ArrayLike) –
probability (ArrayLike) –
- Returns
- Returns
- property name: str
- property true_values: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]
The true (latent) values of the sampler
- Returns
- property obs_values: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]
The observed values of the sampler
- Returns
- property selection: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]
The the slection of the values
- Returns
- property probability: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]
The the probability of the draws
- Returns
- class popsynth.auxiliary_sampler.SecondaryStorage[source]
Bases:
DotMap
- add_secondary(secondary_values: SecondaryContainer) None [source]
Add on a new secondary
- Parameters
secondary_values (SecondaryContainer) –
- Returns
- class popsynth.auxiliary_sampler.AuxiliaryParameter(default: Optional[float] = None, vmin: Optional[float] = None, vmax: Optional[float] = None, free: bool = True, is_normalization: bool = False)[source]
Bases:
Parameter
- class popsynth.auxiliary_sampler.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
- set_luminosity(luminosity: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) None [source]
Set the luminosity values.
- Parameters
luminosity (ArrayLike) – Luminosity
- set_spatial_values(value: SpatialContainer) None [source]
Set the spatial values.
- Parameters
value (
SpatialContainer
) – Spatial values
- set_selection_probability(selector: SelectionProbability) None [source]
Set a selection probabilty for this sampler.
- Parameters
selector (SelectionProbability) – A selection probability oobject
- Returns
- set_secondary_sampler(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
- 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
- property probability: ndarray
- make_secondary(parent_name: str) None [source]
sets this sampler as secondary for book keeping
- Parameters
parent_name (str) –
- Returns
- get_secondary_properties(graph=None, primary=None, spatial_distribution=None) SecondaryStorage [source]
Get properties of secondary samplers.
- Parameters
graph – Graph
primary – Primary sampler
spatial_distribution – Spatial Distribution
- Returns
Dict of samplers
- Return type
SamplerDict
- 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]
- property secondary_samplers: Dict[str, Dict[str, Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]]]
Secondary samplers. :returns: Dict of secondary samplers :rtype:
SamplerDict
- property is_secondary: bool
If another sampler depends on this
- Returns
- property parents: List[str]
The parents of this sampler
- property has_secondary: bool
if this sampler has a secondary :returns:
- property observed: bool
if this sampler is observed
- Returns
- property name: str
The name of the sampler
- Returns
- property obs_name: str
- property true_values: ndarray
The true or latent values
- Returns
- property obs_values: ndarray
The values obscured by measurement error.
- Returns
- property selection: ndarray
The selection booleans on the values
- Returns
- property selector: SelectionProbability
The selection probability object
- Returns
- property truth: Dict[str, float]
A dictionary containing true paramters used to simulate the distribution
- property uses_distance: bool
If this uses distance
- Returns
- property uses_sky_position: bool
If this uses sky position
- Returns
- property uses_luminosity: ndarray
If this uses luminosity
- Returns
- property luminosity_distance
luminosity distance if needed.
- class popsynth.auxiliary_sampler.NonObservedAuxSampler(name: str, uses_distance: bool = False, uses_luminosity: bool = False)[source]
Bases:
AuxiliarySampler
- __init__(name: str, uses_distance: bool = False, uses_luminosity: bool = False)[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
- class popsynth.auxiliary_sampler.DerivedLumAuxSampler(name: str, uses_distance: bool = False)[source]
Bases:
AuxiliarySampler