Skip to content

Add function to copy the PulsarParameters object

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

Description

This MR adds a function in ReadPulsarParFile.[c/h] to allow you to copy the contents of one PulsarParameters structure into another. It also adds a __deepcopy__ method, which makes uses of this copying function, into the Python wrapper function to the PulsarParameters structure.

I have tested that this works via the Python wrapper. For example: if we have a parameter file, say test.par, with the following contents:

NAME JPULSAR08
PSRJ JPULSAR08
F0	97.15415925 1 0.0000023
F1	-4.325e-09
RAJ	23:25:33.4997197871
DECJ	-33:25:06.6608320859
PEPOCH	52944.0007428703684126958
UNITS TDB
H0 1.10013760155e-24 1 0.1e-24
PSI 0.170470927
PHI0 2.945
COSIOTA 0.073902656035643471

then this can be read in and copied with:

from lalpulsar.PulsarParametersWrapper import PulsarParametersPy
import copy
par = PulsarParametersPy('test.par')  # read in par file
newpar = copy.deepcopy(par)  # copy the contents of the par file into a new object

In this case the contents are the same (although may be in a different order).

cc @david-keitel @karl-wette

See also CW/software/lalsuite!27 (where this was originally pushed)

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

Review Status

Previously merged into the CW branch by @karl-wette CW/software/lalsuite!27

Merge request reports