pint.models.parameter.maskParameter
- class pint.models.parameter.maskParameter(name, index=1, key=None, key_value=[], value=None, long_double=False, units=None, description=None, uncertainty=None, frozen=True, continuous=False, aliases=[])[source]
Bases:
floatParameter
Parameter that applies to a subset of TOAs.
A maskParameter applies to a subset of the TOAs, for example JUMP specifies that their arrival times should be adjusted by the value associated with this JUMP. The criterion is based on either one of the standard fields (telescope, frequency, et cetera) or a flag; and the selection can be on an exact match or on a range.
Upon creation of a maskParameter, an index part will be added, so that the parameters can be distinguished within the
pint.models.timing_model.TimingModel
object. For example:>>> p = maskParameter(name='JUMP', index=2, key="-fe", key_value="G430") >>> p.name 'JUMP2'
The selection criterion can be one of the parameters
mjd
,freq
,name
,tel
representing the required columns of a.tim
file, or the name of a flag, starting with-
. If the selection criterion is based onmjd
orfreq
it is expected to be accompanied by a pair of values that define a range; other criteria are expected to be accompanied by a string that is matched exactly.- Parameters:
name (str) – The name of the parameter.
index (int, optional) – The index number for the prefixed parameter.
key (str, optional) – The key words/flag for the selecting TOAs
key_value (list/single value optional) – The value for key words/flags. Value can take one value as a flag value. or two value as a range. e.g.
JUMP freq 430.0 1440.0
. orJUMP -fe G430
value (float or np.longdouble, optional) – Toas/phase adjust value
long_double (bool, optional) – Set float type quantity and value in long double
units (str, optional) – Unit for the offset value
description (str, optional) – Description for the parameter
uncertainty (float or np.longdouble) – uncertainty of the parameter.
frozen (bool, optional) – A flag specifying whether “fitters” should adjust the value of this parameter or leave it fixed.
continuous (bool, optional) – Whether derivatives with respect to this parameter make sense.
aliases (list, optional) – List of aliases for parameter name.
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.
as_ufloat
([units])Return the parameter as a
uncertainties.ufloat
compare_key_value
(other_param)Compare if the key and value are the same with the other parameter.
from_parfile_line
(line)Read mask parameter line (e.g.
from_ufloat
(value[, units])Set the parameter from the value of a
uncertainties.ufloat
Return a help line containing parameter name, description and units.
name_matches
(name)Whether or not the parameter name matches the provided name
new_param
(index[, copy_all])Create a new but same style mask parameter
prior_pdf
([value, logpdf])Return the prior probability density.
select_toa_mask
(toas)Select the toas that match the mask.
set
(value)Deprecated - just assign to .value.
str_quantity
(quan)Quantity as a string (for floating-point values).
value_as_latex
()Attributes
Whether the parameter has long double precision.
prior distribution for this parameter.
Value including units (if appropriate).
repeatable
Parameter uncertainty value with units.
Return a pure value from .uncertainty.
If True, the parameter can automatically scale some values upon assignment.
Units associated with this parameter.
Return the value (without units) of a parameter.
- from_parfile_line(line)[source]
Read mask parameter line (e.g. JUMP).
- Returns:
Whether the parfile line is meaningful to this class
- Return type:
Notes
The accepted format:
NAME key key_value parameter_value NAME key key_value parameter_value fit_flag NAME key key_value parameter_value fit_flag uncertainty NAME key key_value parameter_value uncertainty NAME key key_value1 key_value2 parameter_value NAME key key_value1 key_value2 parameter_value fit_flag NAME key key_value1 key_value2 parameter_value fit_flag uncertainty NAME key key_value1 key_value2 parameter_value uncertainty
where NAME is the name for this class as reported by
self.name_matches
.
- 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]
- select_toa_mask(toas)[source]
Select the toas that match the mask.
- Parameters:
toas (
pint.toas.TOAs
) –- Returns:
An array of TOA indices selected by the mask.
- Return type:
array
- compare_key_value(other_param)[source]
Compare if the key and value are the same with the other parameter.
- Parameters:
other_param (maskParameter) – The parameter to compare.
- Returns:
If the key and value are the same, return True, otherwise False.
- Return type:
- Raises:
ValueError: – If the parameter to compare does not have ‘key’ or ‘key_value’.
- add_alias(alias)
Add a name to the list of aliases for this parameter.
- as_ufloat(units=None)
Return the parameter as a
uncertainties.ufloat
Will cast to the specified units, or the default If the uncertainty is not set will be returned as 0
- Parameters:
units (astropy.units.core.Unit, optional) – Units to cast the value
- Return type:
uncertainties.ufloat
Notes
Currently
ufloat
does not support double precision values, so some precision may be lost.
- from_ufloat(value, units=None)
Set the parameter from the value of a
uncertainties.ufloat
Will cast to the specified units, or the default If the uncertainty is 0 it will be set to
None
- Parameters:
value (uncertainties.ufloat) –
units (astropy.units.core.Unit, optional) – Units to cast the value
- help_line()
Return a help line containing parameter name, description and units.
- property long_double
Whether the parameter has long double precision.
- 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)
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.
- property quantity
Value including units (if appropriate).
- set(value)
Deprecated - just assign to .value.
- str_quantity(quan)
Quantity as a string (for floating-point values).
- 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 unit_scale
If True, the parameter can automatically scale some values upon assignment.
- property units
Units associated with this parameter.
Should be a
astropy.units.Unit
object, or None if never set.