lightcurvelynx.models.multi_object_model
Multiple object models wrap multiple BasePhysicalModels, allowing the user to define such operations as additive models, where each object contributes to the total flux density, or random object models, where only one object is selected at random for each flux calculation.
Classes
A MultiObjectModel wraps multiple BasePhysicalModels (including BandfluxModels). |
|
An AdditiveMultiObjectModel computes the flux from multiple overlapping objects, |
|
A RandomMultiObjectModel selects one of its objects at random and |
Module Contents
- class MultiObjectModel(objects, **kwargs)[source]
Bases:
lightcurvelynx.models.physical_model.SEDModelA MultiObjectModel wraps multiple BasePhysicalModels (including BandfluxModels).
All rest frame effects are applied to each object, allowing different redshifts for each object (for unresolved objects). The observer frame effects are applied to the weighted sum of the objects.
While this model supports both BandfluxModels and SED, it inherits from SEDModel to pick up some of the helper functions.
Note
Each object may have its own sampled (RA, dec) position, which are not required to align.
- _is_bandflux[source]
A list of Booleans indicating whether each model is a BandfluxModel.
- Type:
list
- Parameters:
objects (list) – A list of BasePhysicalModel objects to use in the flux calculation.
**kwargs (dict, optional) – Any additional keyword arguments.
- set_graph_positions(seen_nodes=None)[source]
Force an update of the graph structure (numbering of each node).
- Parameters:
seen_nodes (set, optional) – A set of nodes that have already been processed to prevent infinite loops. Caller should not set.
- set_apply_redshift(apply_redshift)[source]
Toggles the apply_redshift setting.
- Parameters:
apply_redshift (bool) – The new value for apply_redshift.
- add_effect(effect)[source]
Add an effect to each of the submodels.
- Parameters:
effect (Effect) – The effect to add to the model.
- sample_parameters(given_args=None, num_samples=1, rng_info=None)[source]
Sample the model’s underlying parameters if they are provided by a function or ParameterizedModel.
- Parameters:
given_args (dict, optional) – A dictionary representing the given arguments for this sample run. This can be used as the JAX PyTree for differentiation.
num_samples (int) – A count of the number of samples to compute. Default: 1
rng_info (numpy.random._generator.Generator, optional) – A given numpy random number generator to use for this computation. If not provided, the function uses the node’s random number generator.
**kwargs (dict, optional) – All the keyword arguments, including the values needed to sample parameters.
- Returns:
graph_state – An object mapping graph parameters to their values.
- Return type:
- class AdditiveMultiObjectModel(objects, weights=None, **kwargs)[source]
Bases:
MultiObjectModelAn AdditiveMultiObjectModel computes the flux from multiple overlapping objects, including (host galaxy and source pairs) or unresolved sources.
All rest frame effects are applied to each model, allowing different redshifts for each model (for unresolved objects). The observer frame effects are applied to the weighted sum of the models.
Note
Each model may have its own sampled (RA, dec) position, which are not required to align.
- weights
A length N array of weights to apply to each object. If None, all objects will be weighted equally.
- Type:
numpy.ndarray, optional
- Parameters:
objects (list) – A list of BasePhysicalModel objects to use in the flux calculation.
weights (numpy.ndarray, optional) – A length N array of weights to apply to each object. If None, all objects will be weighted equally.
**kwargs (dict, optional) – Any additional keyword arguments.
- minwave(graph_state=None)[source]
Get the minimum wavelength of the model. For additive models, this is a list of minimums for each object.
Note
Wavelength extrapolation is handled by each object. So the actual wavelength’s can be evaluated outside the range of each object.
- Parameters:
graph_state (GraphState, optional) – An object mapping graph parameters to their values. If provided, the function will use the graph state to compute the minimum wavelength.
- Returns:
minwave – The minimum wavelength of the each object (in angstroms) or None
- Return type:
list of float or None
- maxwave(graph_state=None)[source]
Get the maximum wavelength of the model. For additive models, this is a list of maximums for each object.
Note
Wavelength extrapolation is handled by each object. So the actual wavelength’s can be evaluated outside the range of each object.
- Parameters:
graph_state (GraphState, optional) – An object mapping graph parameters to their values. If provided, the function will use the graph state to compute the maximum wavelength.
- Returns:
maxwave – The maximum wavelength of the each object (in angstroms) or None
- Return type:
list of float or None
- class RandomMultiObjectModel(objects, weights=None, object_names=None, **kwargs)[source]
Bases:
MultiObjectModelA RandomMultiObjectModel selects one of its objects at random and computes the flux from that object.
- object_map[source]
A dictionary mapping each object name (or index) to a BasePhysicalModel object.
- Type:
dict
- Parameters:
objects (list) – A list of BasePhysicalModel objects to use in the flux calculation.
weights (numpy.ndarray, optional) – A length N array indicating the relative weight from which to select a object at random. If None, all objects will be weighted equally.
**kwargs (dict, optional) – Any additional keyword arguments.
- minwave(graph_state=None)[source]
Get the minimum wavelength of the model.
- Parameters:
graph_state (GraphState, optional) – An object mapping graph parameters to their values. If provided, the function will use the graph state to compute the minimum wavelength.
- Returns:
minwave – The minimum wavelength of the model (in angstroms) or None if the model does not have a defined minimum wavelength.
- Return type:
float or None
- maxwave(graph_state=None)[source]
Get the maximum wavelength of the model.
- Parameters:
graph_state (GraphState, optional) – An object mapping graph parameters to their values. If provided, the function will use the graph state to compute the maximum wavelength.
- Returns:
maxwave – The maximum wavelength of the model (in angstroms) or None if the model does not have a defined maximum wavelength.
- Return type:
float or None