Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ComputeSky.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Jolien Creighton, Reinhard Prix, Steve Berukoff
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20/**
21 * \author Berukoff, S.J., Papa, M.A.
22 * \file
23 * \ingroup lalpulsar_inject
24 * \brief Computes the phase model coefficients necessary for a successful demodulation.
25 *
26 */
27
28#include <math.h>
29#include <lal/LALConstants.h>
30#include <lal/ComputeSky.h>
31
32static void TimeToFloat( REAL8 *f, LIGOTimeGPS *tgps );
33static void FloatToTime( LIGOTimeGPS *tgps, REAL8 *f );
34
35
36/**
37 * Given an input index which refers to the sky patch under consideration, this
38 * routine returns the phase model coefficients \f$ A_{s\alpha} \f$ and \f$ B_{s\alpha} \f$
39 * which are needed to correctly account for the phase variance of a signal over
40 * time. The \c CSParams parameter structure contains relevant information
41 * for this routine to properly run. In particular, it contains an array of
42 * timestamps in \c LIGOTimeGPS format, which are the GPS times of the first
43 * data from each SFT. The \c input is an \c INT4 variable
44 * \c iSkyCoh, which is the index of the sky patch under consideration. For
45 * each sky patch, this code needs to be run once; the necessary phase model
46 * coefficients are calculated, and can then be applied to the relevant spindown
47 * parameter sets one is using in their search.
48 *
49 * ### Algorithm ###
50 *
51 * The routine uses a simplistic nested for-loop structure. The outer loop is
52 * over the number of SFTs in the observation timescale; this accounts for the
53 * temporal variability of the phase model coefficients. The inner loop is over
54 * the number of spindown parameters in one set. Inside the inner loop, the
55 * values are calculated using the analytical formulae given in the
56 * \ref ComputeSky.h documentation.
57 *
58 * ### Notes ###
59 *
60 * The reference-time, at which the pulsar spin-parameters are defined, is
61 * taken to be the start-time *INTERPRETED* as an SSB time (i.e. no translation
62 * is done, the times are numerically equal!).
63 */
64void
66 REAL8 *skyConst,
67 INT8 iSkyCoh,
69{
70
71 INT4 m, n;
72 REAL8 t;
73 REAL8 basedTbary;
74
75 REAL8 dTbary;
76 REAL8 tBary;
77 REAL8 tB0;
80
81 /* Check for non-negativity of sky positions in SkyCoh[] */
83
84 /* Check to make sure sky positions are loaded */
87
88 /* Check to make sure parameters are loaded and reasonable */
92
93 for ( n = 0; n < params->mObsSFT; n++ ) {
94 ASSERT( params->tGPS[n].gpsSeconds >= 0, status, COMPUTESKYH_ENEGA, COMPUTESKYH_MSGENEGA );
95 }
96
97 /* Check to make sure pointer to output is not NULL */
99
100 params->baryinput->alpha = params->skyPos[iSkyCoh];
101 params->baryinput->delta = params->skyPos[iSkyCoh + 1];
102
103 /* NOTE: we DO NOT translate the start-time into the SSB frame,
104 * as this would result in a source-position dependent reference-time.
105 * Instead we simply take the GPS start-time and interpret it as the
106 * SSB reference-time
107 */
108 /*
109 params->baryinput->tgps.gpsSeconds=params->tGPS[0].gpsSeconds;
110 params->baryinput->tgps.gpsNanoSeconds=params->tGPS[0].gpsNanoSeconds;
111
112 XLALBarycenterEarth(status->statusPtr, params->earth, &(params->baryinput->tgps), params->edat);
113 XLALBarycenter(status->statusPtr, params->emit, params->baryinput, params->earth);
114 TimeToFloat(&tB0, &(params->emit->te));
115 */
116 TimeToFloat( &tB0, &( params->tGPS[0] ) );
117
118
119 for ( n = 0; n < params->mObsSFT; n++ ) {
120 t = ( REAL8 )( params->tGPS[n].gpsSeconds ) + ( REAL8 )( params->tGPS[n].gpsNanoSeconds ) * 1.0E-9 + 0.5 * params->tSFT;
121
122 FloatToTime( &( params->baryinput->tgps ), &t );
123
124 XLAL_CHECK_LAL( status, XLALBarycenterEarth( params->earth, &( params->baryinput->tgps ), params->edat ) == XLAL_SUCCESS, XLAL_EFUNC );
125 XLAL_CHECK_LAL( status, XLALBarycenter( params->emit, params->baryinput, params->earth ) == XLAL_SUCCESS, XLAL_EFUNC );
126
127 TimeToFloat( &tBary, &( params->emit->te ) );
128
129 dTbary = tBary - tB0;
130
131 for ( m = 0; m < params->spinDwnOrder + 1; m++ ) {
132 basedTbary = pow( dTbary, ( REAL8 )m );
133 skyConst[2 * n * ( params->spinDwnOrder + 1 ) + 2 * ( INT4 )m] = 1.0 / ( ( REAL8 )m + 1.0 ) * basedTbary * dTbary - 0.5 * params->tSFT * params->emit->tDot * basedTbary;
134 skyConst[2 * n * ( params->spinDwnOrder + 1 ) + 2 * ( INT4 )m + 1] = params->tSFT * params->emit->tDot * basedTbary;
135 }
136 }
137 /* Normal Exit */
139 RETURN( status );
140}
141
142
143/* Internal routines */
144static void TimeToFloat( REAL8 *f, LIGOTimeGPS *tgps )
145{
146 INT4 x, y;
147
148 x = tgps->gpsSeconds;
149 y = tgps->gpsNanoSeconds;
150 *f = ( REAL8 )x + ( REAL8 )y * 1.e-9;
151}
152
153static void FloatToTime( LIGOTimeGPS *tgps, REAL8 *f )
154{
155 REAL8 temp0, temp2, temp3;
156 REAL8 temp1, temp4;
157
158 temp0 = floor( *f ); /* this is tgps.S */
159 temp1 = ( *f ) * 1.e10;
160 temp2 = fmod( temp1, 1.e10 );
161 temp3 = fmod( temp1, 1.e2 );
162 temp4 = ( temp2 - temp3 ) * 0.1;
163
164 tgps->gpsSeconds = ( INT4 )temp0;
165 tgps->gpsNanoSeconds = ( INT4 )temp4;
166}
void LALComputeSky(LALStatus *status, REAL8 *skyConst, INT8 iSkyCoh, CSParams *params)
Given an input index which refers to the sky patch under consideration, this routine returns the phas...
Definition: ComputeSky.c:65
static void FloatToTime(LIGOTimeGPS *tgps, REAL8 *f)
Definition: ComputeSky.c:153
static void TimeToFloat(REAL8 *f, LIGOTimeGPS *tgps)
Definition: ComputeSky.c:144
#define COMPUTESKYH_MSGENULL
Definition: ComputeSky.h:120
#define COMPUTESKYH_ENEGA
Definition: ComputeSky.h:119
#define COMPUTESKYH_ENNUL
Definition: ComputeSky.h:118
#define COMPUTESKYH_ENULL
Definition: ComputeSky.h:117
#define COMPUTESKYH_MSGENEGA
Definition: ComputeSky.h:122
#define COMPUTESKYH_MSGENNUL
Definition: ComputeSky.h:121
#define XLAL_CHECK_LAL(sp, assertion,...)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
int XLALBarycenterEarth(EarthState *earth, const LIGOTimeGPS *tGPS, const EphemerisData *edat)
Computes the position and orientation of the Earth, at some arrival time , specified LIGOTimeGPS inp...
Definition: LALBarycenter.c:78
int XLALBarycenter(EmissionTime *emit, const BarycenterInput *baryinput, const EarthState *earth)
Transforms from detector arrival time in GPS (as specified in the LIGOTimeGPS structure) to pulse em...
double REAL8
int64_t INT8
int32_t INT4
static const INT4 m
XLAL_SUCCESS
XLAL_EFUNC
list y
n
This structure contains the parameters for the LALComputeSky() routine.
Definition: ComputeSky.h:131
INT4 gpsNanoSeconds