Reading/storing pulsar parameters#
CWInPy provides a PulsarParameters
class for reading in,
and storing, Tempo-style pulsar parameter files. The class can also be used to
construct a set of parameters for a source. This class is based on, and designed to supercede, the
PulsarParameters.py structure in LALPulsar.
- class PulsarParameters(pp=None)#
Bases:
object
A class to wrap the SWIG-wrapped
lalpulsar.PulsarParameters
structure.This class lets you access the structure in a more Pythonic way, as well as providing a nice format for holding pulsar (
.par
) parameter files.The class can be used to set numerical values (double precision, unsigned integers), strings, or vectors of floating point values, e.g.:
>>> pp = PulsarParameters() # an empty structure >>> pp['DECJ'] = 0.23 # set a numerical value >>> pp['BINARY'] = 'BT' # set a string value >>> pp['F'] = [10.2, 1.4e-11] # set a vector of float values
Examples
An example of initialising the class using a parameter file is:
>>> pppy = PulsarParameters('apulsar.par')
or, equivalently with:
>>> pppy = PulsarParameters() >>> pppy.read('apulsar.par')
- Parameters:
pp (PulsarParameters, str) – A
lalpulsar.PulsarParameters
structure, or a string giving the path to a Tempo-style (.par
) pulsar parameter file. If nothing is given then an emptyPulsarParameters
structure is created. Theread()
method can subsequently be used to read in a.par
file, or parameters can be added.
- PulsarParameters()#
Return the PulsarParameters structure
- as_dict()#
Return the contents (not error at the moment) of the structure as a dictionary
- convert_to_tempo_units(name, value, iserr=False)#
Convert from PulsarParameter units to TEMPO-par-file units
- Parameters:
- Returns:
A class:~astropy.unit.Unit object with dimensions for float parameters, or a list containing class:~astropy.unit.Unit object for a list or
ndarray
.- Return type:
value
- static convert_to_units(name, value)#
Convert parameter values to equivalent dimensional versions.
- get_error(name)#
Return the error value for a particular parameter
- Parameters:
name (str) – the name of the parameter
- get_fitflag(name)#
Return the “fit flag” (a 1 or 0 depending whether the parameter with fit for by TEMPO(2) in the
.par
file).- Parameters:
name (str) – the name of the parameter
- items()#
Return list of item tuples for each parameter in the structure
- keys()#
Return a list of the parameter names stored in the PulsarParameters structure
- parameter(name, withunits=False, tempounits=False)#
Return the parameter given by name.
- pp_to_par(filename, precision=19)#
Output the PulsarParameter structure to a
.par
file.
- pp_to_str(precision=19)#
Convert the PulsarParameter structure to a string in the format of a Tempo-style
.par
file. If the structure contains information from a read-in.par
file, that content will be returned.
- read(filename)#
Read a TEMPO-style parameter file into a PulsarParameters structure
- Parameters:
filename (str) – The path to the pulsar
.par
file.
- property updated#
Flag to state whether any new parameters have been set, or current parameters updated.
- values()#
Return the values of each parameter in the structure