27 void usage(
const char* program_name)
29 std::cout <<
"Usage:\n"
30 <<
"\t" << program_name <<
" [options] input_filterbank_files... output_filterbank_file\n"
32 <<
"\tCatenates all input_filterbank_files to output_filterbank_file,\n"
33 <<
"\twith appropriatw src_file header field pointing to the first file\n"
35 <<
"\t--as_time_series: save as multiple channels (time series)\n"
36 <<
"\t--as_filterbank : save as multiple spectra (filterbank)\n"
37 <<
"\t--help : this message\n";
41 template<
typename SigProcTraits>
46 , std::ostream& output_file
47 , std::vector<std::string> files
48 , std::ifstream& input_file
49 ,
bool as_time_series)
55 typename SigProcTraits::DataType data(number_of_channels,
58 typename SigProcTraits::Adapter sigproc_adapter;
60 unsigned file_index = 0;
62 while(!input_file.eof()) {
63 input_file >> sigproc_adapter >> data;
67 output_file << pss::astrotypes::sigproc::SigProcFormat<pss::astrotypes::units::Frequency, pss::astrotypes::units::Time>() << data;
71 output_file << pss::astrotypes::sigproc::SigProcFormat<pss::astrotypes::units::Time, pss::astrotypes::units::Frequency>() << data;
77 if(++file_index < files.size()) {
78 input_file.open(files[file_index]);
81 if(header.number_of_bits() !=
sizeof(
typename decltype(data)::value_type)) {
82 std::cerr <<
"Error: file " << files[file_index]
83 <<
" has " << header.number_of_bits() <<
" bit data."
84 <<
" (expecting " <<
sizeof(
typename decltype(data)::value_type) <<
" bits)";
94 int main(
int argc,
char** argv) {
96 bool as_time_series =
false;
97 bool as_filterbank =
false;
98 std::vector<std::string> files;
101 for(
int a=1; a < argc; ++a) {
102 if((
char)argv[a][0] ==
'-') {
103 if(std::string(
"--as_time_series") == argv[a])
105 as_time_series =
true;
107 if(std::string(
"--as_filterbank") == argv[a])
109 as_filterbank =
true;
111 else if(std::string(
"--help") == argv[a])
117 std::cerr <<
"unknown parameter " << argv[a] << std::endl;
122 files.push_back(argv[a]);
124 if(files.size() < 2) {
125 std::cerr <<
"Must specify one or more input files and an output file" << std::endl;
129 if( as_time_series && as_filterbank ) {
130 std::cerr <<
"--as_filterbank and --as_time_series are mutually incompatible" << std::endl;
132 std::string out_file = files.back();
136 std::ifstream input_file_stream(argv[1], std::ios::binary);
139 input_file_stream >> header;
142 std::cout << pss::astrotypes::sigproc::Header::Info() << header;
153 std::ofstream output_file(out_file);
154 output_file << header;
158 , header.number_of_channels()
int main(int argc, char **argv)
A compile time dimesion tagging of size_t.
static bool exec(pss::astrotypes::DimensionSize< pss::astrotypes::units::Frequency > number_of_channels, std::ostream &output_file, std::vector< std::string > files, std::ifstream &input_file, bool as_time_series)
static void exec(Header const &h, Args &&...args)
void usage(const char *program_name)