pint.models.timing_model.AllComponents

class pint.models.timing_model.AllComponents[source]

Bases: object

A class for the components pool.

This object stores and manages the instances of component classes with class attribute .register = True. This includes the PINT built-in components and user defined components and there is no need to import the component class. This class constructs the available component instances, but without any valid parameter values (parameters are initialized when a component instance gets constructed, however, the parameter values are unknown to the components at the moment). Thus, runing .validate() function in the component instance will fail. This class is designed for helping model building and parameter seraching, not for direct data analysis.

Note

This is a low level class for managing all the components. To build a timing model, we recommend to use the subclass models.model_builder.ModelBuilder, where higher level interface are provided. If one wants to use this class directly, one has to construct the instance separately.

Methods

alias_to_pint_param(alias)

Translate a alias to a PINT parameter name.

param_to_unit(name)

Return the unit associated with a parameter

search_binary_components(system_name)

Search the pulsar binary component based on given name.

Attributes

category_component_map

A dictionary mapping category to a list of component names.

component_category_map

A dictionary mapping component name to its category name.

component_unique_params

Return the parameters that are only present in one component.

param_component_map

Return the parameter to component map.

repeatable_param

Return the repeatable parameter map.

property param_component_map

Return the parameter to component map.

This property returns the all PINT defined parameters to their host components. The parameter aliases are not included in this map. If searching the host component for a parameter alias, pleaase use alias_to_pint_param method to translate the alias to PINT parameter name first.

property repeatable_param

Return the repeatable parameter map.

property category_component_map

A dictionary mapping category to a list of component names.

Returns:

The mapping from categories to the componens belongs to the categore. The key is the categore name, and the value is a list of all the components in the categore.

Return type:

dict

property component_category_map

A dictionary mapping component name to its category name.

Returns:

The mapping from components to its categore. The key is the component name and the value is the component’s category name.

Return type:

dict

property component_unique_params

Return the parameters that are only present in one component.

Returns:

A mapping from a component name to a list of parameters are only in this component.

Return type:

dict

Note

This function only returns the PINT defined parameter name, not including the aliases.

search_binary_components(system_name)[source]

Search the pulsar binary component based on given name.

Parameters:

system_name (str) – Searching name for the pulsar binary/system

Return type:

The matching binary model component instance.

Raises:

UnknownBinaryModel – If the input binary model name does not match any PINT defined binary model.

alias_to_pint_param(alias)[source]

Translate a alias to a PINT parameter name.

This is a wrapper function over the property _param_alias_map. It also handles indexed parameters (e.g., pint.models.parameter.prefixParameter and pint.models.parameter.maskParameter) with an index beyond those currently initialized.

Parameters:

alias (str) – Alias name to be translated

Returns:

  • pint_par (str) – PINT parameter name the given alias maps to. If there is no matching PINT parameters, it will raise a UnknownParameter error.

  • first_init_par (str) – The parameter name that is first initialized in a component. If the paramere is non-indexable, it is the same as pint_par, otherwrise it returns the parameter with the first index. For example, the first_init_par for ‘T2EQUAD25’ is ‘EQUAD1’

Notes

Providing a indexable parameter without the index attached, it returns the PINT parameter with first index (i.e. 0 or 1). If with index, the function returns the matched parameter with the index provided. The index format has to match the PINT defined index format. For instance, if PINT defines a parameter using leading-zero indexing, the provided index has to use the same leading-zeros, otherwrise, returns a UnknownParameter error.

Examples

>>> from pint.models.timing_model import AllComponents
>>> ac = AllComponents()
>>> ac.alias_to_pint_param('RA')
('RAJ', 'RAJ')
>>> ac.alias_to_pint_param('T2EQUAD')
('EQUAD1', 'EQUAD1')
>>> ac.alias_to_pint_param('T2EQUAD25')
('EQUAD25', 'EQUAD1')
>>> ac.alias_to_pint_param('DMX_0020')
('DMX_0020', 'DMX_0001')
>>> ac.alias_to_pint_param('DMX20')
UnknownParameter: Can not find matching PINT parameter for 'DMX020'
param_to_unit(name)[source]

Return the unit associated with a parameter

This is a wrapper function over the property _param_unit_map. It also handles aliases and indexed parameters (e.g., pint.models.parameter.prefixParameter and pint.models.parameter.maskParameter) with an index beyond those currently initialized.

This can be used without an existing TimingModel.

Parameters:

name (str) – Name of PINT parameter or alias

Return type:

astropy.u.Unit