astromodels.core.model module
- class astromodels.core.model.Model(*sources)[source]
Bases:
Node
- add_external_parameter(parameter: Parameter) None [source]
Add a parameter that comes from something other than a function, to the model.
- Parameters
parameter – a Parameter instance
- Returns
none
- add_independent_variable(variable: IndependentVariable) None [source]
Add a global independent variable to this model, such as time.
- Parameters
variable – an IndependentVariable instance
- Returns
none
- add_source(new_source: Union[PointSource, ExtendedSource, ParticleSource]) None [source]
Add the provided source to the model
- Parameters
new_source – the new source to be added (an instance of PointSource, ExtendedSource or ParticleSource)
- Returns
(none)
- display(complete: bool = False) None [source]
Display information about the point source.
:param complete : if True, displays also information on fixed parameters :return: (none)
- property extended_sources: Dict[str, ExtendedSource]
Returns the dictionary of all defined extended sources
- Returns
collections.OrderedDict()
- property free_parameters: Dict[str, Parameter]
Get a dictionary with all the free parameters in this model
- Returns
dictionary of free parameters
- get_extended_source_fluxes(id: int, j2000_ra: float, j2000_dec: float, energies: ndarray) ndarray [source]
Get the flux of the id-th extended sources at the given position at the given energies
- Parameters
id – id of the source
j2000_ra – R.A. where the flux is desired
j2000_dec – Dec. where the flux is desired
energies – energies at which the flux is desired
- Returns
flux array
- get_extended_source_name(id: int) str [source]
Return the name of the n-th extended source
- Parameters
id – id of the source (integer)
- Returns
the name of the id-th source
- get_number_of_extended_sources() int [source]
Return the number of extended sources
- Returns
number of extended sources
- get_number_of_particle_sources() int [source]
Return the number of particle sources
- Returns
number of particle sources
- get_number_of_point_sources() int [source]
Return the number of point sources
- Returns
number of point sources
- get_particle_source_fluxes(id: int, energies: ndarray) ndarray [source]
Get the fluxes from the id-th point source
- Parameters
id – id of the source
energies – energies at which you need the flux
- Returns
fluxes
- get_point_source_fluxes(id: int, energies: ndarray, tag=None) ndarray [source]
Get the fluxes from the id-th point source
- Parameters
id – id of the source
energies – energies at which you need the flux
tag – a tuple (integration variable, a, b) specifying the integration to perform. If this
parameter is specified then the returned value will be the average flux for the source computed as the integral between a and b over the integration variable divided by (b-a). The integration variable must be an independent variable contained in the model. If b is None, then instead of integrating the integration variable will be set to a and the model evaluated in a. :return: fluxes
- get_point_source_position(id) Tuple[float] [source]
Get the point source position (R.A., Dec)
- Parameters
id – id of the source
- Returns
a tuple with R.A. and Dec.
- get_total_flux(energies: ndarray) float [source]
Returns the total differential flux at the provided energies from all point sources
- Returns
- link(parameter_1, parameter_2, link_function=None) None [source]
Link the value of the provided parameters through the provided function (identity is the default, i.e., parameter_1 = parameter_2).
- Parameters
parameter_1 – the first parameter;can be either a single parameter or a list of prarameters
parameter_2 – the second parameter
link_function – a function instance. If not provided, the identity function will be used by default.
Otherwise, this link will be set: parameter_1 = link_function(parameter_2) :return: (none)
- property linked_functions: List[_LinkedFunctionContainer]
return a list of containers for the linked functions
- property linked_parameters: Dict[str, Parameter]
Get a dictionary with all parameters in this model in a linked status. A parameter is in a linked status if it is linked to another parameter (i.e. it is forced to have the same value of the other parameter), or if it is linked with another parameter or an independent variable through a law.
- Returns
dictionary of linked parameters
- property parameters: Dict[str, Parameter]
Return a dictionary with all parameters
- Returns
dictionary of parameters
- property particle_sources: Dict[str, ParticleSource]
Returns the dictionary of all defined particle sources
- Returns
collections.OrderedDict()
- property point_sources: Dict[str, PointSource]
Returns the dictionary of all defined point sources
- Returns
collections.OrderedDict()
- property properties: Dict[str, Parameter]
Return a dictionary with all parameters
- Returns
dictionary of parameters
- remove_external_parameter(parameter_name: str) None [source]
Remove an external parameter which was added with add_external_parameter
- Parameters
variable_name – name of parameter to remove
- Returns
- remove_independent_variable(variable_name: str) None [source]
Remove an independent variable which was added with add_independent_variable
- Parameters
variable_name – name of variable to remove
- Returns
- remove_source(source_name: str) None [source]
Returns a new model with the provided source removed from the current model. Any parameters linked to the source to be removed are automatically unlinked.
- Parameters
source_name – the name of the source to be removed
- Returns
a new Model instance without the source
- set_free_parameters(values: Iterable[float]) None [source]
Set the free parameters in the model to the provided values.
NOTE: of course, order matters
- Parameters
values – a list of new values
- Returns
None
- property sources: Dict[str, Union[PointSource, ExtendedSource, ParticleSource]]
Returns a dictionary containing all defined sources (of any kind)
- Returns
collections.OrderedDict()
- unlink(parameter: Parameter) None [source]
Sets free one or more parameters which have been linked previously
- Parameters
parameter – the parameter to be set free, can also be a list of parameters
- Returns
(none)
- unlink_all_from_source(source_name: str, warn: bool = False) None [source]
Unlink all parameters of the current model that are linked to a parameter of a given source. To be called before removing a source from the model.
- Parameters
source_name – the name of the source to which to remove all links
warn – If True, prints a warning if any parameters were unlinked.