Skip to main content
`Ctrl`+`K`

# Parameter

class astropy.modeling.Parameter(name='', description='', default=None, unit=None, getter=None, setter=None, fixed=False, tied=False, min=None, max=None, bounds=None, prior=None, posterior=None, mag=False)

  Bases: `object`

  Wraps individual parameters.

  Since 4.0 Parameters are no longer descriptors and are based on a new implementation of the Parameter class. Parameters now (as of 4.0) store values locally (as instead previously in the associated model)

  This class represents a model’s parameter (in a somewhat broad sense). It serves a number of purposes:

  1. A type to be recognized by models and treated specially at class initialization (i.e., if it is found that there is a class definition of a Parameter, the model initializer makes a copy at the instance level).

  2. Managing the handling of allowable parameter values and once defined, ensuring updates are consistent with the Parameter definition. This includes the optional use of units and quantities as well as transforming values to an internally consistent representation (e.g., from degrees to radians through the use of getters and setters).

  3. Holding attributes of parameters relevant to fitting, such as whether the parameter may be varied in fitting, or whether there are constraints that must be satisfied.

  See Parameters for more details.

  Parameters:
    name `python:str`

      parameter name

      Warning

      The fact that `Parameter` accepts `name` as an argument is an implementation detail, and should not be used directly. When defining a new `Model` class, parameter names are always automatically defined by the class attribute they’re assigned to.

    description `python:str`

      parameter description

    default `python:float` or `array`

      default value to use for this parameter

    unit `Unit`

      if specified, the parameter will be in these units, and when the parameter is updated in future, it should be set to a `Quantity` that has equivalent units.

    getter `python:callable()` or `None`, optional

      A function that wraps the raw (internal) value of the parameter when returning the value through the parameter proxy (e.g., a parameter may be stored internally as radians but returned to the user as degrees). The internal value is what is used for computations while the proxy value is what users will interact with (passing and viewing). If `getter` is not `None`, then a `setter` must also be input.

    setter `python:callable()` or `None`, optional

      A function that wraps any values assigned to this parameter; should be the inverse of `getter`. If `setter` is not `None`, then a `getter` must also be input.

    fixed bool

      if True the parameter is not varied during fitting

    tied `python:callable()` or `python:False`

      if callable is supplied it provides a way to link the value of this parameter to another parameter (or some other arbitrary function)

    min `python:float`

      the lower bound of a parameter

    max `python:float`

      the upper bound of a parameter

    bounds `python:tuple`

      specify min and max as a single tuple–bounds may not be specified simultaneously with min or max

    mag bool

      Specify if the unit of the parameter can be a Magnitude unit or not

  Attributes Summary

  `bounds` | The minimum and maximum values of a parameter as a tuple.
  `constraints` | Types of constraints a parameter can have.
  `default` | Parameter default value.
  `fixed` | Boolean indicating if the parameter is kept fixed during fitting.
  `input_unit` | Unit for the input value.
  `internal_unit` | Return the internal unit the parameter uses for the internal value stored.
  `max` | A value used as an upper bound when fitting a parameter.
  `min` | A value used as a lower bound when fitting a parameter.
  `model` | Return the model this parameter is associated with.
  `name` | Parameter name.
  `posterior` |
  `prior` |
  `quantity` | This parameter, as a `Quantity` instance.
  `shape` | The shape of this parameter's value array.
  `size` | The size of this parameter's value array.
  `std` | Standard deviation, if available from fit.
  `tied` | Indicates that this parameter is linked to another one.
  `unit` | The unit attached to this parameter, if any.
  `validator` | Used as a decorator to set the validator method for a `Parameter`.
  `value` | The unadorned value proxied by this parameter.

  Methods Summary

  `copy`([name, description, default, unit, ...]) | Make a copy of this `Parameter`, overriding any of its core attributes in the process (or an exact copy).
  `validate`(value) | Run the validator on this parameter.

  Attributes Documentation

  bounds

    The minimum and maximum values of a parameter as a tuple.

  constraints = ('fixed', 'tied', 'bounds')

    Types of constraints a parameter can have. Excludes ‘min’ and ‘max’ which are just aliases for the first and second elements of the ‘bounds’ constraint (which is represented as a 2-tuple). ‘prior’ and ‘posterior’ are available for use by user fitters but are not used by any built-in fitters as of this writing.

  default

    Parameter default value.

  fixed

    Boolean indicating if the parameter is kept fixed during fitting.

  input_unit

    Unit for the input value.

  internal_unit

    Return the internal unit the parameter uses for the internal value stored.

  max

    A value used as an upper bound when fitting a parameter.

  min

    A value used as a lower bound when fitting a parameter.

  model

    Return the model this parameter is associated with.

  name

    Parameter name.

  posterior
  prior
  quantity

    This parameter, as a `Quantity` instance.

  shape

    The shape of this parameter’s value array.

  size

    The size of this parameter’s value array.

  std

    Standard deviation, if available from fit.

  tied

    Indicates that this parameter is linked to another one.

    A callable which provides the relationship of the two parameters.

  unit

    The unit attached to this parameter, if any.

    On unbound parameters (i.e. parameters accessed through the model class, rather than a model instance) this is the required/ default unit for the parameter.

  validator

    Used as a decorator to set the validator method for a `Parameter`. The validator method validates any value set for that parameter. It takes two arguments–`self`, which refers to the `Model` instance (remember, this is a method defined on a `Model`), and the value being set for this parameter. The validator method’s return value is ignored, but it may raise an exception if the value set on the parameter is invalid (typically an `InputParameterError` should be raised, though this is not currently a requirement).

    Note: Using this method as a decorator will cause problems with pickling the model. An alternative is to assign the actual validator function to `Parameter._validator` (see examples in modeling).

  value

    The unadorned value proxied by this parameter.

  Methods Documentation

  copy(name=None, description=None, default=None, unit=None, getter=None, setter=None, fixed=False, tied=False, min=None, max=None, bounds=None, prior=None, posterior=None)

    Make a copy of this `Parameter`, overriding any of its core attributes in the process (or an exact copy).

    The arguments to this method are the same as those for the `Parameter` initializer. This simply returns a new `Parameter` instance with any or all of the attributes overridden, and so returns the equivalent of:

        Parameter(self.name, self.description, ...)

  validate(value)

    Run the validator on this parameter.