Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MPIfR-BDG
psrdada_cpp
Commits
a96112a2
Commit
a96112a2
authored
Jul 15, 2021
by
Jason Wu
Browse files
adding correct MJD_START for all pol merger and dada writer.
parent
de4c3c1c
Pipeline
#105744
passed with stages
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
psrdada_cpp/effelsberg/edd/src/EDDPolnMerge.cpp
View file @
a96112a2
...
...
@@ -58,30 +58,13 @@ void EDDPolnMerge::init(RawBytes& block)
long
double
sample_clock
=
std
::
strtold
(
buffer
,
NULL
);
ascii_header_get
(
block
.
ptr
(),
"SYNC_TIME"
,
"%s"
,
buffer
);
long
double
sync_time
=
std
::
strtold
(
buffer
,
NULL
);
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock_start "
<<
sample_clock_start
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock "
<<
sample_clock
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sync_time "
<<
sync_time
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock_start / sample_clock "
<<
sample_clock_start
/
sample_clock
;
long
double
unix_time
=
sync_time
+
(
sample_clock_start
/
sample_clock
);
char
time_buffer
[
80
];
std
::
time_t
unix_time_int
;
struct
std
::
tm
*
timeinfo
;
double
fractpart
,
intpart
;
fractpart
=
std
::
modf
(
static_cast
<
double
>
(
unix_time
)
,
&
intpart
);
unix_time_int
=
static_cast
<
std
::
time_t
>
(
intpart
);
timeinfo
=
std
::
gmtime
(
&
unix_time_int
);
std
::
strftime
(
time_buffer
,
80
,
"%Y-%m-%d-%H:%M:%S"
,
timeinfo
);
std
::
stringstream
utc_time_stamp
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"unix_time"
<<
unix_time
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"fractional part "
<<
fractpart
;
//BOOST_LOG_TRIVIAL(debug) << "fractional part ." << static_cast<std::size_t>(fractpart*10000000000);
//utc_time_stamp<< time_buffer << "." <<fractpart;
utc_time_stamp
<<
time_buffer
<<
"."
<<
std
::
setw
(
10
)
<<
std
::
setfill
(
'0'
)
<<
std
::
size_t
(
fractpart
*
10000000000
)
<<
std
::
setfill
(
' '
);
//BOOST_LOG_TRIVIAL(debug) << "fractional part" <<static_cast<std::size_t>(fractpart * 10000000000);
//utc_time_stamp<< time_buffer << "." << static_cast<std::size_t>(fractpart * 10000000000);
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is start time in utc "
<<
utc_time_stamp
.
str
().
c_str
()
<<
"
\n
"
;
// std::cout << "this is sync_time MJD "<< mjd_time<< "\n";
ascii_header_set
(
oblock
.
ptr
(),
"UTC_START"
,
"%s"
,
utc_time_stamp
.
str
().
c_str
());
long
double
mjd_time
=
(
unix_time
/
86400.0
)
+
40587
;
std
::
ostringstream
mjd_start
;
mjd_start
<<
std
::
fixed
;
mjd_start
<<
std
::
setprecision
(
12
);
mjd_start
<<
mjd_time
;
ascii_header_set
(
oblock
.
ptr
(),
"MJD_START"
,
"%s"
,
mjd_start
.
str
().
c_str
());
ascii_header_set
(
oblock
.
ptr
(),
"UNIX_TIME"
,
"%Lf"
,
unix_time
);
oblock
.
used_bytes
(
oblock
.
total_bytes
());
_writer
.
header_stream
().
release
();
...
...
psrdada_cpp/effelsberg/edd/src/EDDRoach.cpp
View file @
a96112a2
...
...
@@ -37,37 +37,20 @@ void EDDRoach::init(RawBytes& block)
}
std
::
memcpy
(
oblock
.
ptr
(),
block
.
ptr
(),
block
.
used_bytes
());
char
buffer
[
1024
];
ascii_header_get
(
block
.
ptr
(),
"SAMPLE_CLOCK_START"
,
"%s"
,
buffer
);
std
::
size_t
sample_clock_start
=
std
::
strtoul
(
buffer
,
NULL
,
0
);
ascii_header_get
(
block
.
ptr
(),
"CLOCK_SAMPLE"
,
"%s"
,
buffer
);
long
double
sample_clock
=
std
::
strtold
(
buffer
,
NULL
);
ascii_header_get
(
block
.
ptr
(),
"SYNC_TIME"
,
"%s"
,
buffer
);
long
double
sync_time
=
std
::
strtold
(
buffer
,
NULL
);
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock_start "
<<
sample_clock_start
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock "
<<
sample_clock
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sync_time "
<<
sync_time
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock_start / sample_clock "
<<
sample_clock_start
/
sample_clock
;
long
double
unix_time
=
sync_time
+
(
sample_clock_start
/
sample_clock
);
char
time_buffer
[
80
];
std
::
time_t
unix_time_int
;
struct
std
::
tm
*
timeinfo
;
double
fractpart
,
intpart
;
fractpart
=
std
::
modf
(
static_cast
<
double
>
(
unix_time
)
,
&
intpart
);
unix_time_int
=
static_cast
<
std
::
time_t
>
(
intpart
);
timeinfo
=
std
::
gmtime
(
&
unix_time_int
);
std
::
strftime
(
time_buffer
,
80
,
"%Y-%m-%d-%H:%M:%S"
,
timeinfo
);
std
::
stringstream
utc_time_stamp
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"unix_time"
<<
unix_time
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"fractional part "
<<
fractpart
;
//BOOST_LOG_TRIVIAL(debug) << "fractional part ." << static_cast<std::size_t>(fractpart*10000000000);
//utc_time_stamp<< time_buffer << "." <<fractpart;
utc_time_stamp
<<
time_buffer
<<
"."
<<
std
::
setw
(
10
)
<<
std
::
setfill
(
'0'
)
<<
std
::
size_t
(
fractpart
*
10000000000
)
<<
std
::
setfill
(
' '
);
//BOOST_LOG_TRIVIAL(debug) << "fractional part" <<static_cast<std::size_t>(fractpart * 10000000000);
//utc_time_stamp<< time_buffer << "." << static_cast<std::size_t>(fractpart * 10000000000);
BOOST_LOG_TRIVIAL
(
info
)
<<
"this is start time in utc "
<<
utc_time_stamp
.
str
().
c_str
()
<<
"
\n
"
;
// std::cout << "this is sync_time MJD "<< mjd_time<< "\n";
ascii_header_set
(
oblock
.
ptr
(),
"UTC_START"
,
"%s"
,
utc_time_stamp
.
str
().
c_str
());
ascii_header_set
(
oblock
.
ptr
(),
"UNIX_TIME"
,
"%Lf"
,
unix_time
);
ascii_header_get
(
block
.
ptr
(),
"SAMPLE_CLOCK_START"
,
"%s"
,
buffer
);
std
::
size_t
sample_clock_start
=
std
::
strtoul
(
buffer
,
NULL
,
0
);
ascii_header_get
(
block
.
ptr
(),
"CLOCK_SAMPLE"
,
"%s"
,
buffer
);
long
double
sample_clock
=
std
::
strtold
(
buffer
,
NULL
);
ascii_header_get
(
block
.
ptr
(),
"SYNC_TIME"
,
"%s"
,
buffer
);
long
double
sync_time
=
std
::
strtold
(
buffer
,
NULL
);
long
double
unix_time
=
sync_time
+
(
sample_clock_start
/
sample_clock
);
long
double
mjd_time
=
(
unix_time
/
86400.0
)
+
40587
;
std
::
ostringstream
mjd_start
;
mjd_start
<<
std
::
fixed
;
mjd_start
<<
std
::
setprecision
(
12
);
mjd_start
<<
mjd_time
;
ascii_header_set
(
oblock
.
ptr
(),
"MJD_START"
,
"%s"
,
mjd_start
.
str
().
c_str
());
ascii_header_set
(
oblock
.
ptr
(),
"UNIX_TIME"
,
"%Lf"
,
unix_time
);
oblock
.
used_bytes
(
oblock
.
total_bytes
());
_writer
.
header_stream
().
release
();
}
...
...
psrdada_cpp/effelsberg/edd/src/EDDRoach_merge.cpp
View file @
a96112a2
...
...
@@ -29,38 +29,21 @@ void EDDRoach_merge::init(RawBytes& block)
throw
std
::
runtime_error
(
"Output DADA buffer does not have enough space for header"
);
}
std
::
memcpy
(
oblock
.
ptr
(),
block
.
ptr
(),
block
.
used_bytes
());
char
buffer
[
1024
];
ascii_header_get
(
block
.
ptr
(),
"SAMPLE_CLOCK_START"
,
"%s"
,
buffer
);
std
::
size_t
sample_clock_start
=
std
::
strtoul
(
buffer
,
NULL
,
0
);
ascii_header_get
(
block
.
ptr
(),
"CLOCK_SAMPLE"
,
"%s"
,
buffer
);
long
double
sample_clock
=
std
::
strtold
(
buffer
,
NULL
);
ascii_header_get
(
block
.
ptr
(),
"SYNC_TIME"
,
"%s"
,
buffer
);
long
double
sync_time
=
std
::
strtold
(
buffer
,
NULL
);
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock_start "
<<
sample_clock_start
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock "
<<
sample_clock
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sync_time "
<<
sync_time
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock_start / sample_clock "
<<
sample_clock_start
/
sample_clock
;
long
double
unix_time
=
sync_time
+
(
sample_clock_start
/
sample_clock
);
char
time_buffer
[
80
];
std
::
time_t
unix_time_int
;
struct
std
::
tm
*
timeinfo
;
double
fractpart
,
intpart
;
fractpart
=
std
::
modf
(
static_cast
<
double
>
(
unix_time
)
,
&
intpart
);
unix_time_int
=
static_cast
<
std
::
time_t
>
(
intpart
);
timeinfo
=
std
::
gmtime
(
&
unix_time_int
);
std
::
strftime
(
time_buffer
,
80
,
"%Y-%m-%d-%H:%M:%S"
,
timeinfo
);
std
::
stringstream
utc_time_stamp
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"unix_time"
<<
unix_time
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"fractional part "
<<
fractpart
;
//BOOST_LOG_TRIVIAL(debug) << "fractional part ." << static_cast<std::size_t>(fractpart*10000000000);
//utc_time_stamp<< time_buffer << "." <<fractpart;
utc_time_stamp
<<
time_buffer
<<
"."
<<
std
::
setw
(
10
)
<<
std
::
setfill
(
'0'
)
<<
std
::
size_t
(
fractpart
*
10000000000
)
<<
std
::
setfill
(
' '
);
//BOOST_LOG_TRIVIAL(debug) << "fractional part" <<static_cast<std::size_t>(fractpart * 10000000000);
//utc_time_stamp<< time_buffer << "." << static_cast<std::size_t>(fractpart * 10000000000);
BOOST_LOG_TRIVIAL
(
info
)
<<
"this is start time in utc "
<<
utc_time_stamp
.
str
().
c_str
()
<<
"
\n
"
;
// std::cout << "this is sync_time MJD "<< mjd_time<< "\n";
ascii_header_set
(
oblock
.
ptr
(),
"UTC_START"
,
"%s"
,
utc_time_stamp
.
str
().
c_str
());
ascii_header_set
(
oblock
.
ptr
(),
"UNIX_TIME"
,
"%Lf"
,
unix_time
);
char
buffer
[
1024
];
ascii_header_get
(
block
.
ptr
(),
"SAMPLE_CLOCK_START"
,
"%s"
,
buffer
);
std
::
size_t
sample_clock_start
=
std
::
strtoul
(
buffer
,
NULL
,
0
);
ascii_header_get
(
block
.
ptr
(),
"CLOCK_SAMPLE"
,
"%s"
,
buffer
);
long
double
sample_clock
=
std
::
strtold
(
buffer
,
NULL
);
ascii_header_get
(
block
.
ptr
(),
"SYNC_TIME"
,
"%s"
,
buffer
);
long
double
sync_time
=
std
::
strtold
(
buffer
,
NULL
);
long
double
unix_time
=
sync_time
+
(
sample_clock_start
/
sample_clock
);
long
double
mjd_time
=
(
unix_time
/
86400.0
)
+
40587
;
std
::
ostringstream
mjd_start
;
mjd_start
<<
std
::
fixed
;
mjd_start
<<
std
::
setprecision
(
12
);
mjd_start
<<
mjd_time
;
ascii_header_set
(
oblock
.
ptr
(),
"MJD_START"
,
"%s"
,
mjd_start
.
str
().
c_str
());
ascii_header_set
(
oblock
.
ptr
(),
"UNIX_TIME"
,
"%Lf"
,
unix_time
);
oblock
.
used_bytes
(
oblock
.
total_bytes
());
_writer
.
header_stream
().
release
();
}
...
...
psrdada_cpp/effelsberg/edd/src/EDDRoach_merge_leap.cpp
View file @
a96112a2
...
...
@@ -36,39 +36,21 @@ void EDDRoach_merge_leap::init(RawBytes& block)
throw
std
::
runtime_error
(
"Output DADA buffer does not have enough space for header"
);
}
std
::
memcpy
(
oblock
.
ptr
(),
block
.
ptr
(),
block
.
used_bytes
());
char
buffer
[
1024
];
ascii_header_get
(
block
.
ptr
(),
"SAMPLE_CLOCK_START"
,
"%s"
,
buffer
);
std
::
size_t
sample_clock_start
=
std
::
strtoul
(
buffer
,
NULL
,
0
);
ascii_header_get
(
block
.
ptr
(),
"CLOCK_SAMPLE"
,
"%s"
,
buffer
);
long
double
sample_clock
=
std
::
strtold
(
buffer
,
NULL
);
ascii_header_get
(
block
.
ptr
(),
"SYNC_TIME"
,
"%s"
,
buffer
);
long
double
sync_time
=
std
::
strtold
(
buffer
,
NULL
);
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock_start "
<<
sample_clock_start
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock "
<<
sample_clock
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sync_time "
<<
sync_time
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"this is sample_clock_start / sample_clock "
<<
sample_clock_start
/
sample_clock
;
long
double
unix_time
=
sync_time
+
(
sample_clock_start
/
sample_clock
);
char
time_buffer
[
80
];
std
::
time_t
unix_time_int
;
struct
std
::
tm
*
timeinfo
;
double
fractpart
,
intpart
;
fractpart
=
std
::
modf
(
static_cast
<
double
>
(
unix_time
)
,
&
intpart
);
unix_time_int
=
static_cast
<
std
::
time_t
>
(
intpart
);
timeinfo
=
std
::
gmtime
(
&
unix_time_int
);
std
::
strftime
(
time_buffer
,
80
,
"%Y-%m-%d-%H:%M:%S"
,
timeinfo
);
std
::
stringstream
utc_time_stamp
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"unix_time"
<<
unix_time
;
BOOST_LOG_TRIVIAL
(
debug
)
<<
"fractional part "
<<
fractpart
;
//BOOST_LOG_TRIVIAL(debug) << "fractional part ." << static_cast<std::size_t>(fractpart*10000000000);
//utc_time_stamp<< time_buffer << "." <<fractpart;
utc_time_stamp
<<
time_buffer
<<
"."
<<
std
::
setw
(
10
)
<<
std
::
setfill
(
'0'
)
<<
std
::
size_t
(
fractpart
*
10000000000
)
<<
std
::
setfill
(
' '
);
//BOOST_LOG_TRIVIAL(debug) << "fractional part" <<static_cast<std::size_t>(fractpart * 10000000000);
//utc_time_stamp<< time_buffer << "." << static_cast<std::size_t>(fractpart * 10000000000);
BOOST_LOG_TRIVIAL
(
info
)
<<
"this is start time in utc "
<<
utc_time_stamp
.
str
().
c_str
()
<<
"
\n
"
;
// std::cout << "this is sync_time MJD "<< mjd_time<< "\n";
// ascii_header_set(oblock.ptr(), "MJD", "%s", utc_time_stamp.str().c_str());
ascii_header_set
(
oblock
.
ptr
(),
"UTC_START"
,
"%s"
,
utc_time_stamp
.
str
().
c_str
());
ascii_header_set
(
oblock
.
ptr
(),
"UNIX_TIME"
,
"%Lf"
,
unix_time
);
char
buffer
[
1024
];
ascii_header_get
(
block
.
ptr
(),
"SAMPLE_CLOCK_START"
,
"%s"
,
buffer
);
std
::
size_t
sample_clock_start
=
std
::
strtoul
(
buffer
,
NULL
,
0
);
ascii_header_get
(
block
.
ptr
(),
"CLOCK_SAMPLE"
,
"%s"
,
buffer
);
long
double
sample_clock
=
std
::
strtold
(
buffer
,
NULL
);
ascii_header_get
(
block
.
ptr
(),
"SYNC_TIME"
,
"%s"
,
buffer
);
long
double
sync_time
=
std
::
strtold
(
buffer
,
NULL
);
long
double
unix_time
=
sync_time
+
(
sample_clock_start
/
sample_clock
);
long
double
mjd_time
=
(
unix_time
/
86400.0
)
+
40587
;
std
::
ostringstream
mjd_start
;
mjd_start
<<
std
::
fixed
;
mjd_start
<<
std
::
setprecision
(
12
);
mjd_start
<<
mjd_time
;
ascii_header_set
(
oblock
.
ptr
(),
"MJD_START"
,
"%s"
,
mjd_start
.
str
().
c_str
());
ascii_header_set
(
oblock
.
ptr
(),
"UNIX_TIME"
,
"%Lf"
,
unix_time
);
oblock
.
used_bytes
(
oblock
.
total_bytes
());
_writer
.
header_stream
().
release
();
}
...
...
psrdada_cpp/effelsberg/edd/src/dada_disk_sink_leap.cpp
View file @
a96112a2
...
...
@@ -30,6 +30,21 @@ void DiskSinkLeap::init(RawBytes& block)
ascii_header_set
(
_header
,
"BW"
,
"%s"
,
"16"
);
ascii_header_get
(
_header
,
"UTC_START"
,
"%s"
,
_start_time
);
BOOST_LOG_TRIVIAL
(
debug
)
<<
"UTC_START = "
<<
_start_time
;
char
buffer
[
1024
];
ascii_header_get
(
block
.
ptr
(),
"SAMPLE_CLOCK_START"
,
"%s"
,
buffer
);
std
::
size_t
sample_clock_start
=
std
::
strtoul
(
buffer
,
NULL
,
0
);
ascii_header_get
(
block
.
ptr
(),
"CLOCK_SAMPLE"
,
"%s"
,
buffer
);
long
double
sample_clock
=
std
::
strtold
(
buffer
,
NULL
);
ascii_header_get
(
block
.
ptr
(),
"SYNC_TIME"
,
"%s"
,
buffer
);
long
double
sync_time
=
std
::
strtold
(
buffer
,
NULL
);
long
double
unix_time
=
sync_time
+
(
sample_clock_start
/
sample_clock
);
long
double
mjd_time
=
(
unix_time
/
86400.0
)
+
40587
;
std
::
ostringstream
mjd_start
;
mjd_start
<<
std
::
fixed
;
mjd_start
<<
std
::
setprecision
(
12
);
mjd_start
<<
mjd_time
;
ascii_header_set
(
_header
,
"MJD_START"
,
"%s"
,
mjd_start
.
str
().
c_str
());
ascii_header_set
(
_header
,
"UNIX_TIME"
,
"%Lf"
,
unix_time
);
}
bool
DiskSinkLeap
::
operator
()(
RawBytes
&
block
)
{
...
...
psrdada_cpp/effelsberg/edd/src/dada_disk_sink_multithread.cpp
View file @
a96112a2
...
...
@@ -28,6 +28,21 @@ void DiskSinkMultithread::init(RawBytes& block)
std
::
memcpy
(
&
_header
,
block
.
ptr
(),
block
.
used_bytes
());
ascii_header_get
(
_header
,
"UTC_START"
,
"%s"
,
_start_time
);
BOOST_LOG_TRIVIAL
(
debug
)
<<
"UTC_START = "
<<
_start_time
;
char
buffer
[
1024
];
ascii_header_get
(
block
.
ptr
(),
"SAMPLE_CLOCK_START"
,
"%s"
,
buffer
);
std
::
size_t
sample_clock_start
=
std
::
strtoul
(
buffer
,
NULL
,
0
);
ascii_header_get
(
block
.
ptr
(),
"CLOCK_SAMPLE"
,
"%s"
,
buffer
);
long
double
sample_clock
=
std
::
strtold
(
buffer
,
NULL
);
ascii_header_get
(
block
.
ptr
(),
"SYNC_TIME"
,
"%s"
,
buffer
);
long
double
sync_time
=
std
::
strtold
(
buffer
,
NULL
);
long
double
unix_time
=
sync_time
+
(
sample_clock_start
/
sample_clock
);
long
double
mjd_time
=
(
unix_time
/
86400.0
)
+
40587
;
std
::
ostringstream
mjd_start
;
mjd_start
<<
std
::
fixed
;
mjd_start
<<
std
::
setprecision
(
12
);
mjd_start
<<
mjd_time
;
ascii_header_set
(
_header
,
"MJD_START"
,
"%s"
,
mjd_start
.
str
().
c_str
());
ascii_header_set
(
_header
,
"UNIX_TIME"
,
"%Lf"
,
unix_time
);
}
bool
DiskSinkMultithread
::
operator
()(
RawBytes
&
block
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment