20The module provides the HeterodynedCWSimulator() class for simulating a
21signal from a continuous wave source after application of a heterodyned as
22described in Equations 7 and 8 of @cite Pitkin2017 . An example usage to
23generate the complex heterodyned signal time series is:
26from lalpulsar.simulateHeterodynedCW import HeterodynedCWSimulator
27from lalpulsar.PulsarParametersWrapper import PulsarParametersPy
31# set the pulsar parameters
32par = PulsarParametersPy()
33par['RAJ'] = lal.TranslateHMStoRAD('01:23:34.5')
34par['DECJ'] = lal.TranslateDMStoRAD('-45:01:23.4')
35par['F'] = [123.456789, -9.87654321e-12]
36pepoch = lal.TranslateStringMJDTTtoGPS(
'58000')
37par[
'PEPOCH'] = pepoch.gpsSeconds + 1e-9*pepoch.gpsNanoSeconds
44times = np.arange(1000000000.0, 1000086400., 3600)
53model = het.model(usephase=
True)
56An example of getting the time series
for a signal that has phase parameters
57that are
not identical to the heterodyned parameters would be:
67par[
'RAJ'] = lal.TranslateHMStoRAD(
'01:23:34.6')
68par[
'DECJ'] = lal.TranslateDMStoRAD(
'-45:01:23.5')
69par[
'F'] = [123.4567, -9.876e-12]
70pepoch = lal.TranslateStringMJDTTtoGPS(
'58000')
71par[
'PEPOCH'] = pepoch.gpsSeconds + 1e-9*pepoch.gpsNanoSeconds
74times = np.arange(1000000000., 1000000600., 60)
84parupdate[
'RAJ'] = lal.TranslateHMStoRAD(
'01:23:34.5')
85parupdate[
'DECJ'] = lal.TranslateDMStoRAD(
'-45:01:23.4')
86parupdate[
'F'] = [123.456789, -9.87654321e-12]
87pepoch = lal.TranslateStringMJDTTtoGPS(
'58000')
88parupdate[
'PEPOCH'] = pepoch.gpsSeconds + 1e-9*pepoch.gpsNanoSeconds
89parupdate[
'H0'] = 5.6e-26
90parupdate[
'COSIOTA'] = -0.2
92parupdate[
'PHI0'] = 2.3
95model = het.model(parupdate, usephase=
True, updateSSB=
True)
101from __future__ import division, print_function
108 raise ImportError(
"SWIG wrappings of LAL cannot be imported")
113 raise ImportError(
"SWIG wrappings of LALPulsar cannot be imported")
116 from .PulsarParametersWrapper
import PulsarParametersPy
118 raise ImportError(
"Cannot import PulsarParametersPy class")
120from .
import git_version
123__author__ =
"Matthew Pitkin <matthew.pitkin@ligo.org>"
124__version__ = git_version.id
125__date__ = git_version.date
128DOWNLOAD_URL =
"https://git.ligo.org/lscsoft/lalsuite/raw/master/lalpulsar/lib/{}"
146 A class to simulate
strain data for
a continuous gravitational-wave
147 signal after the data has been heterodyned, i.e., after multiplying
148 the data by a complex phase vector. This uses the Equations 7
and 8
153 structure, containing the parameters
for the source,
in particular
154 the phase parameters at which the data
is "heterodyned".
155 @param det: the name of a detector.
156 @param times: an array of GPS times at which to calculate the
158 @param t0: a time epoch
in GPS seconds at which to calculate the
159 detector response function. If
not given
and @b times
is set,
160 then the first value of
@b times will be used.
161 @param dt: the time steps (
in seconds)
in the data over which to
162 average the detector response. If
not given
and @b times
is set,
163 the the time difference between the first two values
in @b times
165 @param earth_ephem: a file containing the Earth ephemeris information.
166 If
not set then a default file will be used.
167 @param sun_ephem: a file containing the Earth ephemeris information.
168 If
not set then a default file will be used.
169 @param time_corr: a file containing information on the time system
170 corrections
for, e.g., the TCB
or TDB system. If
not set then
171 a default file will be used.
172 @param ephem: The solar system ephemeris system to use
for the Earth
173 and Sun ephemeris, i.e.,
@c 'DE200',
@c 'DE405',
@c 'DE421',
or
174 @c 'DE430'. By default the
@c 'EPHEM' value
from the supplied
175 @b par will be used, but
if not found,
and if this value
is not
176 set, it will default to
@c 'DE405'.
177 @param units: The time system used, i.e.,
@c 'TDB' or @c 'TCB'. By default
178 the
@c 'UNITS' value
from the
@b par will be used, but
if not
179 found,
and if this value
is not set, it will (like TEMPO2) default
189 self.
__sunstr =
"sun00-40-{}.dat.gz"
200 earth_ephem, sun_ephem, time_corr
241 and self.
hetpar[
"WAVESIN"]
is not None
242 and self.
hetpar[
"WAVECOS"]
is not None
256 "Must supply either 'times' or 't0' to calculate "
257 "the response function"
264 "Must supply either 'times' or 'dt' to calculate "
265 "the response function"
270 raise ValueError(
"Must supply a 'dt' value")
278 if ra
is None or dec
is None:
279 raise ValueError(
"Right ascension and/or declination have not " "been set!")
281 self.
__resp = lalpulsar.DetResponseLookupTable(
295 if isinstance(det, lal.Detector):
299 if not isinstance(det, str):
300 raise TypeError(
"Detector name must be a string")
306 "Detector '{}' was not a valid detector " "name.".
format(det)
314 Return the response function look-up table.
328 def times(self, times):
338 elif isinstance(times, lal.LIGOTimeGPS):
340 [times.gpsSeconds + 1e-9 * times.gpsNanoSeconds], dtype=
"float64"
342 self.
__gpstimes = lalpulsar.CreateTimestampVector(1)
345 elif isinstance(times, lalpulsar.LIGOTimeGPSVector):
347 self.
__times = np.zeros(len(times.data), dtype=
"float64")
348 for i, gpstime
in enumerate(times.data):
350 times.data[i].gpsSeconds + 1e-9 * times.data[i].gpsNanoSeconds
353 elif isinstance(times, (int, float)):
354 self.
__times = np.array([times], dtype=
"float64")
355 elif isinstance(times, (list, np.ndarray)):
356 self.
__times = np.array(times, dtype=
"float64")
358 raise TypeError(
"Unknown data type for times")
361 for i, time
in enumerate(self.
__times):
362 self.
__gpstimes.data[i] = lal.LIGOTimeGPS(time)
369 def ephem(self, ephem):
371 Set the heterodyne solar system ephemeris version. This will attempt to
372 use the value set in the heterodyne source parameters, but otherwise
376 if self.
hetpar[
"EPHEM"]
is not None:
379 self.
__ephem =
"DE405" if ephem
is None else ephem
386 def units(self, units):
388 Set the time system units, i.e., either 'TDB' or 'TCB'. This will
389 attempt to use the value set
in the heterodyne source parameters, but
390 otherwise defaults to
'TCB'.
393 if self.
hetpar[
"UNITS"]
is not None:
396 self.
__units =
"TCB" if units
is None else units
398 if self.
__units not in [
"TCB",
"TDB"]:
400 "Unknown time system '{}' has been " "given.".
format(self.
__units)
414 updatefitwaves=False,
420 Compute the heterodyned strain model using
423 @param newpar: A text parameter file,
or PulsarParameterPy() object,
424 containing a set of parameter at which to calculate the strain
425 model. If this
is @c None then the
"heterodyne" parameters are used.
426 @param updateSSB: set to
@c True to update the solar system barycentring
427 time delays compared to those used
in heterodyning, i.e.,
if the
428 @b newpar contains updated positional parameters.
429 @param updateBSB: set to
@c True to update the binary system barycentring
430 time delays compared to those used
in heterodying, i.e.,
if the
431 @b newpar contains updated binary system parameters
432 @param updateglphase: set to
@c True to update the pulsar glitch
433 evolution compared to that used
in heterodyning, i.e.,
if the
@b newpar
434 contains updated glitch parameters.
435 @param updatefitwaves: set to
@c True to update the pulsar FITWAVES phase
436 evolution (used to model strong red timing noise) compared to that
437 used
in heterodyning.
438 @param freqfactor: the factor by which the frequency evolution
is
439 multiplied
for the source model. This defaults to 2
for emission
440 from the \f$l=m=2\f$ quadrupole mode.
441 @param usephase: set to
@c True if the model
is to include the phase
442 evolution, i.e.,
if phase parameters are being updated, otherwise
443 only two (six
for non-GR sources) values giving the amplitides
445 @param roq: a boolean value to set to
@c True requiring the output
for
448 @return a complex array called
@b compstrain
451 if newpar
is not None:
459 compstrain = lalpulsar.HeterodynedPulsarGetModel(
460 parupdate.PulsarParameters(),
461 origpar.PulsarParameters(),
481 return compstrain.data.data
483 def _read_par(self, par):
485 Read a TEMPO-style parameter file into a PulsarParameterPy object.
488 if isinstance(par, PulsarParametersPy):
491 if isinstance(par, str):
495 raise IOError(
"Could not read in parameter file: '{}'".
format(par))
497 raise TypeError(
"The parameter file must be a string")
515 def _check_nonGR(self, par):
517 Check if the source parameters are
for a non-GR model, i.e., are any of
518 the amplitude/phase parameters
for a non-GR model set
537 for param
in nonGRparams:
538 if param
in par.keys():
543 def _initialise_ephemeris(self, earth_ephem, sun_ephem, time_corr):
545 Initialise the solar system ephemeris.
548 if earth_ephem
is not None:
549 earthfile = earth_ephem
553 if sun_ephem
is not None:
558 if time_corr
is not None:
564 edat = lalpulsar.InitBarycenter(earthfile, sunfile)
568 from astropy.utils.data
import download_file
570 efile = download_file(DOWNLOAD_URL.format(earthfile), cache=
True)
571 sfile = download_file(DOWNLOAD_URL.format(sunfile), cache=
True)
572 edat = lalpulsar.InitBarycenter(efile, sfile)
573 except Exception
as e:
574 raise IOError(
"Could not read in ephemeris files: {}".
format(e))
577 tdat = lalpulsar.InitTimeCorrections(timefile)
581 from astropy.utils.data
import download_file
583 tfile = download_file(DOWNLOAD_URL.format(timefile), cache=
True)
584 tdat = lalpulsar.InitTimeCorrections(tfile)
585 except Exception
as e:
586 raise IOError(
"Could not read in time correction file: {}".
format(e))
COMPLEX16TimeSeries * XLALHeterodynedPulsarGetModel(PulsarParameters *pars, PulsarParameters *origpars, REAL8 freqfactor, UINT4 usephase, UINT4 useroq, UINT4 nonGR, const LIGOTimeGPSVector *timestamps, REAL8Vector *hetssbdelays, UINT4 calcSSBDelay, REAL8Vector *hetbsbdelays, UINT4 calcBSBDelay, REAL8Vector *glphase, UINT4 calcglphase, REAL8Vector *fitwavesphase, UINT4 calcfitwaves, const DetResponseTimeLookupTable *resp, const EphemerisData *ephem, const TimeCorrectionData *tdat, TimeCorrectionType ttype)
Generate the model of the neutron star signal.
A class to wrap the SWIG-wrapped lalpulsar.PulsarParameters structure.
def resp(self)
Return the response function look-up table.
def model(self, newpar=None, updateSSB=False, updateBSB=False, updateglphase=False, updatefitwaves=False, freqfactor=2.0, usephase=False, roq=False)
Compute the heterodyned strain model using XLALHeterodynedPulsarGetModel().
def units(self, units)
Set the time system units, i.e., either 'TDB' or 'TCB'.
def _initialise_ephemeris(self, earth_ephem, sun_ephem, time_corr)
def ephem(self, ephem)
Set the heterodyne solar system ephemeris version.
def _check_nonGR(self, par)
def times(self, times)
Set an array of times, and also a LIGOTimeGPSVector() containing the times.
def __init__(self, par, det, times=None, earth_ephem=None, sun_ephem=None, time_corr=None, ephem="DE405", units="TCB", t0=None, dt=None)
A class to simulate strain data for a continuous gravitational-wave signal after the data has been he...
A vector of 'timestamps' of type LIGOTimeGPS.
The PulsarParameters structure to contain a set of pulsar parameters.