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.:
>>> from lalpulsar.PulsarParametersWrapper import PulsarParametersPy >>> pppy = PulsarParametersPy() # an empty structure >>> pppy['DECJ'] = 0.23 # set a numerical value >>> pppy['BINARY'] = 'BT' # set a string value >>> pppy['F'] = [10.2, 1.4e-11] # set a vector of float values
Args: 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 empty lalpulsar.PulsarParameters structure is created. The read()
method can subsequently be used to read in a .par
file, or parameters can be added.
Examples: An example of initialising the class with a previously created lalpulsar.PulsarParameters
structure is:
>>> import lalpulsar >>> from lalpulsar.PulsarParametersWrapper import PulsarParametersPy >>> # read in a pulsar parameter file >>> pp = lalpulsar.ReadTEMPOParFile('apulsar.par') >>> # view as a PulsarParametersPy object >>> pppy = PulsarParametersPy(pp)
The same thing could be achieved more directly using:
>>> pppy = PulsarParametersPy('apulsar.par')
or, equivalently with:
>>> pppy = PulsarParametersPy() >>> pppy.read('apulsar.par')
Definition at line 256 of file PulsarParametersWrapper.py.
Inherits object.
Public Member Functions | |
def | __init__ (self, pp=None) |
def | __len__ (self) |
def | __str__ (self) |
def | __getitem__ (self, key) |
Get value from pulsar parameters. More... | |
def | __setitem__ (self, key, value) |
Set the value of a key. More... | |
def | convert_to_units (self, name, value) |
Convert parameter values to equivalent dimensional versions. More... | |
def | convert_to_tempo_units (self, name, value, iserr=False) |
Convert from PulsarParameter units to TEMPO-par-file units. More... | |
def | parameter (self, name, withunits=False, tempounits=False) |
Return the parameter given by name. More... | |
def | keys (self) |
Return a list of the parameter names stored in the PulsarParameters structure. More... | |
def | values (self) |
Return the values of each parameter in the structure. More... | |
def | as_dict (self) |
Return the contents (not error at the moment) of the structure as a dictionary. More... | |
def | items (self) |
Return list of item tuples for each parameter in the structure. More... | |
def | read (self, filename) |
Read a TEMPO-style parameter file into a PulsarParameters structure. More... | |
def | get_error (self, name) |
Return the error value for a particular parameter. More... | |
def | get_fitflag (self, name) |
Return the "fit flag" (a 1 or 0 depending whether the parameter with fit for by TEMPO(2) in the .par file). More... | |
def | pp_to_str (self, precision=19) |
Convert the PulsarParameter structure to a string in the format of a TEMPO-style .par file. More... | |
def | pp_to_par (self, filename, precision=19) |
Output the PulsarParameter structure to a .par file. More... | |
def | PulsarParameters (self) |
Return the PulsarParameters structure. More... | |
def | __deepcopy__ (self, memo) |
Create a copy of the parameters. More... | |
Data Fields | |
keynames | |
length | |
Static Public Attributes | |
list | keynames = [] |
int | length = 0 |
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.__init__ | ( | self, | |
pp = None |
|||
) |
Definition at line 262 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.__len__ | ( | self | ) |
Definition at line 283 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.__str__ | ( | self | ) |
Definition at line 288 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.__getitem__ | ( | self, | |
key | |||
) |
Get value from pulsar parameters.
Definition at line 294 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.__setitem__ | ( | self, | |
key, | |||
value | |||
) |
Set the value of a key.
Definition at line 386 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.convert_to_units | ( | self, | |
name, | |||
value | |||
) |
Convert parameter values to equivalent dimensional versions.
Args: name (str): the name of the parameter to convert value: the value to the parameter to convert
Returns: :class:astropy.unit.Unit
: a unit class with dimensions for a float parameters, or a list containing unit classes for a list or :class:numpy.ndarray
Definition at line 423 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.convert_to_tempo_units | ( | self, | |
name, | |||
value, | |||
iserr = False |
|||
) |
Convert from PulsarParameter units to TEMPO-par-file units.
Args: name (str): a parameter name value (float, list, :class:numpy.ndarray
): the value of the parameter iserr (bool): state whether where converting the parameter's error value
Returns: :class:astropy.unit.Unit
: a unit class with dimensions for a float parameters, or a list containing unit classes for a list or :class:numpy.ndarray
Definition at line 459 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.parameter | ( | self, | |
name, | |||
withunits = False , |
|||
tempounits = False |
|||
) |
Return the parameter given by name.
Args: name (str): the name of the parameter to return withunits (bool): if True return the parameter in a form with its appropriate units tempounits (bool): of True return the parameter converted into the units required in a TEMPO-style parameter file
Definition at line 571 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.keys | ( | self | ) |
Return a list of the parameter names stored in the PulsarParameters structure.
Definition at line 597 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.values | ( | self | ) |
Return the values of each parameter in the structure.
Definition at line 617 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.as_dict | ( | self | ) |
Return the contents (not error at the moment) of the structure as a dictionary.
Definition at line 652 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.items | ( | self | ) |
Return list of item tuples for each parameter in the structure.
Definition at line 664 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.read | ( | self, | |
filename | |||
) |
Read a TEMPO-style parameter file into a PulsarParameters structure.
Args: filename (str): the path to the pulsar .par
file.
Definition at line 682 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.get_error | ( | self, | |
name | |||
) |
Return the error value for a particular parameter.
Args: name (str): the name of the parameter
Definition at line 703 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.get_fitflag | ( | self, | |
name | |||
) |
Return the "fit flag" (a 1 or 0 depending whether the parameter with fit for by TEMPO(2) in the .par
file).
Args: name (str): the name of the parameter
Definition at line 721 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.pp_to_str | ( | self, | |
precision = 19 |
|||
) |
Convert the PulsarParameter structure to a string in the format of a TEMPO-style .par
file.
Args: precision (int): the number of decimal places for an output value
Returns: str: the contents in TEMPO-format
Definition at line 743 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.pp_to_par | ( | self, | |
filename, | |||
precision = 19 |
|||
) |
Output the PulsarParameter structure to a .par
file.
Args: filename (str): the path to the output file precision (int): the number of decimal places for an output value
Definition at line 917 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.PulsarParameters | ( | self | ) |
Return the PulsarParameters structure.
Definition at line 930 of file PulsarParametersWrapper.py.
def lalpulsar.PulsarParametersWrapper.PulsarParametersPy.__deepcopy__ | ( | self, | |
memo | |||
) |
Create a copy of the parameters.
Definition at line 937 of file PulsarParametersWrapper.py.
|
static |
Definition at line 258 of file PulsarParametersWrapper.py.
|
static |
Definition at line 259 of file PulsarParametersWrapper.py.
lalpulsar.PulsarParametersWrapper.PulsarParametersPy.keynames |
Definition at line 600 of file PulsarParametersWrapper.py.
lalpulsar.PulsarParametersWrapper.PulsarParametersPy.length |
Definition at line 601 of file PulsarParametersWrapper.py.