LALApps
10.1.0.1-eeff03c
LALSuite
LAL
LALFrame
LALMetaIO
LALSimulation
LALBurst
LALInspiral
LALInference
LALPulsar
LALApps
gpstime.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2007 Jolien Creighton
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
#include "config.h"
21
22
#include <math.h>
23
#include <lal/LALStdlib.h>
24
#include <
LALAppsVCSInfo.h
>
25
#include "
gpstime.h
"
26
27
/* one second in nano seconds as an INT8 */
28
#define I8_SEC_NS LAL_INT8_C(1000000000)
29
30
/* one second in nano seconds as a REAL8 */
31
#define D_SEC_NS (1e9)
32
33
/* one nano seconds in seconds as a REAL8 */
34
#define D_NS_SEC (1e-9)
35
36
37
/* express LIGOTimeGPS as INT8 nanoseconds */
38
INT8
epoch_to_ns
(
LIGOTimeGPS
*epoch )
39
{
40
INT8
ns
;
41
ns
= (
INT8
)(
epoch
->gpsSeconds) *
I8_SEC_NS
;
42
ns
+= (
INT8
)(
epoch
->gpsNanoSeconds);
43
return
ns
;
44
}
45
46
47
/* convert INT8 nanoseconds to LIGOTimeGPS epoch */
48
LIGOTimeGPS
*
ns_to_epoch
(
LIGOTimeGPS
*epoch,
INT8
ns )
49
{
50
epoch
->gpsSeconds = (
INT4
)(
ns
/
I8_SEC_NS
);
51
epoch
->gpsNanoSeconds = (
INT4
)(
ns
%
I8_SEC_NS
);
52
return
epoch
;
53
}
54
55
56
/* convert REAL8 seconds to INT8 nanoseconds */
57
INT8
sec_to_ns
(
REAL8
sec )
58
{
59
INT8
ns
;
60
ns
= (
INT8
) floor(
D_SEC_NS
* sec );
61
return
ns
;
62
}
63
64
65
/* convert INT8 nanoseconds to REAL8 seconds */
66
REAL8
ns_to_sec
(
INT8
ns )
67
{
68
REAL8
sec;
69
sec =
D_NS_SEC
*
ns
;
70
return
sec;
71
}
LALAppsVCSInfo.h
sec_to_ns
INT8 sec_to_ns(REAL8 sec)
Definition:
gpstime.c:57
ns_to_epoch
LIGOTimeGPS * ns_to_epoch(LIGOTimeGPS *epoch, INT8 ns)
Definition:
gpstime.c:48
D_SEC_NS
#define D_SEC_NS
Definition:
gpstime.c:31
I8_SEC_NS
#define I8_SEC_NS
Definition:
gpstime.c:28
ns_to_sec
REAL8 ns_to_sec(INT8 ns)
Definition:
gpstime.c:66
epoch_to_ns
INT8 epoch_to_ns(LIGOTimeGPS *epoch)
Definition:
gpstime.c:38
D_NS_SEC
#define D_NS_SEC
Definition:
gpstime.c:34
gpstime.h
REAL8
double REAL8
INT8
int64_t INT8
INT4
int32_t INT4
ns
ns
LIGOTimeGPS
epoch
enum @1 epoch
src
ring
gpstime.c
Generated on Mon Dec 15 2025 05:33:37 for LALApps by
1.9.4