Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-3a66518
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
skygridsetup.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2011, 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
21#include <stdio.h>
22#include <math.h>
23
24#include <lal/UserInput.h>
25#include <lal/LALString.h>
26#include <lal/DopplerScan.h>
27#include <lal/LALInitBarycenter.h>
28
29#include "../antenna.h"
30
31typedef struct {
32 REAL8 Tsft;
33 REAL8 SFToverlap;
34 REAL8 t0;
35 REAL8 Tobs;
36 REAL8 fmin;
38 CHAR *IFO;
39 CHAR *outfilename;
40 CHAR *ephemEarth;
41 CHAR *ephemSun;
45
46INT4 InitUserVars( UserVariables_t *uvar, int argc, char *argv[] );
47
48//Main program
49int main( int argc, char *argv[] )
50{
51
52 FILE *OUTPUT;
53 LALDetector det;
55
57 XLAL_CHECK( InitUserVars( &uvar, argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC );
58
59 XLAL_CHECK( ( OUTPUT = fopen( uvar.outfilename, "w" ) ) != NULL, XLAL_EIO, "Output file %s could not be opened\n", uvar.outfilename );
60
61 //Interferometer
62 if ( strcmp( "L1", uvar.IFO ) == 0 ) {
63 fprintf( stderr, "IFO = %s\n", uvar.IFO );
65 } else if ( strcmp( "H1", uvar.IFO ) == 0 ) {
66 fprintf( stderr, "IFO = %s\n", uvar.IFO );
68 } else if ( strcmp( "V1", uvar.IFO ) == 0 ) {
69 fprintf( stderr, "IFO = %s\n", uvar.IFO );
71 } else {
72 XLAL_ERROR( XLAL_EINVAL, "Not using valid interferometer! Expected 'H1', 'L1', or 'V1' not %s.\n", uvar.IFO );
73 }
74
75 //Parameters for the sky-grid
76 fprintf( stderr, "Sky region = %s\n", uvar.skyRegion );
79 PulsarDopplerParams dopplerpos;
80 scanInit.gridType = GRID_ISOTROPIC; //Default value for an approximate-isotropic grid
81 scanInit.skyRegionString = uvar.skyRegion; //"allsky" = Default value for all-sky search
82 scanInit.numSkyPartitions = 1; //Default value so sky is not broken into chunks
83 scanInit.Freq = uvar.fmin + 0.5 * uvar.fspan; //Mid-point of the frequency band
84
85 //Initialize ephemeris data structure
86 EphemerisData *edat = NULL;
87 XLAL_CHECK( ( edat = XLALInitBarycenter( uvar.ephemEarth, uvar.ephemSun ) ) != NULL, XLAL_EFUNC );
88
89 //v1: Maximum orbital earth speed in units of c from start of S6 TwoSpect data for 104 weeks total time
90 //else: maximum detector velocity around the time of observation
91 REAL4 detectorVmax = 0.0;
92 if ( uvar.v1 ) {
93 detectorVmax = CompDetectorVmax( 931081500.0 + uvar.SFToverlap, uvar.Tsft, uvar.SFToverlap, 62899200.0 - uvar.SFToverlap, det, edat );
94 } else {
95 detectorVmax = CompDetectorVmax( uvar.t0 - uvar.Tsft, uvar.Tsft, uvar.SFToverlap, uvar.Tobs + 2.0 * uvar.Tsft, det, edat );
96 }
97 XLAL_CHECK( xlalErrno == 0, XLAL_EFUNC, "CompDetectorVmax() failed\n" );
98
99 //Initialize the sky-grid
100 scanInit.dAlpha = 0.5 / ( ( uvar.fmin + 0.5 * uvar.fspan ) * uvar.Tsft * detectorVmax );
101 scanInit.dDelta = scanInit.dAlpha;
102 InitDopplerSkyScan( &status, &scan, &scanInit );
103 XLAL_CHECK( status.statusCode == 0, XLAL_EFUNC );
104
105 //Start at first location
106 XLAL_CHECK( XLALNextDopplerSkyPos( &dopplerpos, &scan ) == XLAL_SUCCESS, XLAL_EFUNC );
107
108 //loop through and output to the specified file
109 while ( scan.state != STATE_FINISHED ) {
110 fprintf( OUTPUT, "%.6f %.6f\n", dopplerpos.Alpha, dopplerpos.Delta );
111
112 //Iterate to next sky location
113 XLAL_CHECK( XLALNextDopplerSkyPos( &dopplerpos, &scan ) == XLAL_SUCCESS, XLAL_EFUNC );
114 }
115
116 //Destroy
119 fclose( OUTPUT );
120
121 return 0;
122
123}
124
125
126INT4 InitUserVars( UserVariables_t *uvar, int argc, char *argv[] )
127{
128 XLAL_CHECK( uvar != NULL, XLAL_EINVAL, "Invalid NULL input 'uvar'\n" );
129 XLAL_CHECK( argv != NULL, XLAL_EINVAL, "Invalid NULL input 'argv'\n" );
130
131 uvar->ephemEarth = XLALStringDuplicate( "earth00-40-DE405.dat.gz" );
132 uvar->ephemSun = XLALStringDuplicate( "sun00-40-DE405.dat.gz" );
133 uvar->outfilename = XLALStringDuplicate( "skygrid.dat" );
134 uvar->skyRegion = XLALStringDuplicate( "allsky" );
135 uvar->Tsft = 1800;
136 uvar->SFToverlap = 900;
137 uvar->fspan = 0.25;
138
139 XLALRegisterUvarMember( Tsft, REAL8, 0, OPTIONAL, "SFT coherence time" );
140 XLALRegisterUvarMember( SFToverlap, REAL8, 0, OPTIONAL, "SFT overlap in seconds, usually Tsft/2" );
141 XLALRegisterUvarMember( t0, REAL8, 0, OPTIONAL, "GPS start time of the search; not needed if --v1 is specified" );
142 XLALRegisterUvarMember( Tobs, REAL8, 0, OPTIONAL, "Duration of the search (in seconds); not needed if --v1 is specified" );
143 XLALRegisterUvarMember( fmin, REAL8, 0, OPTIONAL, "Minimum frequency of band" );
144 XLALRegisterUvarMember( fspan, REAL8, 0, OPTIONAL, "Frequency span of band" );
145 XLALRegisterUvarMember( IFO, STRING, 0, REQUIRED, "Interferometer whose data is being analyzed" );
146 XLALRegisterUvarMember( outfilename, STRING, 0, OPTIONAL, "Output filename" );
147 XLALRegisterUvarMember( ephemEarth, STRING, 0, OPTIONAL, "Earth ephemeris file" );
148 XLALRegisterUvarMember( ephemSun, STRING, 0, OPTIONAL, "Sun ephemeris file" );
149 XLALRegisterUvarMember( skyRegion, STRING, 0, OPTIONAL, "Region of the sky to search (e.g. (ra1,dec1),(ra2,dec2),(ra3,dec3)...) or allsky" );
150 XLALRegisterUvarMember( v1, BOOLEAN, 0, DEVELOPER, "Flag to use older style of CompDetectorVmax (for S6/VSR2-3 analysis)" );
151
152 BOOLEAN should_exit = 0;
154 if ( should_exit ) {
155 exit( 1 );
156 }
157
158 if ( !uvar->v1 && !XLALUserVarWasSet( &uvar->t0 ) ) {
159 XLAL_ERROR( XLAL_EINVAL, "Must set t0" );
160 }
161 if ( !uvar->v1 && !XLALUserVarWasSet( &uvar->Tobs ) ) {
162 XLAL_ERROR( XLAL_EINVAL, "Must set Tobs" );
163 }
164
165 return XLAL_SUCCESS;
166}
void InitDopplerSkyScan(LALStatus *status, DopplerSkyScanState *skyScan, const DopplerSkyScanInit *init)
Definition: DopplerScan.c:273
int XLALNextDopplerSkyPos(PulsarDopplerParams *pos, DopplerSkyScanState *skyScan)
NextDopplerSkyPos(): step through sky-grid return 0 = OK, -1 = ERROR.
Definition: DopplerScan.c:127
@ STATE_FINISHED
all templates have been read
Definition: DopplerScan.h:84
@ GRID_ISOTROPIC
approximately isotropic sky-grid
Definition: DopplerScan.h:92
#define IFO
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
#define STRING(a)
#define fprintf
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
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
EphemerisData * XLALInitBarycenter(const CHAR *earthEphemerisFile, const CHAR *sunEphemerisFile)
XLAL interface to reading ephemeris files 'earth' and 'sun', and return ephemeris-data in old backwar...
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
unsigned char BOOLEAN
double REAL8
#define XLAL_INIT_DECL(var,...)
char CHAR
int32_t INT4
float REAL4
LAL_LLO_4K_DETECTOR
LAL_VIRGO_DETECTOR
LAL_LHO_4K_DETECTOR
char char * XLALStringDuplicate(const char *s)
int XLALUserVarReadAllInput(BOOLEAN *should_exit, int argc, char *argv[], const LALVCSInfoList vcs_list)
void XLALDestroyUserVars(void)
#define XLALRegisterUvarMember(name, type, option, category,...)
int XLALUserVarWasSet(const void *cvar)
#define xlalErrno
#define XLAL_ERROR(...)
#define XLAL_CHECK(assertion,...)
XLAL_SUCCESS
XLAL_EFUNC
XLAL_EIO
XLAL_EINVAL
int main(int argc, char *argv[])
Definition: skygridsetup.c:49
INT4 InitUserVars(UserVariables_t *uvar, int argc, char *argv[])
Definition: skygridsetup.c:126
double t0
initialization-structure passed to InitDopplerSkyScan()
Definition: DopplerScan.h:134
this structure reflects the current state of a DopplerSkyScan
Definition: DopplerScan.h:152
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
Type containing the 'Doppler-parameters' affecting the time-evolution of the phase.
REAL8 Delta
Sky position: DEC (latitude) in equatorial coords and radians.
REAL8 Alpha
Sky position: RA (longitude) in equatorial coords and radians.
user input variables
Definition: compareFstats.c:51
CHAR * ephemSun
Sun ephemeris file to use.
CHAR * ephemEarth
Earth ephemeris file to use.
REAL8 SFToverlap
overlap SFTs by this many seconds
REAL8 Tsft
SFT time baseline Tsft.