Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
create_time_correction_ephemeris.h
Go to the documentation of this file.
1/*
2* Copyright (C) 2012 Matt Pitkin
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/* Many of these functions are (with occasional modification) taken directly
21 * from the TEMPO2 software package http://www.atnf.csiro.au/research/pulsar/tempo2/
22 * written by George Hobbs and Russell Edwards */
23
24#include <stdio.h>
25#include <stdlib.h>
26#include <math.h>
27#include <string.h>
28#include <time.h>
29
30#include <lal/Date.h>
31#include <lal/LALString.h>
32#include <lal/LALgetopt.h>
33#include <lal/LALVCSInfo.h>
34#include <lal/LALPulsarVCSInfo.h>
35
36/* TEMPO style time delay file */
37#define TT2TDB_FILE "/ephemeris/TDB.1950.2050"
38/* TEMPO2 style time delay file */
39#define IFTEPH_FILE "/ephemeris/TIMEEPH_short.te405"
40
41#define MAXFNAME 512
42
43#define MJDEPOCH 44244.0
44#define DAYSTOSEC 86400.0
45#define GPS2TT 51.184
46
47/* macros taken from TEMPO2's ifteph.h file */
48/* constants determined by Irwin & Fukushima */
49#define IFTE_TEPH0 -65.564518e-6
50
51//This is the value used by if99 : #define IFTE_KM1 1.55051979154e-8 */
52// However we should use the IAU value of L_B that follows from
53// their definition of L_G: L_B = 1.55051976772e-8, K=1/(1-L_B)
54#define IFTE_KM1 1.55051979176e-8
55#define IFTE_K (((long double)1.0) + ((long double)IFTE_KM1))
56
57#define USAGE \
58"Usage: %s [options]\n\n"\
59" --help display this message\n"\
60" --verbose display all error messages\n"\
61" --ephem-type TEMPO/TDB or TEMPO2/TCB/Teph\n"\
62" --output-path path into which to output the ascii ephemeris (the\n\
63 file name will get constructed from the ephemeris type\n\
64 and the start and end years of the input times.)\n"\
65" --start a start GPS time\n"\
66" --end an end GPS time\n"\
67" --interval an interval (in seconds) between entries\n"\
68"\n"
69
70typedef enum {
72 TT2TCB
74
75typedef struct taginputParams_t {
76 char *ephemtype; /* type of ephemeris */
77 char ephemfile[MAXFNAME]; /* path and name of binary ephemeris file */
78 char *outputpath; /* path to output ephemeris file */
79
80 double startT; /* a start GPS time */
81 double endT; /* an end GPS time */
82 double interval; /* number of seconds between output entries */
83
86
87void get_input_args( inputParams_t *inputParams, int argc, char *argv[] );
88
89/*** FUNCTIONS TAKEN FROM TEMPO2 *****/
90
91/* Fortran-equivalent functions */
92double fortran_mod( double a, double p );
93int open_file( char fname[MAXFNAME] );
94double read_double( void );
95int read_int( void );
96void close_file( void );
97
98double FB_deltaT( long double mjd_tt, char fname[MAXFNAME] );
99
100double IF_deltaT( long double mjd_tt );
101
102/* functions and structures for reading in Irwin and Fukushima ephemeris file */
103
105 double pc[18], vc[18], twot;
106 int np, nv;
107};
108
109typedef struct {
110 char title[256];
111 double startJD, endJD, stepJD;
113 double L_C;
116 int irec;
117 double buf[322];
118 FILE *f;
120 int ipt[2][3];
122
124
125void IFTE_init( const char fname[MAXFNAME] );
126void IFTE_close_file( void );
127static void IFTEinterp( struct IFTE_interpolation_info *iinfo,
128 const double coef[], const double t[2], const int ncf,
129 const int ncm, const int na, const int ifl,
130 double posvel[] );
131
132void IFTE_get_Vals( double JDeph0, double JDeph1, int kind,
133 double *res );
134void IFTE_get_DeltaT_DeltaTDot( double Teph0, double Teph1,
135 double *DeltaT, double *DeltaTDot );
136double IFTE_DeltaT( double Teph0, double Teph1 );
137
138/* functions to perform endian swapping */
139void IFTswap8( char *dword );
140void IFTswapDouble( double *dbl );
141void IFTswapInts( int *word, int n );
142void IFTswapInt( int *word );
143void IFTswap4( char *word );
144void IFTswap8N( char *dwords, int n );
145void IFTswapDoubles( double *dbl, int N );
void IFTE_init(const char fname[MAXFNAME])
double FB_deltaT(long double mjd_tt, char fname[MAXFNAME])
void IFTswap8N(char *dwords, int n)
double fortran_mod(double a, double p)
void get_input_args(inputParams_t *inputParams, int argc, char *argv[])
int open_file(char fname[MAXFNAME])
void IFTswapInts(int *word, int n)
double IFTE_DeltaT(double Teph0, double Teph1)
void close_file(void)
void IFTswapDoubles(double *dbl, int N)
double read_double(void)
static void IFTEinterp(struct IFTE_interpolation_info *iinfo, const double coef[], const double t[2], const int ncf, const int ncm, const int na, const int ifl, double posvel[])
void IFTswap4(char *word)
void IFTE_close_file(void)
void IFTE_get_Vals(double JDeph0, double JDeph1, int kind, double *res)
void IFTswap8(char *dword)
double IF_deltaT(long double mjd_tt)
void IFTswapInt(int *word)
void IFTswapDouble(double *dbl)
static IFTEphemeris ifte
void IFTE_get_DeltaT_DeltaTDot(double Teph0, double Teph1, double *DeltaT, double *DeltaTDot)
static const INT4 a