Bases: object
Base class for all models.
This is an abstract class and should not be instantiated directly.
This class sets the constraints and other properties for all individual parameters and performs parameter validation.
Parameters: | param_dim : int
fixed : dict
tied : dict
bounds : dict
eqcons : list
ineqcons : list
|
---|
Examples
>>> from astropy.modeling import models
>>> def tie_center(model):
... mean = 50 * model.stddev
... return mean
>>> tied_parameters = {'mean': tie_center}
Specify that 'mean' is a tied parameter in one of two ways:
>>> g1 = models.Gaussian1D(amplitude=10, mean=5, stddev=.3,
... tied=tied_parameters)
or
>>> g1 = models.Gaussian1D(amplitude=10, mean=5, stddev=.3)
>>> g1.mean.tied
False
>>> g1.mean.tied = tie_center
>>> g1.mean.tied
<function tie_center at 0x...>
Fixed parameters:
>>> g1 = models.Gaussian1D(amplitude=10, mean=5, stddev=.3,
... fixed={'stddev': True})
>>> g1.stddev.fixed
True
or
>>> g1 = models.Gaussian1D(amplitude=10, mean=5, stddev=.3)
>>> g1.stddev.fixed
False
>>> g1.stddev.fixed = True
>>> g1.stddev.fixed
True
Attributes Summary
bounds | A dict mapping parameter names to their upper and lower bounds as (min, max) tuples. |
eqcons | List of parameter equality constraints. |
fittable | bool(x) -> bool |
fixed | A dict mapping parameter names to their fixed constraint. |
ineqcons | List of parameter inequality constraints. |
input_names | list() -> new empty list |
linear | bool(x) -> bool |
model_constraints | list() -> new empty list |
model_set_axis | |
n_inputs | int(x=0) -> int or long |
n_outputs | int(x=0) -> int or long |
param_dim | Deprecated since version 0.4. |
param_names | list() -> new empty list |
param_sets | Return parameters as a pset. |
parameter_constraints | list() -> new empty list |
parameters | A flattened array of all parameter values in all parameter sets. |
standard_broadcasting | bool(x) -> bool |
tied | A dict mapping parameter names to their tied constraint. |
Methods Summary
__call__(*inputs, **kwargs) | |
add_model(model, mode) | Create a CompositeModel by chaining the current model with the new one using the specified mode. |
copy() | Return a copy of this model. |
evaluate(*args, **kwargs) | Evaluate the model on some input variables. |
inverse() | Returns a callable object which performs the inverse transform. |
invert() | Invert coordinates iteratively if possible. |
prepare_inputs(*inputs, **kwargs) | This method is used in Model.__call__ to ensure that all the inputs to the model can be broadcast into compatible shapes (if one or both of them are input as arrays), particularly if there are more than one parameter sets. |
prepare_outputs(format_info, *outputs, **kwargs) |
Attributes Documentation
List of parameter equality constraints.
List of parameter inequality constraints.
Deprecated since version 0.4: The param_dim function is deprecated and may be removed in a future version. Use len(model) instead.
List of names of the parameters that describe models of this type.
The parameters in this list are in the same order they should be passed in when initializing a model of a specific type. Some types of models, such as polynomial models, have a different number of parameters depending on some other property of the model, such as the degree.
Return parameters as a pset.
This is a list with one item per parameter set, which is an array of that parameter’s values across all parameter sets, with the last axis associated with the parameter set.
A flattened array of all parameter values in all parameter sets.
Fittable parameters maintain this list and fitters modify it.
Methods Documentation
Create a CompositeModel by chaining the current model with the new one using the specified mode.
Parameters: | model : an instance of a subclass of Model mode : string
|
---|---|
Returns: | model : CompositeModel
|
Return a copy of this model.
Uses a deep copy so that all model attributes, including parameter values, are copied as well.
Evaluate the model on some input variables.
Returns a callable object which performs the inverse transform.
Invert coordinates iteratively if possible.
This method is used in Model.__call__ to ensure that all the inputs to the model can be broadcast into compatible shapes (if one or both of them are input as arrays), particularly if there are more than one parameter sets.