Skip to content

PulsarParametersPy: convert pulsar parameter structure to TEMPO-style file string

Matthew Pitkin requested to merge matthew-pitkin/lalsuite:pulsarstr into master

Description

The PulsarParametersPy class, which wraps the LALPulsar PulsarParameters structure, currently can convert the structure to output a TEMPO-style parameter file. However, rather than having this directly output to a file it can be useful to just have it output to a string. This MR creates a class method to have this output to a string (and adds a __str__ method).

There are also a couple of minor fixes to how the class deals with glitch parameters (these only relate to how they are accesses by the PulsarParametersPy class and not problems with how they are stored in the PulsarParameters structure.

API Changes and Justification

Backwards Compatible Changes

  • This change introduces no API changes
  • This change adds new API calls

Backwards Incompatible Changes

  • This change modifies an existing API
  • This change removes an existing API

If any of the Backwards Incompatible check boxes are ticked please provide a justification why this change is necessary and why it needs to be done in a backwards incompatible way.

Review Status

This can be tested with by, e.g., writing an example parameter file to example.par:

PSRJ J0123+4512
RAJ 01:23:00.00
DECJ 45:12:00.00
PEPOCH 54000
F0 123.4567 1 0.0002
F1 -1.23e-15 1 4e-17
BINARY BT
TASC 54321.0
OM 12.3 1 2.1
PB 1.3
A1 45.6
ECC 0.001
GLPH_1 2.3
GLF0_1 1.2e-6
GLEP_1 56789.1
GLF0D_1 -1.2e-6
GLTD_1 3.45
WAVE_OM 0.1
WAVEEPOCH 56789.0
WAVE1 0.234 0.123
WAVE2 1.1e-6  2.2e-7

Then in Python we can read this in with:

> from lalpulsar.PulsarParametersWrapper import PulsarParametersPy
> par = PulsarParametersPy("example.par")
> print(par)
PSRJ       J0123+4512
RAJ        01:23:00.000000000000
DECJ       45:12:00.000000000036
PEPOCH     54000.0000000000000000000
F0         123.4566999999999978854      1	0.0002000000000000000
F1         -1.2300000000000000680e-15   1	4.0000000000000002862e-17
BINARY     BT
TASC       54321.0000000000000000000
OM         12.3000000000000007105       1	2.1000000000000000888
PB         1.3000000000000000444
A1         45.6000000000000014211
ECC        0.0010000000000000000
GLPH_1     2.2999999999999998224
GLF0_1     0.0000012000000000000
GLEP_1     56789.0999999999985448085
GLF0D_1    -1.1999999999999999457e-06
GLTD_1     3.4499999999999997335
WAVE_OM    0.1000000000000000056
WAVEEPOCH  56789.0000000000000000000
WAVE1      0.2340000000000000135	0.1229999999999999982
WAVE2      0.0000011000000000000	2.2000000000000001122e-07

So they are identical bar minor precision issues after many decimal places.

cc @karl-wette @david-keitel

Edited by LALSuite Bot

Merge request reports