astromodels.functions.function module
- class astromodels.functions.function.CompositeFunction(operation, function_or_scalar_1, function_or_scalar_2=None)[source]
Bases:
Function
- property expression
- fast_call(x)
Call self as a function.
- property functions
A list containing the function used to build this composite function
- class astromodels.functions.function.Function(name: str | None = None, function_definition: str | None = None, parameters: Dict[str, Parameter] | None = None, properties: Dict[str, FunctionProperty] | None = None)[source]
Bases:
Node
Generic Function class. Will be subclassed in Function1D, Function2D and Function3D.
- property description: str
Returns a description for this function
- duplicate()[source]
Create a copy of the current function with all the parameters equal to the current value
- Returns:
a new copy of the function
- evaluate_at(*args, **parameter_specification)[source]
Evaluate the function at the given x(,y,z) for the provided parameters, explicitly provided as part of the parameter_specification keywords.
- Parameters:
*args –
**parameter_specification –
- Returns:
- property external_functions
- property fixed_units
Returns the fixed units if has_fixed_units is True (see has_fixed_units)
- Returns:
None, or a tuple (x_unit, y_unit)
- property free_parameters: Dict[str, Parameter]
Returns a dictionary of free parameters for this function
- Returns:
dictionary of free parameters
- get_boundaries()[source]
Returns the boundaries of this function. By default there is no boundary, but subclasses can override this.
- Returns:
a tuple of tuples containing the boundaries for each coordinate (ra_min, ra_max), (dec_min, dec_max)
- get_total_spatial_integral(z)[source]
Returns the total integral (for 2D functions) or the integral over the spatial components (for 3D functions). needs to be implemented in subclasses.
- Returns:
an array of values of the integral (same dimension as z).
- has_fixed_units() bool [source]
Returns True if this function cannot change units, which is the case only for very specific functions (like models from foreign libraries like Xspec)
- Returns:
True or False
- property has_free_parameters: bool
Returns True or False depending on if any parameters are free
- property has_properties: bool
- property is_prior: bool
Returns False by default and must be overrided in the prior functions.
- Returns:
True or False
- property latex
Returns the LaTEX formula for this function
- link_external_function(function: Function, internal_name: str)[source]
link and external function to this function for use in its evaluate method. the function can be from another source
the linked function can be accessed via self.external_functions[internal_name]
- Parameters:
function ("Function") – the function to link.
internal_name (str) – the internal name used to access this in the external_functions dict
- Returns:
- property n_dim: int
number of dimensions for this function (1, 2 or 3)
- Type:
return
- of(another_function)[source]
Compose this function with another as in this_function(another_function(x)) :param another_function: another function to compose with the current one :return: a composite function instance
- property properties: Dict[str, FunctionProperty] | None
return the properties of the function
- Returns:
- unlink_external_function(internal_name: str)[source]
unlink an external function
- Parameters:
internal_name (str)
- Returns:
- property uuid
Returns the ID of the current function. The ID is used by the CompositeFunction class to keep track of the unique instances of each function. It should not be used by the user for any specific purpose.
- Returns:
(none)
- class astromodels.functions.function.Function1D(name: str | None = None, function_definition: str | None = None, parameters: Dict[str, Parameter] | None = None, properties: Dict[str, FunctionProperty] | None = None)[source]
Bases:
Function
- get_boundaries()[source]
Returns the boundaries of this function. By default there is no boundary, but subclasses can override this.
- Returns:
a tuple of tuples containing the boundaries for each coordinate (ra_min, ra_max), (dec_min, dec_max)
- local_spectral_index(x, epsilon=1e-05)[source]
compute the local spectral index of the model at a given set of energies
- Parameters:
x
epsilon
- Returns:
- property x_unit
The unit of the independent variable :return: a astropy.Unit instance
- property y_unit: Unit
The unit of the dependent variable :return: a astropy.Unit instance
- class astromodels.functions.function.Function2D(name: str | None = None, function_definition: str | None = None, parameters: Dict[str, Parameter] | None = None, properties: Dict[str, FunctionProperty] | None = None)[source]
Bases:
Function
- property x_unit
- property y_unit
- property z_unit
- class astromodels.functions.function.Function3D(name: str | None = None, function_definition: str | None = None, parameters: Dict[str, Parameter] | None = None, properties: Dict[str, FunctionProperty] | None = None)[source]
Bases:
Function
- property w_unit
- property x_unit
- property y_unit
- property z_unit
- class astromodels.functions.function.FunctionMeta(name, bases, dct)[source]
Bases:
type
A metaclass for the models, which takes care of setting up the parameters and the other attributes according to the definition given in the documentation of the function class.
- static check_calling_sequence(name, function_name, function, possible_variables)[source]
Check the calling sequence for the function looking for the variables specified. One or more of the variables can be in the calling sequence. Note that the order of the variables will be enforced. It will also enforce that the first parameter in the calling sequence is called ‘self’.
- Parameters:
function – the function to check
possible_variables – a list of variables to check, The order is important, and will be enforced
- Returns:
a tuple containing the list of found variables, and the name of the other parameters in the calling
sequence
- static parse_property_definition(func_name, prop_name, definition) FunctionProperty [source]
- astromodels.functions.function.get_function(function_name, composite_function_expression=None)[source]
Returns the function “name”, which must be among the known functions or a composite function.
- Parameters:
function_name – the name of the function (use ‘composite’ if the function is a composite function)
composite_function_expression – composite function specification such as
((((powerlaw{1} + (sin{2} * 3)) + (sin{2} * 25)) - (powerlaw{1} * 16)) + (sin{2} ** 3.0)) :return: the an instance of the requested class