GammaLib 2.2.0.dev
Loading...
Searching...
No Matches
GCOSTools.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCOSTools.cpp - COSI tools *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2026 by Juergen Knoedlseder *
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 GCOSTools.hpp
23 * @brief Implementation of COSI tools
24 * @author Juergen Knoedlseder
25 */
26
27/* __ Includes ___________________________________________________________ */
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31#include "GCOSTools.hpp"
32
33/* __ Method name definitions ____________________________________________ */
34
35/* __ Coding definitions _________________________________________________ */
36
37/* __ Debug definitions __________________________________________________ */
38
39
40/***********************************************************************//**
41 * @brief Convert COSI seconds to GammaLib time
42 *
43 * @param[in] seconds COSI time in seconds
44 * @return GammaLib time.
45 *
46 * The COSI time is specified in Unix time which is seconds from
47 * 1970-01-01 00:00:00 UTC, ignoring leap seconds.
48 ***************************************************************************/
49GTime gammalib::cos_time(const double& seconds)
50{
51 // Set time reference for Unix seconds
52 static const GTimeReference tref(40587.00048824074, "sec");
53
54 // Convert COSI seconds to GammaLib time
55 GTime time(seconds, tref);
56
57 // Return time
58 return time;
59}
60
61
62/***********************************************************************//**
63 * @brief Convert GammaLib time to COSI seconds
64 *
65 * @param[in] time GammaLib time
66 * @return COSI time in seconds.
67 *
68 * The COSI time is specified in Unix time which is seconds from
69 * 1970-01-01 00:00:00 UTC, ignoring leap seconds.
70 ***************************************************************************/
71double gammalib::cos_seconds(const GTime& time)
72{
73 // Set time reference for Unix seconds
74 static const GTimeReference tref(40587.00048824074, "sec");
75
76 // Convert GammaLib time to COSI seconds
77 double seconds = time.convert(tref);
78
79 // Return COSI seconds
80 return seconds;
81}
Definition of COSI tools.
Implements a time reference.
Time class.
Definition GTime.hpp:55
double convert(const GTimeReference &ref) const
Return time in specified reference.
Definition GTime.cpp:711
double cos_seconds(const GTime &time)
Convert GammaLib time to COSI seconds.
Definition GCOSTools.cpp:71
GTime cos_time(const double &seconds)
Convert COSI seconds to GammaLib time.
Definition GCOSTools.cpp:49