Skip to content
This repository was archived by the owner on Aug 12, 2024. It is now read-only.

Commit 34a4e8f

Browse files
author
kruithof
committed
Added a check to produce_html_plotpage to see whether the correlation
file is empty. We do not block then, but terminate with a message. git-svn-id: svn+ssh://jop91.astron.nl/auto/home/jive_cvs/SOFTC/svn/trunk/sfxc@801 5736e3ea-d426-0410-8aaf-93e336ac3372
1 parent 7ae41d3 commit 34a4e8f

5 files changed

+33
-11
lines changed

utils/baseline_info.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,13 @@ int main(int argc, char *argv[]) {
5555
}
5656

5757
// read the data in
58-
Fringe_info_container fringes(input);
58+
Fringe_info_container fringes(input, /* stop at eof */ true);
5959

60+
if (fringes.eof()) {
61+
std::cout << "Empty correlation file" << std::endl;
62+
return 1;
63+
}
64+
6065
std::ofstream out("baseline.txt");
6166
out << "# fringe_pos, phase (max), ampl (max), phase (center), ampl (center), snr, weight" << std::endl;
6267

utils/fringe_info.cc

+10-4
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ int Fringe_info::max_value_offset() const {
121121

122122
// Fringe_info_container
123123

124-
Fringe_info_container::Fringe_info_container(FILE *input) : input(input) {
125-
//`read-in the global header
124+
Fringe_info_container::
125+
Fringe_info_container(FILE *input, bool stop_at_eof) : input(input) {
126+
// read-in the global header
126127
read_data_from_file(sizeof(Output_header_global),
127-
(char *)&global_header, false);
128+
(char *)&global_header, stop_at_eof);
129+
if (eof()) return;
128130

129131
data_freq.resize(global_header.number_channels+1);
130132
data_lag.resize(global_header.number_channels+1);
@@ -137,10 +139,14 @@ Fringe_info_container::Fringe_info_container(FILE *input) : input(input) {
137139

138140
// Read the first timeslice header:
139141
read_data_from_file(sizeof(Output_header_timeslice),
140-
(char*)&last_timeslice_header, false);
142+
(char*)&last_timeslice_header, stop_at_eof);
143+
if (eof()) return;
141144
assert(last_timeslice_header.number_baselines != 0);
142145
}
143146

147+
bool Fringe_info_container::eof() {
148+
return feof(input);
149+
}
144150
void
145151
Fringe_info_container::read_data_from_file(int to_read, char * data,
146152
bool stop_at_eof) {

utils/fringe_info.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Fringe_info_container {
4545
typedef Container::iterator iterator;
4646

4747
public:
48-
Fringe_info_container(FILE *input);
48+
Fringe_info_container(FILE *input, bool stop_at_eof);
4949

5050
void read_plots(bool stop_at_eof);
5151

@@ -58,6 +58,7 @@ class Fringe_info_container {
5858
const Fringe_info_container &other_info,
5959
bool relative_error);
6060

61+
bool eof();
6162
private:
6263
void read_data_from_file(int to_read, char * data, bool stop_at_eof);
6364

utils/produce_html_diffpage.cc

+9-4
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,16 @@ int main(int argc, char *argv[]) {
7777

7878

7979
// read the data in
80-
Fringe_info_container fringe_info1(input1);
81-
Fringe_info_container fringe_info2(input2);
80+
Fringe_info_container fringe_info1(input1, /* stop at eof */ true);
81+
Fringe_info_container fringe_info2(input2, /* stop at eof */ true);
8282

83-
fringe_info1.read_plots(true);
84-
fringe_info2.read_plots(true);
83+
if (fringe_info1.eof() || fringe_info2.eof()) {
84+
std::cout << "Empty correlation file" << std::endl;
85+
return 1;
86+
}
87+
88+
fringe_info1.read_plots(/* stop at eof */ true);
89+
fringe_info2.read_plots(/* stop at eof */ true);
8590

8691
fringe_info1.print_diff_html(vex, fringe_info2, false);
8792

utils/produce_html_plotpage.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,12 @@ int main(int argc, char *argv[]) {
127127

128128

129129
// read the data in
130-
Fringe_info_container fringe_info(input);
130+
Fringe_info_container fringe_info(input, !update);
131+
if ((!update) && fringe_info.eof()) {
132+
std::cout << "Empty correlation file" << std::endl;
133+
return 1;
134+
}
135+
131136

132137
do {
133138
fringe_info.read_plots(!update);

0 commit comments

Comments
 (0)