DeltaT.h
1 #ifndef _UCORRELATOR_DELTA_T_H
2 #define _UCORRELATOR_DELTA_T_H
3 
4 #include "AntennaPositions.h"
5 #include "AnitaGeomTool.h"
6 #include "FFTtools.h"
7 #include "TrigCache.h"
8 
9 
10 #ifndef DEG2RAD
11 #define DEG2RAD (M_PI/180.);
12 #endif
13 
14 namespace UCorrelator
15 {
17  inline double getAntennaGroupDelay(double phidiff, double theta)
18  {
19  theta-=10;
20 
21  double c1 = 1.45676e-8;
22  double c2 = 5.01452e-6;
23 
24  if(AnitaVersion::get() == 4){
25  // anita 4 group delay
26  c1 = 1.29e-8;
27  c2 = 4.91e-6;
28  }
29 
30  double totalAngle2=theta*theta+phidiff*phidiff;//TODO
31  if (totalAngle2>50*50) return (50*50*50*50 * c1 - 50*50 * c2);
32 
33  double delayTime=totalAngle2 * totalAngle2 * c1 - totalAngle2 * c2;
34 
35  return delayTime;
36  }
37 
38 
43  inline double getDeltaTtoCenter(int ant1, double phi, double theta, AnitaPol::AnitaPol_t pol, bool includeGroupDelay = false, bool includeTimeShift = true, bool simulationTimeShift = false)
44  {
45  double th = theta * DEG2RAD;
46  const AntennaPositions * ap = AntennaPositions::instance();
47  double ph1_deg = (phi- ap->phiAnt[pol][ant1]) ;
48  double ph1 = ph1_deg * DEG2RAD;
49  double r1 = ap->rAnt[pol][ant1];
50 
51  int whichShift = simulationTimeShift ? -1 : 1;
52  double tshift = includeTimeShift ? ((pol==AnitaPol::kHorizontal) ? 0 : whichShift * (r1 - ap->rAnt[pol^1][ant1])*cos(ph1) * 1e9/C_LIGHT) : 0;
53 
54  double part1=ap->zAnt[pol][ant1]*tan(th) - r1 * cos(ph1);
55 
56  double geomDelay=1e9*((cos(th) * part1)/C_LIGHT); //returns time in ns
57 
58 
59  if (includeGroupDelay)
60  {
61  geomDelay += getAntennaGroupDelay(FFTtools::wrap(ph1_deg,360,0), theta);
62  }
63 
64  return geomDelay + tshift;
65  }
66 
68  inline double getDeltaT(int ant1, int ant2, double phi, double theta, AnitaPol::AnitaPol_t pol, bool includeGroupDelay = false)
69  {
70  double th = theta * DEG2RAD;
71  const AntennaPositions * ap = AntennaPositions::instance();
72  double ph1_deg = (phi- ap->phiAnt[pol][ant1]) ;
73  double ph2_deg = (phi- ap->phiAnt[pol][ant2]) ;
74  double ph1 = ph1_deg * DEG2RAD;
75  double ph2 = ph2_deg * DEG2RAD;
76 
77  double part1=ap->zAnt[pol][ant1]*tan(th) - ap->rAnt[pol][ant1] * cos(ph1);
78  double part2=ap->zAnt[pol][ant2]*tan(th) - ap->rAnt[pol][ant2] * cos(ph2);
79 
80  double geomDelay=1e9*((cos(th) * (part1 - part2))/C_LIGHT); //returns time in ns
81 
82 
83  if (includeGroupDelay)
84  {
85  geomDelay += getAntennaGroupDelay(FFTtools::wrap(ph1_deg,360,0), theta) - getAntennaGroupDelay(FFTtools::wrap(ph2_deg,360,0), theta);
86  }
87 
88  return geomDelay;
89  }
90 
96  inline double getDeltaTFast(int ant1, int ant2, int phibin, int thetabin, AnitaPol::AnitaPol_t pol, const TrigCache * cache, bool includeGroupDelay = false)
97  {
98  const AntennaPositions * ap = cache->ap;
99  const int nphi = cache->nphi;
100  double part1=ap->zAnt[pol][ant1]*cache->tan_theta[thetabin] - ap->rAnt[pol][ant1] * cache->cos_phi[2*(phibin + nphi * ant1) + pol];
101  double part2=ap->zAnt[pol][ant2]*cache->tan_theta[thetabin] - ap->rAnt[pol][ant2] * cache->cos_phi[2*(phibin + nphi * ant2) + pol];
102 
103  double geomDelay=(1.e9/C_LIGHT)*(cache->cos_theta[thetabin] * (part1 - part2)); //returns time in ns
104 
105 
106  if (includeGroupDelay)
107  {
108  double ph1_deg = FFTtools::wrap((cache->phi[phibin]- ap->phiAnt[pol][ant1]),360,0) ;
109  double ph2_deg = FFTtools::wrap((cache->phi[phibin]- ap->phiAnt[pol][ant2]),360,0) ;
110  double theta_deg = cache->theta[thetabin];
111  geomDelay += getAntennaGroupDelay(ph1_deg, theta_deg) - getAntennaGroupDelay(ph2_deg, theta_deg);
112  }
113 
114  return geomDelay;
115  }
116 
117 
118 }
119 
120 #endif
double getDeltaTtoCenter(int ant1, double phi, double theta, AnitaPol::AnitaPol_t pol, bool includeGroupDelay=false, bool includeTimeShift=true, bool simulationTimeShift=false)
Definition: DeltaT.h:43
double getAntennaGroupDelay(double phidiff, double theta)
Definition: DeltaT.h:17
double getDeltaT(int ant1, int ant2, double phi, double theta, AnitaPol::AnitaPol_t pol, bool includeGroupDelay=false)
Definition: DeltaT.h:68
double getDeltaTFast(int ant1, int ant2, int phibin, int thetabin, AnitaPol::AnitaPol_t pol, const TrigCache *cache, bool includeGroupDelay=false)
Definition: DeltaT.h:96
double zAnt[2][NUM_SEAVEYS]
double rAnt[2][NUM_SEAVEYS]
void wrap(size_t N, double *vals, double period=360)
Definition: FFTtools.cxx:2851
double phiAnt[2][NUM_SEAVEYS]
Horizontal Polarisation.
enum AnitaPol::EAnitaPol AnitaPol_t
Polarisation enumeration.