38 #include <gsl/gsl_vector.h>
39 #include <gsl/gsl_matrix.h>
41 #include <lal/UserInput.h>
42 #include <lal/LALConstants.h>
44 #include <lal/LALInitBarycenter.h>
45 #include <lal/AVFactories.h>
46 #include <lal/SkyCoordinates.h>
47 #include <lal/ComputeFstat.h>
48 #include <lal/GetEarthTimes.h>
49 #include <lal/SFTfileIO.h>
50 #include <lal/LALString.h>
52 #include <lal/ComputeFstat.h>
53 #include <lal/LogPrintf.h>
54 #include <lal/StringVector.h>
55 #include <lal/UniversalDopplerMetric.h>
56 #include <lal/MetricUtils.h>
57 #include <lal/LALPulsarVCSInfo.h>
60 #define FSTATMETRIC_EMEM 1
61 #define FSTATMETRIC_EINPUT 2
62 #define FSTATMETRIC_ENULL 3
63 #define FSTATMETRIC_ENONULL 4
64 #define FSTATMETRIC_EFILE 5
65 #define FSTATMETRIC_EXLAL 6
68 #define FSTATMETRIC_MSGEMEM "Out of memory."
69 #define FSTATMETRIC_MSGEINPUT "Invalid input."
70 #define FSTATMETRIC_MSGENULL "Illegal NULL input"
71 #define FSTATMETRIC_MSGENONULL "Output field not initialized to NULL"
72 #define FSTATMETRIC_MSGEFILE "File IO error"
73 #define FSTATMETRIC_MSGEXLAL "XLAL function call failed"
79 #define METRIC_FORMAT "% .16e"
85 #define OneBillion 1.0e9
90 #define GPS2REAL8(gps) (1.0 * (gps).gpsSeconds + 1.e-9 * (gps).gpsNanoSeconds )
93 #define SCALAR(u,v) ((u)[0]*(v)[0] + (u)[1]*(v)[1] + (u)[2]*(v)[2])
96 #define COPY_VECT(dst,src) do { (dst)[0] = (src)[0]; (dst)[1] = (src)[1]; (dst)[2] = (src)[2]; } while(0)
98 #define SQ(x) ((x) * (x))
219 if ( uvar.coordsHelp ) {
225 printf(
"\n%s\n", helpstr );
232 config.history->VCSInfoString = VCSInfoString;
237 metricParams.detMotionType = detMotionType;
239 metricParams.segmentList = config.segmentList;
240 metricParams.coordSys = config.coordSys;
241 metricParams.multiIFO = config.multiIFO;
242 metricParams.multiNoiseFloor = config.multiNoiseFloor;
243 metricParams.signalParams = config.signalParams;
244 metricParams.projectCoord = uvar.projection - 1;
245 metricParams.approxPhase = uvar.approxPhase;
250 if ( uvar.metricType == 0 || uvar.metricType == 2 ) {
257 if ( uvar.metricType == 1 || uvar.metricType == 2 ) {
265 if ( uvar.outputMetric ) {
267 if ( ( fpMetric = fopen( uvar.outputMetric,
"wb" ) ) == NULL ) {
269 __func__, uvar.outputMetric, strerror( errno ) );
274 LogPrintf(
LOG_CRITICAL,
"%s: failed to write Doppler metric into output-file '%s'. xlalErrno = %d\n\n",
342 XLALRegisterUvarMember( Alpha, RAJ,
'a', OPTIONAL,
"Sky: equatorial J2000 right ascension (in radians or hours:minutes:seconds)" );
343 XLALRegisterUvarMember( Delta, DECJ,
'd', OPTIONAL,
"Sky: equatorial J2000 declination (in radians or degrees:minutes:seconds)" );
349 XLALRegisterUvarMember( orbitasini,
REAL8, 0, OPTIONAL,
"Target projected semimajor axis of binary orbit (Units: light seconds)" );
351 XLALRegisterUvarMember( orbitTp, EPOCH, 0, OPTIONAL,
"Target time of periapse passage of the CW source in a binary orbit (Units: GPS seconds)" );
355 XLALRegisterUvarMember( refTime, EPOCH, 0, OPTIONAL,
"Reference epoch for phase-evolution parameters (format 'xx.yy[GPS|MJD]'). [0=startTime, default=mid-time]" );
359 XLALRegisterUvarMember( Nseg,
INT4,
'N', OPTIONAL,
"Compute semi-coherent metric for this number of segments within 'duration'" );
360 XLALRegisterUvarMember( segmentList,
STRING, 0, OPTIONAL,
"ALTERNATIVE: specify segment file with format: repeated lines <startGPS endGPS duration[h] NumSFTs>" );
371 XLALRegisterUvarMember( projection,
INT4, 0, OPTIONAL,
"Project onto subspace orthogonal to this axis: 0=none, 1=1st-coord, 2=2nd-coord etc" );
373 XLALRegisterUvarMember( coords, STRINGVector,
'c', OPTIONAL,
"Doppler-coordinates to compute metric in (see --coordsHelp)" );
374 XLALRegisterUvarMember( coordsHelp,
BOOLEAN, 0, OPTIONAL,
"output help-string explaining all the possible Doppler-coordinate names for --coords" );
376 XLALRegisterUvarMember( detMotionStr,
STRING, 0, DEVELOPER,
"Detector-motion string: S|O|S+O where S=spin|spinz|spinxy and O=orbit|ptoleorbit" );
377 XLALRegisterUvarMember( approxPhase,
BOOLEAN, 0, DEVELOPER,
"Use an approximate phase-model, neglecting Roemer delay in spindown coordinates (or orders >= 1)" );
390 if ( !cfg || !uvar || !app_name ) {
401 XLAL_ERROR(
XLAL_EDOM,
"Can specify EITHER {--startTime, --duration, --Nseg} OR --segmentList\n" );
430 refTimeGPS = startTimeGPS;
477 CHAR *cmdline = NULL;
479 size_t len = strlen( app_name ) + 1;
490 strcpy( tmp, app_name );
540 XLAL_CHECK( Nseg >= 1,
XLAL_EDOM,
"Got invalid zero-length segment list 'metric->meta.segmentList'\n" );
559 fprintf(
fp,
"DopplerCoordinates = { " );
576 fprintf(
fp,
"%%%% Projection onto subspace orthogonal to coordinate: '%s'\n",
pname );
591 fprintf(
fp,
"%%%% DopplerPoint = {\n" );
596 if ( doppler->
asini > 0 ) {
631 if ( Pmetric != NULL ) {
636 gsl_matrix *gN_ij = NULL;
643 gsl_matrix_free( gN_ij );
645 gsl_matrix *gDN_ij = NULL;
652 gsl_matrix_free( gDN_ij );
656 if ( Fmetric != NULL ) {
671 if ( Fmetric != NULL && Fmetric->
Fisher_ab != NULL ) {
672 A = gsl_matrix_get( Fmetric->
Fisher_ab, 0, 0 );
673 B = gsl_matrix_get( Fmetric->
Fisher_ab, 1, 1 );
674 C = gsl_matrix_get( Fmetric->
Fisher_ab, 0, 1 );
678 fprintf(
fp,
"\nA = %.16g;\nB = %.16g;\nC = %.16g;\nD = %.16g;\n",
A,
B,
C,
D );
686 char *seglist_octave;
688 fprintf(
fp,
"\n\nsegmentList = %s;\n", seglist_octave );
#define __func__
log an I/O error, i.e.
#define FSTATMETRIC_EXLAL
int main(int argc, char *argv[])
#define FSTATMETRIC_EFILE
int XLALDestroyConfig(ConfigVariables *cfg)
Destructor for internal configuration struct.
int XLALOutputDopplerMetric(FILE *fp, const DopplerPhaseMetric *Pmetric, const DopplerFstatMetric *Fmetric, const ResultHistory_t *history)
int initUserVars(UserVariables_t *uvar)
register all "user-variables"
int vrbflg
defined in lal/lib/std/LALError.c
int XLALInitCode(ConfigVariables *cfg, const UserVariables_t *uvar, const char *app_name)
basic initializations: set-up 'ConfigVariables'
void XLALDestroyResultHistory(ResultHistory_t *history)
Destructor for ResultHistory type.
lal_errhandler_t lal_errhandler
int LAL_ERR_EXIT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
void LALCheckMemoryLeaks(void)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
int XLALParseMultiLALDetector(MultiLALDetector *detInfo, const LALStringVector *detNames)
Parse string-vectors (typically input by user) of N detector-names for detectors ,...
int XLALParseMultiNoiseFloor(MultiNoiseFloor *multiNoiseFloor, const LALStringVector *sqrtSX, UINT4 numDetectors)
Parse string-vectors (typically input by user) of N detector noise-floors for detectors ,...
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
EphemerisData * XLALInitBarycenter(const CHAR *earthEphemerisFile, const CHAR *sunEphemerisFile)
XLAL interface to reading ephemeris files 'earth' and 'sun', and return ephemeris-data in old backwar...
#define XLAL_INIT_DECL(var,...)
void * XLALCalloc(size_t m, size_t n)
void * XLALMalloc(size_t n)
char char * XLALStringDuplicate(const char *s)
char * XLALVCSInfoString(const LALVCSInfoList vcs_list, const int verbose, const char *prefix)
void void int XLALfprintfGSLmatrix(FILE *fp, const char *fmt, const gsl_matrix *gij) _LAL_GCC_VPRINTF_FORMAT_(2)
void LogPrintf(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
int XLALDiagNormalizeMetric(gsl_matrix **p_gpr_ij, gsl_matrix **p_transform, const gsl_matrix *g_ij)
Diagonally-normalize a metric .
int XLALNaturalizeMetric(gsl_matrix **p_gpr_ij, gsl_matrix **p_transform, const gsl_matrix *g_ij, const DopplerMetricParams *metricParams)
Return a metric in naturalized coordinates.
LALSegList * XLALReadSegmentsFromFile(const char *fname)
Function to read a segment list from given filename, returns a sorted LALSegList.
int XLALSegListClear(LALSegList *seglist)
int XLALSegListInitSimpleSegments(LALSegList *seglist, LIGOTimeGPS startTime, UINT4 Nseg, REAL8 Tseg)
char * XLALSegList2String(const LALSegList *seglist)
int XLALSegListIsInitialized(const LALSegList *seglist)
LALStringVector * XLALCreateStringVector(const CHAR *str1,...)
int XLALDopplerCoordinateNames2System(DopplerCoordinateSystem *coordSys, const LALStringVector *coordNames)
Given a LALStringVector of coordinate-names, parse them into a 'DopplerCoordinateSystem',...
const CHAR * XLALDetectorMotionName(DetectorMotionType detMotionType)
Provide a pointer to a static string containing the DopplerCoordinate-name cooresponding to the enum ...
CHAR * XLALDopplerCoordinateHelpAll(void)
Return a string (allocated here) containing a full name - helpstring listing for all doppler-coordina...
void XLALDestroyDopplerFstatMetric(DopplerFstatMetric *metric)
Free a DopplerFstatMetric structure.
void XLALDestroyDopplerPhaseMetric(DopplerPhaseMetric *metric)
Free a DopplerPhaseMetric structure.
const CHAR * XLALDopplerCoordinateName(DopplerCoordinateID coordID)
Provide a pointer to a static string containing the DopplerCoordinate-name cooresponding to the enum ...
int XLALParseDetectorMotionString(const CHAR *detMotionString)
Parse a detector-motion type string into the corresponding enum-number,.
DopplerFstatMetric * XLALComputeDopplerFstatMetric(const DopplerMetricParams *metricParams, const EphemerisData *edat)
Calculate the general (single-segment coherent, or multi-segment semi-coherent) full (multi-IFO) Fsta...
DopplerPhaseMetric * XLALComputeDopplerPhaseMetric(const DopplerMetricParams *metricParams, const EphemerisData *edat)
Calculate an approximate "phase-metric" with the specified parameters.
@ DETMOTION_SPIN
Full spin motion.
@ DETMOTION_ORBIT
Ephemeris-based orbital motion.
#define XLAL_CHECK(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
REAL8 XLALGPSDiff(const LIGOTimeGPS *t1, const LIGOTimeGPS *t0)
Configuration settings required for and defining a coherent pulsar search.
ResultHistory_t * history
history trail leading up to and including this application
MultiLALDetector multiIFO
detectors to generate data for (if provided by user and not via noise files)
MultiNoiseFloor multiNoiseFloor
...
LALSegList segmentList
segment list contains start- and end-times of all segments
DopplerCoordinateSystem coordSys
array of enums describing Doppler-coordinates to compute metric in
PulsarParams signalParams
GW signal parameters: Amplitudes + doppler.
EphemerisData * edat
ephemeris data
type describing a Doppler coordinate system: lists the number of dimensions and the symbolic names of...
DopplerCoordinateID coordIDs[DOPPLERMETRIC_MAX_DIM]
coordinate 'names'
UINT4 dim
number of dimensions covered
Struct to hold the output of XLALComputeDopplerFstatMetric(), including meta-info on the number of di...
gsl_matrix * m3_ij
Fstat-metric sub components.
double maxrelerr
estimate for largest relative error in Fmetric component integrations
gsl_matrix * gFav_ij
'average' Fstat-metric
gsl_matrix * gF_ij
full F-statistic metric gF_ij, including antenna-pattern effects (see )
DopplerMetricParams meta
"meta-info" describing/specifying the type of Doppler metric
REAL8 rho2
signal SNR rho^2 = A^mu M_mu_nu A^nu
gsl_matrix * Fisher_ab
Full 4+n dimensional Fisher matrix, ie amplitude + Doppler space.
meta-info specifying a Doppler-metric
MultiLALDetector multiIFO
detectors to compute metric for
DetectorMotionType detMotionType
the type of detector-motion assumed: full spin+orbit, pure orbital, Ptole, ...
PulsarParams signalParams
parameter-space point to compute metric for (doppler + amplitudes)
INT4 projectCoord
project metric onto subspace orthogonal to this axis (-1 = none, 0 = 1st coordinate,...
LALSegList segmentList
segment list: Nseg segments of the form (startGPS endGPS numSFTs)
MultiNoiseFloor multiNoiseFloor
and associated per-detector noise-floors to be used for weighting.
DopplerCoordinateSystem coordSys
number of dimensions and coordinate-IDs of Doppler-metric
Struct to hold the output of XLALComputeDopplerPhaseMetric(), including meta-info on the number of di...
double maxrelerr
estimate for largest relative error in phase-metric component integrations
gsl_matrix * g_ij
symmetric matrix holding the phase-metric, averaged over segments
DopplerMetricParams meta
"meta-info" describing/specifying the type of Doppler metric
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
array of detectors definitions 'LALDetector'
UINT4 length
number of detectors
LALDetector sites[PULSAR_MAX_DETECTORS]
array of site information
array of detector-specific 'noise floors' (ie PSD values), assumed constant over the frequency-band o...
REAL8 sqrtSn[PULSAR_MAX_DETECTORS]
per-IFO sqrt(PSD) values , where
UINT4 length
number of detectors
Type containing the JKS 'amplitude parameters' {h0, cosi, phi0, psi}.
REAL8 aCross
Signal amplitude (cross)
REAL8 psi
polarization angle psi
REAL8 aPlus
Signal amplitude (plus)
REAL8 phi0
initial signal-phase (at some reference time)
Type containing the 'Doppler-parameters' affecting the time-evolution of the phase.
REAL8 period
Binary: orbital period (sec)
LIGOTimeGPS tp
Binary: time of observed periapsis passage (in SSB)
PulsarSpins fkdot
Intrinsic spins: [Freq, f1dot, f2dot, ...
REAL8 Delta
Sky position: DEC (latitude) in equatorial coords and radians.
LIGOTimeGPS refTime
Reference time of pulsar parameters (in SSB!)
REAL8 Alpha
Sky position: RA (longitude) in equatorial coords and radians.
REAL8 ecc
Binary: orbital eccentricity.
REAL8 asini
Binary: projected, normalized orbital semi-major axis (s).
REAL8 argp
Binary: argument of periapsis (radians)
Type defining the parameters of a pulsar-source of CW Gravitational waves.
PulsarAmplitudeParams Amp
'Amplitude-parameters': h0, cosi, phi0, psi
PulsarDopplerParams Doppler
'Phase-evolution parameters': {skypos, fkdot, orbital params }
Rudimentary first sketch of a history type, to encode all the history-trail leading to a certain resu...
CHAR * cmdline
commandline used to produce this result
CHAR * VCSInfoString
Git source-version + configure string.
CHAR * app_name
name (and path) of this application
REAL8 Alpha
Right ascension [radians] alpha of pulsar.
INT4 duration
Duration of requested signal in seconds.
REAL8 orbitArgp
Argument of periapsis (radians)
REAL8 duration
length of observation in seconds
REAL8 psi
Polarization angle psi.
CHAR * ephemSun
Sun ephemeris file to use.
BOOLEAN approxPhase
use an approximate phase-model, neglecting Roemer delay in spindown coordinates
REAL8 h0
overall signal amplitude h0
LIGOTimeGPS refTime
Pulsar reference epoch tRef in SSB ('0' means: use startTime converted to SSB)
CHAR * detMotionStr
string specifying type of detector-motion to use
CHAR * ephemEarth
Earth ephemeris file to use.
REAL8 phi0
Initial phase phi.
REAL8 f2dot
Second spindown parameter f''.
LIGOTimeGPS orbitTp
'true' epoch of periapsis passage
INT4 metricType
type of metric to compute: 0=phase-metric, 1=F-metric(s), 2=both
REAL8 Freq
physical start frequency to compute PSD for (excluding rngmed wings)
CHAR * segmentList
ALTERNATIVE: specify segment file with format: repeated lines <startGPS endGPS duration[h] NumSFTs>".
INT4 Nseg
number of segments to split duration into
LALStringVector * coords
list of Doppler-coordinates to compute metric in, see –coordsHelp for possible values
INT4 projection
project metric onto subspace orthogonal to this coordinate-axis (0=none, 1=1st-coordinate axis,...
LIGOTimeGPS startTime
Start-time of requested signal in detector-frame (GPS seconds)
REAL8 Delta
Declination [radians] delta of pulsar.
REAL8 orbitasini
Projected orbital semi-major axis in seconds (a/c)
REAL8 f1dot
First spindown parameter f'.
LALStringVector * IFOs
list of detector-names "H1,H2,L1,.." or single detector
LALStringVector * sqrtSX
Add Gaussian noise: list of respective detectors' noise-floors sqrt{Sn}".
BOOLEAN coordsHelp
output help-string explaining all the possible Doppler-coordinate names for –cords
REAL8 orbitEcc
Orbital eccentricity.
REAL8 f3dot
Third spindown parameter f'''.
REAL8 orbitPeriod
Orbital period (seconds)
REAL8 cosi
cos(iota) of inclination angle iota
CHAR * outputMetric
filename to write metrics into