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
antenna.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2010, 2012, 2013, 2014 Evan Goetz
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#include <math.h>
21#include <lal/SSBtimes.h>
22#include <lal/DetResponse.h>
23#include <lal/Velocity.h>
24#include "antenna.h"
25
26/**
27 * \brief Compute the number of integer bin shifts per SFT
28 *
29 * bin shift = f0*v*Tsft, where f0 is frequency, v is velocity in units of c, and Tsft is the SFT coherence length.
30 * An optional dopplerMultiplier value could be multiplied if desired (default value is 1.0)
31 * \param [out] output Pointer to INT4Vector of bin shift values
32 * \param [in] ssbTimes Pointer to the interferometer-specific SSBtimes
33 * \param [in] freq Frequency from which to compute the bin shifts
34 * \param [in] Tsft Coherence length of the SFTs
35 * \param [in] dopplerMultiplier Multiplicative factor to increase or decrease the bin shifts (standard physics = 1.0)
36 * \return Status value
37 */
38INT4 CompBinShifts( INT4Vector *output, const SSBtimes *ssbTimes, const REAL8 freq, const REAL8 Tsft, const REAL4 dopplerMultiplier )
39{
40 for ( UINT4 ii = 0; ii < output->length; ii++ ) {
41 output->data[ii] = ( INT4 )round( dopplerMultiplier * ( ssbTimes->Tdot->data[ii] - 1.0 ) * freq * Tsft );
42 }
43 return XLAL_SUCCESS;
44}
45
46/**
47 * \brief Compute the antenna pattern weights
48 *
49 * If linPolOn = 0, then the output weights are Fplus*Fplus + Fcross*Fcross,
50 * or if linPolOn = 1, then the output weights are Fplus*Fplus for the given polarization angle
51 * \param [out] output Pointer to REAL4Vector of antenna pattern weights
52 * \param [in] skypos Sky position measured in RA and Dec in radians
53 * \param [in] t0 Start time (GPS seconds)
54 * \param [in] Tsft Coherence length of the SFTs (in seconds)
55 * \param [in] SFToverlap Overlap of the SFTs (in seconds)
56 * \param [in] Tobs Observation time (in seconds)
57 * \param [in] linPolOn Flag for linear polarizations (linPolOn = 0 is circular polarization weights, linPolOn = 1 is linear polarization weights)
58 * \param [in] polAngle Only used for when linPolOn = 1. Polarization angle from which to compute the antenna pattern weights
59 * \param [in] det A LALDetector struct
60 * \return Status value
61 */
62INT4 CompAntennaPatternWeights( REAL4VectorAligned *output, const SkyPosition skypos, const REAL8 t0, const REAL8 Tsft, const REAL8 SFToverlap, const REAL8 Tobs, const BOOLEAN linPolOn, const REAL8 polAngle, const LALDetector det )
63{
64
65 XLAL_CHECK( output != NULL, XLAL_EINVAL );
66
67 INT4 numffts = ( INT4 )floor( Tobs / ( Tsft - SFToverlap ) - 1 ); //Number of FFTs
68 REAL8 fplus, fcross;
69
70 for ( INT4 ii = 0; ii < numffts; ii++ ) {
71
73 gpstime.gpsSeconds = ( INT4 )floor( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft );
74 gpstime.gpsNanoSeconds = ( INT4 )floor( ( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft - floor( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft ) ) * 1e9 );
77
78 XLALComputeDetAMResponse( &fplus, &fcross, ( const REAL4( * )[3] )det.response, skypos.longitude, skypos.latitude, polAngle, gmst );
80
81 if ( !linPolOn ) {
82 output->data[ii] = ( REAL4 )( fplus * fplus + fcross * fcross );
83 } else {
84 output->data[ii] = ( REAL4 )( fplus * fplus );
85 }
86
87 } /* for ii < numffts */
88
89 return XLAL_SUCCESS;
90
91} /* CompAntennaPatternWeights() */
92
94{
95
96 XLAL_CHECK( output != NULL, XLAL_EINVAL );
97
98 REAL8 onePlusCosiSqOver2Sq = 1.0, cosiSq = 1.0;
99 if ( cosi != NULL ) {
100 onePlusCosiSqOver2Sq = 0.25 * ( 1.0 + ( *cosi ) * ( *cosi ) ) * ( 1.0 + ( *cosi ) * ( *cosi ) );
101 cosiSq = ( *cosi ) * ( *cosi );
102 }
103
104 REAL8 fplus, fcross;
105 for ( UINT4 ii = 0; ii < timestamps->length; ii++ ) {
108
109 if ( psi != NULL ) {
110 XLALComputeDetAMResponse( &fplus, &fcross, det.response, skypos.longitude, skypos.latitude, *psi, gmst );
112 output->data[ii] = fplus * fplus * onePlusCosiSqOver2Sq + fcross * fcross * cosiSq;
113 } else {
114 output->data[ii] = 0.0;
115 for ( UINT4 jj = 0; jj < 16; jj++ ) {
116 XLALComputeDetAMResponse( &fplus, &fcross, det.response, skypos.longitude, skypos.latitude, 0.0625 * LAL_PI * jj, gmst );
118 output->data[ii] += fplus * fplus * onePlusCosiSqOver2Sq + fcross * fcross * cosiSq;
119 }
120 output->data[ii] *= 0.0625;
121 }
122 }
123
124 return XLAL_SUCCESS;
125
126} // CompAntennaPatternWeights()
127
128/**
129 * Compute the antenna velocity
130 * \param [out] output Pointer to REAL4Vector of antenna velocities
131 * \param [in] skypos Sky position measured in RA and Dec in radians
132 * \param [in] t0 Start time (GPS seconds)
133 * \param [in] Tsft Coherence length of the SFTs (in seconds)
134 * \param [in] SFToverlap Overlap of the SFTs (in seconds)
135 * \param [in] Tobs Observation time (in seconds)
136 * \param [in] det A LALDetector struct
137 * \param [in] edat Pointer to EphemerisData
138 * \return Status value
139 */
140INT4 CompAntennaVelocity( REAL4VectorAligned *output, const SkyPosition skypos, const REAL8 t0, const REAL8 Tsft, const REAL8 SFToverlap, const REAL8 Tobs, const LALDetector det, EphemerisData *edat )
141{
142
143 XLAL_CHECK( output != NULL && edat != NULL, XLAL_EINVAL );
144
145 INT4 numffts = ( INT4 )floor( Tobs / ( Tsft - SFToverlap ) - 1 ); //Number of FFTs
147
148 REAL8 detvel[3];
149 for ( INT4 ii = 0; ii < numffts; ii++ ) {
150
152 gpstime.gpsSeconds = ( INT4 )floor( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft );
153 gpstime.gpsNanoSeconds = ( INT4 )floor( ( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft - floor( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft ) ) * 1e9 );
154
155 LALDetectorVel( &status, detvel, &gpstime, det, edat );
156 XLAL_CHECK( status.statusCode == 0, XLAL_EFUNC );
157
158 output->data[ii] = ( REAL4 )( detvel[0] * cos( skypos.longitude ) * cos( skypos.latitude ) + detvel[1] * sin( skypos.longitude ) * cos( skypos.latitude ) + detvel[2] * sin( skypos.latitude ) );
159
160 } /* for ii < numffts */
161
162 return XLAL_SUCCESS;
163
164} /* CompAntennaVelocity() */
165
166
167/**
168 * Compute the maximum change in antenna velocity
169 * \param [in] t0 Start time (GPS seconds)
170 * \param [in] Tsft Coherence length of the SFTs (in seconds)
171 * \param [in] SFToverlap Overlap of the SFTs (in seconds)
172 * \param [in] Tobs Observation time (in seconds)
173 * \param [in] det A LALDetector struct
174 * \param [in] edat Pointer to EphemerisData
175 * \return Maximum change in antenna velocity
176 */
177REAL4 CompDetectorDeltaVmax( const REAL8 t0, const REAL8 Tsft, const REAL8 SFToverlap, const REAL8 Tobs, const LALDetector det, EphemerisData *edat )
178{
179
180 XLAL_CHECK( edat != NULL, XLAL_EINVAL );
181
182 INT4 numffts = ( INT4 )floor( Tobs / ( Tsft - SFToverlap ) - 1 ); //Number of FFTs
184
185 REAL8 detvel[3], detvel0[3], dv[3];
186 REAL4 deltaVmax = 0.0;
187 for ( INT4 ii = 0; ii < numffts; ii++ ) {
189 gpstime.gpsSeconds = ( INT4 )floor( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft );
190 gpstime.gpsNanoSeconds = ( INT4 )floor( ( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft - floor( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft ) ) * 1e9 );
191
192 if ( ii == 0 ) {
193 LALDetectorVel( &status, detvel0, &gpstime, det, edat );
194 XLAL_CHECK_REAL4( status.statusCode == 0, XLAL_EFUNC );
195 } else {
196 LALDetectorVel( &status, detvel, &gpstime, det, edat );
197 XLAL_CHECK_REAL4( status.statusCode == 0, XLAL_EFUNC );
198
199 dv[0] = detvel[0] - detvel0[0];
200 dv[1] = detvel[1] - detvel0[1];
201 dv[2] = detvel[2] - detvel0[2];
202 REAL4 deltaV = ( REAL4 )sqrt( dv[0] * dv[0] + dv[1] * dv[1] + dv[2] * dv[2] );
203 if ( deltaV > deltaVmax ) {
204 deltaVmax = deltaV;
205 }
206 } /* if ii==0 else ... */
207 } /* for ii < numffts */
208
209 return deltaVmax;
210
211} /* CompDetectorDeltaVmax() */
212
213
214/**
215 * Compute the largest magnitude of antenna velocity
216 * \param [in] t0 Start time (GPS seconds)
217 * \param [in] Tsft Coherence length of the SFTs (in seconds)
218 * \param [in] SFToverlap Overlap of the SFTs (in seconds)
219 * \param [in] Tobs Observation time (in seconds)
220 * \param [in] det A LALDetector struct
221 * \param [in] edat Pointer to EphemerisData
222 * \return Maximum magnitude of antenna velocity
223 */
224REAL4 CompDetectorVmax( const REAL8 t0, const REAL8 Tsft, const REAL8 SFToverlap, const REAL8 Tobs, const LALDetector det, EphemerisData *edat )
225{
226
227 XLAL_CHECK( edat != NULL, XLAL_EINVAL );
228
229 INT4 numffts = ( INT4 )floor( Tobs / ( Tsft - SFToverlap ) - 1 ); //Number of FFTs
231
233 gpstime.gpsSeconds = ( INT4 )floor( t0 + 0.5 * Tsft );
234 gpstime.gpsNanoSeconds = ( INT4 )floor( ( t0 + 0.5 * Tsft - floor( t0 + 0.5 * Tsft ) ) * 1e9 );
235
236 REAL8 detvel[3];
237 LALDetectorVel( &status, detvel, &gpstime, det, edat );
238 XLAL_CHECK_REAL4( status.statusCode == 0, XLAL_EFUNC );
239 REAL4 Vmax = ( REAL4 )sqrt( detvel[0] * detvel[0] + detvel[1] * detvel[1] + detvel[2] * detvel[2] );
240
241 for ( INT4 ii = 1; ii < numffts; ii++ ) {
242 gpstime.gpsSeconds = ( INT4 )floor( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft );
243 gpstime.gpsNanoSeconds = ( INT4 )floor( ( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft - floor( t0 + ii * ( Tsft - SFToverlap ) + 0.5 * Tsft ) ) * 1e9 );
244
245 LALDetectorVel( &status, detvel, &gpstime, det, edat );
246 XLAL_CHECK_REAL4( status.statusCode == 0, XLAL_EFUNC );
247 REAL4 V = ( REAL4 )sqrt( detvel[0] * detvel[0] + detvel[1] * detvel[1] + detvel[2] * detvel[2] );
248 if ( V > Vmax ) {
249 Vmax = V;
250 }
251 } /* for ii < numffts */
252
253 return Vmax;
254
255} /* CompDetectorVmax() */
257{
258 XLAL_CHECK( timestamps != NULL && edat != NULL, XLAL_EINVAL );
259
261
263
264 REAL8 detvel[3];
265 LALDetectorVel( &status, detvel, &gpstime, det, edat );
266 XLAL_CHECK_REAL4( status.statusCode == 0, XLAL_EFUNC );
267 REAL4 Vmax = ( REAL4 )sqrt( detvel[0] * detvel[0] + detvel[1] * detvel[1] + detvel[2] * detvel[2] );
268
269 for ( UINT4 ii = 1; ii < timestamps->length; ii++ ) {
270 gpstime = timestamps->data[ii];
271
272 LALDetectorVel( &status, detvel, &gpstime, det, edat );
273 XLAL_CHECK_REAL4( status.statusCode == 0, XLAL_EFUNC );
274 REAL4 V = ( REAL4 )sqrt( detvel[0] * detvel[0] + detvel[1] * detvel[1] + detvel[2] * detvel[2] );
275 if ( V > Vmax ) {
276 Vmax = V;
277 }
278 } /* for ii < numffts */
279
280 return Vmax;
281}
LIGOTimeGPSVector * timestamps
INT4 CompBinShifts(INT4Vector *output, const SSBtimes *ssbTimes, const REAL8 freq, const REAL8 Tsft, const REAL4 dopplerMultiplier)
Compute the number of integer bin shifts per SFT.
Definition: antenna.c:38
INT4 CompAntennaPatternWeights2(REAL4VectorAligned *output, const SkyPosition skypos, const LIGOTimeGPSVector *timestamps, const LALDetector det, const REAL8 *cosi, const REAL8 *psi)
Definition: antenna.c:93
INT4 CompAntennaPatternWeights(REAL4VectorAligned *output, const SkyPosition skypos, const REAL8 t0, const REAL8 Tsft, const REAL8 SFToverlap, const REAL8 Tobs, const BOOLEAN linPolOn, const REAL8 polAngle, const LALDetector det)
Compute the antenna pattern weights.
Definition: antenna.c:62
REAL4 CompDetectorVmax2(const LIGOTimeGPSVector *timestamps, const LALDetector det, EphemerisData *edat)
Definition: antenna.c:256
REAL4 CompDetectorVmax(const REAL8 t0, const REAL8 Tsft, const REAL8 SFToverlap, const REAL8 Tobs, const LALDetector det, EphemerisData *edat)
Compute the largest magnitude of antenna velocity.
Definition: antenna.c:224
REAL4 CompDetectorDeltaVmax(const REAL8 t0, const REAL8 Tsft, const REAL8 SFToverlap, const REAL8 Tobs, const LALDetector det, EphemerisData *edat)
Compute the maximum change in antenna velocity.
Definition: antenna.c:177
INT4 CompAntennaVelocity(REAL4VectorAligned *output, const SkyPosition skypos, const REAL8 t0, const REAL8 Tsft, const REAL8 SFToverlap, const REAL8 Tobs, const LALDetector det, EphemerisData *edat)
Compute the antenna velocity.
Definition: antenna.c:140
void XLALComputeDetAMResponse(double *fplus, double *fcross, const REAL4 D[3][3], const double ra, const double dec, const double psi, const double gmst)
#define LAL_PI
unsigned char BOOLEAN
#define LIGOTIMEGPSZERO
double REAL8
#define XLAL_INIT_DECL(var,...)
uint32_t UINT4
int32_t INT4
float REAL4
void LALDetectorVel(LALStatus *status, REAL8 v[3], LIGOTimeGPS *time0, LALDetector detector, EphemerisData *edat)
This function finds the velocity of a given detector at a given time.
Definition: Velocity.c:200
#define xlalErrno
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_REAL4(assertion,...)
XLAL_SUCCESS
XLAL_EFUNC
XLAL_EINVAL
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
int gpstime
Definition: hwinject.c:365
double t0
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
REAL4 response[3][3]
A vector of 'timestamps' of type LIGOTimeGPS.
Definition: SFTfileIO.h:188
LIGOTimeGPS * data
array of timestamps
Definition: SFTfileIO.h:193
UINT4 length
number of timestamps
Definition: SFTfileIO.h:192
REAL8 * data
Simple container for two REAL8-vectors, namely the SSB-timings DeltaT_alpha and Tdot_alpha,...
Definition: SSBtimes.h:60
REAL8Vector * Tdot
dT/dt : time-derivative of SSB-time wrt local time for SFT-alpha
Definition: SSBtimes.h:63
REAL8 longitude
REAL8 latitude
double V