GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMBvc.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMBvc.cpp - COMPTEL Solar System Barycentre Data class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2022 by Juergen Knodlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GCOMBvc.cpp
23  * @brief COMPTEL Solar System Barycentre Data class implementation
24  * @author Juergen Knodlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GTools.hpp"
32 #include "GSkyDir.hpp"
33 #include "GCOMBvc.hpp"
34 
35 /* __ Method name definitions ____________________________________________ */
36 
37 /* __ Macros _____________________________________________________________ */
38 
39 /* __ Coding definitions _________________________________________________ */
40 
41 /* __ Debug definitions __________________________________________________ */
42 
43 
44 /*==========================================================================
45  = =
46  = Constructors/destructors =
47  = =
48  ==========================================================================*/
49 
50 /***********************************************************************//**
51  * @brief Void constructor
52  ***************************************************************************/
54 {
55  // Initialise class members
56  init_members();
57 
58  // Return
59  return;
60 }
61 
62 
63 /***********************************************************************//**
64  * @brief Copy constructor
65  *
66  * @param[in] bvc COMPTEL Solar System Barycentre Data.
67  ***************************************************************************/
69 {
70  // Initialise class members
71  init_members();
72 
73  // Copy members
74  copy_members(bvc);
75 
76  // Return
77  return;
78 }
79 
80 
81 /***********************************************************************//**
82  * @brief Destructor
83  ***************************************************************************/
85 {
86  // Free members
87  free_members();
88 
89  // Return
90  return;
91 }
92 
93 
94 /*==========================================================================
95  = =
96  = Operators =
97  = =
98  ==========================================================================*/
99 
100 /***********************************************************************//**
101  * @brief Assignment operator
102  *
103  * @param[in] bvc COMPTEL Solar System Barycentre Data.
104  * @return COMPTEL Solar System Barycentre Data.
105  ***************************************************************************/
107 {
108  // Execute only if object is not identical
109  if (this != &bvc) {
110 
111  // Free members
112  free_members();
113 
114  // Initialise private members
115  init_members();
116 
117  // Copy members
118  copy_members(bvc);
119 
120  } // endif: object was not identical
121 
122  // Return this object
123  return *this;
124 }
125 
126 
127 /*==========================================================================
128  = =
129  = Public methods =
130  = =
131  ==========================================================================*/
132 
133 /***********************************************************************//**
134  * @brief Clear COMPTEL Solar System Barycentre Data
135  ***************************************************************************/
136 void GCOMBvc::clear(void)
137 {
138  // Free members
139  free_members();
140 
141  // Initialise private members
142  init_members();
143 
144  // Return
145  return;
146 }
147 
148 
149 /***********************************************************************//**
150  * @brief Clone COMPTEL Solar System Barycentre Data
151  *
152  * @return Pointer to deep copy of COMPTEL Solar System Barycentre Data.
153  ***************************************************************************/
155 {
156  return new GCOMBvc(*this);
157 }
158 
159 
160 /***********************************************************************//**
161  * @brief Return time difference between photon arrival time at CGRO and
162  * the Solar System Barycentre (SSB)
163  *
164  * @param[in] dir Source position.
165  * @return Time difference between photon arrival times (s)
166  *
167  * Returns the time difference between photon arrival time at CGRO and the
168  * Solar System Barycentre (SSB). The arrival time at the SSB is computed
169  * by adding the time difference to the photon arrival time as measured by
170  * COMPTEL
171  *
172  * \f[
173  * T_{\rm SSB} = T_{\rm CGRO} + \Delta T
174  * \f]
175  *
176  * The routine implements the algorithm PUL-AL-004 and is inspried from the
177  * COMPASS code evpbin02.pulssb.f.
178  *
179  * It computes
180  *
181  * \f[
182  * \Delta T = \Delta T_{\rm travel} - \Delta T_{\rm rel} + \Delta T_{\rm BVC}
183  * \f]
184  *
185  * where
186  *
187  * \f[
188  * \Delta T_{\rm travel} = \left( \vec{SSB} \cdot \vec{n} \right) \times 10^{-6}
189  * \f]
190  *
191  * is the light travel time in seconds between CGRO and the SSB, with
192  * \f$\vec{SSB}\f$ being the vector going from the SSB to CGRO, specified
193  * using the GCOMBvc::ssb() method, and \f$\vec{n}\f$ is the normalised
194  * vector of the source position, provided by the GSkyDir::celvector()
195  * method,
196  *
197  * \f[
198  * \Delta T_{\rm rel} =
199  * -2 R \log \left( 1 + \frac{\Delta T_{\rm travel}}{|\vec{SSB}| * 10^{-6}} \right)
200  * \f]
201  *
202  * is the relativistic delay due to the Sun in seconds, with
203  * \f$R=0.49254909 \times 10^{-5}\f$ s, and \f$\Delta T_{\rm BVC}\f$ is the
204  * difference in seconds due to the time unit conversion as specified by the
205  * GCOMBvc::tdelta() method.
206  ***************************************************************************/
207 double GCOMBvc::tdelta(const GSkyDir& dir) const
208 {
209  // Set constants
210  const double radius = 0.49254909e-5;
211 
212  // Get celestial vector
213  GVector n = dir.celvector();
214 
215  // Compute the light travel time from the satellite to SSB along the
216  // pulsar direction
217  double travt = m_ssb * n * 1.0e-6;
218 
219  // Compute the relativistic delay due to the Sun
220  double r = norm(m_ssb) * 1.0e-6;
221  double relat = -2.0 * radius * std::log(1.0 + (travt/r));
222 
223  // Compute the time difference at SSB
224  double tdelta = travt - relat + this->tdelta();
225 
226  // Return
227  return tdelta;
228 }
229 
230 
231 /***********************************************************************//**
232  * @brief Print COMPTEL Solar System Barycentre Data
233  *
234  * @param[in] chatter Chattiness.
235  * @return String containing COMPTEL Solar System Barycentre Data
236  * information.
237  ***************************************************************************/
238 std::string GCOMBvc::print(const GChatter& chatter) const
239 {
240  // Initialise result string
241  std::string result;
242 
243  // Continue only if chatter is not silent
244  if (chatter != SILENT) {
245 
246  // Append header
247  result.append("=== GCOMBvc ===");
248 
249  // Append information
250  result.append("\n"+gammalib::parformat("COMPTEL time"));
251  result.append(gammalib::str(m_tjd));
252  result.append(":");
253  result.append(gammalib::str(m_tics));
254  result.append("\n"+gammalib::parformat("MJD"));
255  result.append(gammalib::str(m_time.mjd()));
256  result.append(" days");
257  result.append("\n"+gammalib::parformat("UTC"));
258  result.append(m_time.utc());
259 
260  } // endif: chatter was not silent
261 
262  // Return result
263  return result;
264 }
265 
266 
267 /*==========================================================================
268  = =
269  = Private methods =
270  = =
271  ==========================================================================*/
272 
273 /***********************************************************************//**
274  * @brief Initialise class members
275  ***************************************************************************/
277 {
278  // Initialise members
279  m_time.clear();
280  m_ssb.clear();
281  m_tjd = 0;
282  m_tics = 0;
283  m_tdelta = 0.0;
284 
285  // Return
286  return;
287 }
288 
289 
290 /***********************************************************************//**
291  * @brief Copy class members
292  *
293  * @param[in] bvc COMPTEL Solar System Barycentre Data.
294  ***************************************************************************/
296 {
297  // Copy members
298  m_time = bvc.m_time;
299  m_tjd = bvc.m_tjd;
300  m_tics = bvc.m_tics;
301  m_ssb = bvc.m_ssb;
302  m_tdelta = bvc.m_tdelta;
303 
304  // Return
305  return;
306 }
307 
308 
309 /***********************************************************************//**
310  * @brief Delete class members
311  ***************************************************************************/
313 {
314  // Return
315  return;
316 }
virtual ~GCOMBvc(void)
Destructor.
Definition: GCOMBvc.cpp:84
double norm(const GVector &vector)
Computes vector norm.
Definition: GVector.cpp:864
GTime m_time
Time for Solar System Barycentre Data.
Definition: GCOMBvc.hpp:86
void init_members(void)
Initialise class members.
Definition: GCOMBvc.cpp:276
Sky direction class interface definition.
COMPTEL Solar System Barycentre Data class.
Definition: GCOMBvc.hpp:49
void clear(void)
Clear time.
Definition: GTime.cpp:252
void copy_members(const GCOMBvc &bvc)
Copy class members.
Definition: GCOMBvc.cpp:295
Gammalib tools definition.
COMPTEL Solar System Barycentre Data class definition.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL Solar System Barycentre Data.
Definition: GCOMBvc.cpp:238
void clear(void)
Clear vector.
Definition: GVector.cpp:489
double m_tdelta
Time difference TDB-UTC (sec)
Definition: GCOMBvc.hpp:90
int m_tjd
TJD of Solar System Barycentre Data.
Definition: GCOMBvc.hpp:87
virtual void clear(void)
Clear COMPTEL Solar System Barycentre Data.
Definition: GCOMBvc.cpp:136
GCOMBvc(void)
Void constructor.
Definition: GCOMBvc.cpp:53
void celvector(const GVector &vector)
Set sky direction from 3D vector in celestial coordinates.
Definition: GSkyDir.cpp:313
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
Definition: GVector.cpp:1274
virtual GCOMBvc * clone(void) const
Clone COMPTEL Solar System Barycentre Data.
Definition: GCOMBvc.cpp:154
GChatter
Definition: GTypemaps.hpp:33
GVector m_ssb
Solar System Barycentre vector in celestial system (micro seconds)
Definition: GCOMBvc.hpp:89
double mjd(void) const
Return time in Modified Julian Days (TT)
Definition: GTime.cpp:320
Vector class.
Definition: GVector.hpp:46
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition: GTools.cpp:1143
const double & tdelta(void) const
Return TDB-UTC time difference.
Definition: GCOMBvc.hpp:236
int m_tics
Tics of Solar System Barycentre Data.
Definition: GCOMBvc.hpp:88
Sky direction class.
Definition: GSkyDir.hpp:62
std::string utc(const int &precision=0) const
Return time as string in UTC time system.
Definition: GTime.cpp:465
void free_members(void)
Delete class members.
Definition: GCOMBvc.cpp:312
GCOMBvc & operator=(const GCOMBvc &bvc)
Assignment operator.
Definition: GCOMBvc.cpp:106
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:489