pint.models.model_builder.ModelBuilder
- class pint.models.model_builder.ModelBuilder[source]
Bases:
objectClass for building a TimingModel object from a parameter file.
The ModelBuilder class helps building a TimingModel from a parameter file (i.e., pulsar ephemeris or ‘.par’ file). It first maps the provided parameter names to the PINT defined parameter names, if they are in the PINT parameter aliases list. Then, the ModelBuilder selects model components based on the following rules:
The components in the
default_componentslist will be selected.When a component get mapped uniquely by the given parameters.
The pulsar binary component will be selected by the ‘BINARY’ parameter.
Methods
choose_model(param_inpar)Choose the model components based on the parfile.
- __call__(parfile, allow_name_mixing=False, allow_tcb=False, toas_for_tzr=None, **kwargs)[source]
Callable object for making a timing model from .par file.
- Parameters:
parfile (str or file-like object) – Input .par file name or string contents
allow_name_mixing (bool, optional) – Flag for allowing the input to have mixing aliases names for the same parameter. For example, if this flag is true, one can have T2EFAC and EFAC, both of them maps to PINT parameter EFAC, present in the parfile at the same time.
allow_tcb (True, False, or "raw", optional) – Whether to read TCB par files. Default is False, and will throw an error upon encountering TCB par files. If True, the par file will be converted to TDB upon read. If “raw”, an unconverted malformed TCB TimingModel object will be returned.
toas_for_tzr (TOAs or None, optional) – If this is not None, a TZR TOA (AbsPhase) will be created using the given TOAs object.
kwargs (dict) – Any additional parameter/value pairs that will add to or override those in the parfile.
- Returns:
The result timing model based on the input .parfile or file object.
- Return type:
- choose_model(param_inpar)[source]
Choose the model components based on the parfile.
- Parameters:
param_inpar (dict) – Dictionary of the unique parameters in .par file with the key is the parfile line.
parse_parfile()returns this dictionary.- Returns:
list – List of selected components.
dict – Conflict components dictionary, where the key the component name, the value is a list of component names that are conflicted with the components in the key.
list – A list of parameters that are in the .parfile but not in the PINT defined parameters.
Note
- The selection algorithm:
Look at the BINARY in the par file and cache the indicated binary model
Translate para file parameters to the pint parameter name
Go over the parameter-component map and pick up the components based on the parameters in parfile.
Select the components that have its unique parameters in the parfile. In other words, select the components that have one parameter to on component mapping.
Log the conflict components, one parameter to multiple components mapping.