pint.models.parameter.Parameter
- class pint.models.parameter.Parameter(name=None, value=None, units=None, description=None, uncertainty=None, frozen=True, aliases=None, continuous=True, prior=<pint.models.priors.Prior object>, use_alias=None, parent=None)[source]
Bases:
object
A single timing model parameter.
Subclasses of this class can represent parameters of various types. They can record units, a description of the parameter’s meaning, a default value in some cases, whether the parameter has ever been set, and they can keep track of whether a parameter is to be fit or not.
Parameters can also come in families, either in the form of numbered
prefixParameter
or with associated selection criteria in the form ofmaskParameter
.A parameter’s current value will be stored at
.quantity
, which will have associated units (astropy.quantity.Quantity
) or other special type machinery, or can also be accessed through.value
, which provides the raw value (stripped of units if applicable). Both of these can be assigned to to change the parameter’s value. If the parameter has units, they will be accessible through the.units
property (anastropy.units.Unit
). A parameter that has not been set will have the value None.Parameters also support uncertainties; these are available including units through the
.uncertainty
attribute. Parameters can also be set as.frozen=True
to indicate that they should not be modified as part of a fit.- Parameters:
name (str, optional) – The name of the parameter.
value (number, str, astropy.units.Quantity, or other data type or object) – The input parameter value. Quantities are accepted here, but when the corresponding property is read the value will never have units.
units (str or astropy.units.Unit, optional) – Parameter default unit. Parameter .value and .uncertainty_value attribute will associate with the default units.
description (str, optional) – A short description of what this parameter means.
uncertainty (float) – Current uncertainty of the value.
frozen (bool, optional) – A flag specifying whether
Fitter
objects should adjust the value of this parameter or leave it fixed.aliases (list, optional) – An optional list of strings specifying alternate names that can also be accepted for this parameter.
continuous (bool, optional) – A flag specifying whether derivatives with respect to this parameter exist.
use_alias (str or None) – Alias to use on write; normally whatever alias was in the par file it was read from
parent (pint.models.timing_model.Component, optional) – The parent timing model component
- Variables:
quantity (astropy.units.Quantity or astropy.time.Time or bool or int) – The parameter’s value
Methods
add_alias
(alias)Add a name to the list of aliases for this parameter.
as_latex
()as_parfile_line
([format])Return a parfile line giving the current state of the parameter.
from_parfile_line
(line)Parse a parfile line into the current state of the parameter.
Return a help line containing parameter name, description and units.
name_matches
(name)Whether or not the parameter name matches the provided name
prior_pdf
([value, logpdf])Return the prior probability density.
set
(value)Deprecated - just assign to .value.
str_quantity
(quan)Format the argument in an appropriate way as a string.
value_as_latex
()Attributes
prior distribution for this parameter.
Value including units (if appropriate).
repeatable
Parameter uncertainty value with units.
Return a pure value from .uncertainty.
Units associated with this parameter.
Return the value (without units) of a parameter.
- property quantity
Value including units (if appropriate).
- property value
Return the value (without units) of a parameter.
This value is assumed to be in units of
self.units
. Upon setting, a aQuantity
can be provided, which will be converted toself.units
.
- property units
Units associated with this parameter.
Should be a
astropy.units.Unit
object, or None if never set.
- property uncertainty
Parameter uncertainty value with units.
- property uncertainty_value
Return a pure value from .uncertainty.
This will be interpreted as having units
self.units
.
- property prior
prior distribution for this parameter.
This should be a
Prior
object describing the prior distribution of the quantity, for use in Bayesian fitting.
- prior_pdf(value=None, logpdf=False)[source]
Return the prior probability density.
Evaluated at the current value of the parameter, or at a proposed value.
- Parameters:
value (array-like or float, optional) – Where to evaluate the priors; should be a unitless number. If not provided the prior is evaluated at
self.value
.logpdf (bool) – If True, return the logarithm of the PDF instead of the PDF; this can help with densities too small to represent in floating-point.
- as_parfile_line(format='pint')[source]
Return a parfile line giving the current state of the parameter.
- Parameters:
format (str, optional) – Parfile output format. PINT outputs in ‘tempo’, ‘tempo2’ and ‘pint’ formats. The default format is pint.
- Return type:
Notes
Format differences between tempo, tempo2, and pint at [1]