Commit 7083166f authored by thomas.forbriger's avatar thomas.forbriger
Browse files

croposp [WP]: provide all commandline parameters to output function

parent b2d40aea
...@@ -47,22 +47,6 @@ using std::cout; ...@@ -47,22 +47,6 @@ using std::cout;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
struct Options {
bool verbose, trim, debug, overwrite;
std::string inputformat, labelpattern;
double datetolerance;
bool logscale;
unsigned int n_per_decade;
unsigned int nsegments, divisor, padfactor;
double overlap;
bool compute_psd, compute_npsd, compute_coherency, compute_transfer;
bool compute_phase;
std::string outfile_psd, outfile_npsd, outfile_coherency, outfile_transfer;
std::string outfile_phase;
std::string prefix_psd, prefix_npsd, prefix_transfer;
std::string prefix_phase, prefix_coherency;
}; // struct Options
/* ====================================================================== */ /* ====================================================================== */
// define usage information // define usage information
...@@ -236,7 +220,7 @@ int main(int iargc, char* argv[]) ...@@ -236,7 +220,7 @@ int main(int iargc, char* argv[])
exit(0); exit(0);
} }
Options opt; croposp::Options opt;
opt.verbose=cmdline.optset(1); opt.verbose=cmdline.optset(1);
opt.inputformat=cmdline.string_arg(2); opt.inputformat=cmdline.string_arg(2);
opt.trim=cmdline.optset(3); opt.trim=cmdline.optset(3);
...@@ -469,10 +453,7 @@ int main(int iargc, char* argv[]) ...@@ -469,10 +453,7 @@ int main(int iargc, char* argv[])
{ {
write_named_series(opt.outfile_psd, write_named_series(opt.outfile_psd,
"total power spectral density of signals", "total power spectral density of signals",
frequencies, frequencies, PSD_vector, opt);
PSD_vector,
opt.verbose,
opt.overwrite);
} // if (opt.compute_psd) } // if (opt.compute_psd)
} // if (opt.compute_psd || opt.compute_npsd || } // if (opt.compute_psd || opt.compute_npsd ||
// opt.compute_coherency) // opt.compute_coherency)
...@@ -617,10 +598,7 @@ int main(int iargc, char* argv[]) ...@@ -617,10 +598,7 @@ int main(int iargc, char* argv[])
write_named_series(opt.outfile_coherency, write_named_series(opt.outfile_coherency,
"coherency of pairs of signals", "coherency of pairs of signals",
frequencies, frequencies, coherency_vector, opt);
coherency_vector,
opt.verbose,
opt.overwrite);
} // if (opt.compute_coherency) } // if (opt.compute_coherency)
...@@ -673,10 +651,7 @@ int main(int iargc, char* argv[]) ...@@ -673,10 +651,7 @@ int main(int iargc, char* argv[])
write_named_series(opt.outfile_phase, write_named_series(opt.outfile_phase,
"phase transfer function of pairs of signals", "phase transfer function of pairs of signals",
frequencies, frequencies, phase_vector, opt);
phase_vector,
opt.verbose,
opt.overwrite);
} // if (opt.compute_phase) } // if (opt.compute_phase)
...@@ -727,10 +702,7 @@ int main(int iargc, char* argv[]) ...@@ -727,10 +702,7 @@ int main(int iargc, char* argv[])
write_named_series(opt.outfile_transfer, write_named_series(opt.outfile_transfer,
"amplitude transfer ratio of pairs of signals", "amplitude transfer ratio of pairs of signals",
frequencies, frequencies, transfer_vector, opt);
transfer_vector,
opt.verbose,
opt.overwrite);
} // if (opt.compute_transfer) } // if (opt.compute_transfer)
...@@ -813,10 +785,7 @@ int main(int iargc, char* argv[]) ...@@ -813,10 +785,7 @@ int main(int iargc, char* argv[])
write_named_series(opt.outfile_npsd, write_named_series(opt.outfile_npsd,
"power spectral density of incoherent component", "power spectral density of incoherent component",
frequencies, frequencies, npsd_vector, opt);
npsd_vector,
opt.verbose,
opt.overwrite);
} // if (opt.compute_npsd) } // if (opt.compute_npsd)
......
...@@ -49,6 +49,23 @@ ...@@ -49,6 +49,23 @@
namespace croposp { namespace croposp {
// a structure to hold all commanline parameters
struct Options {
bool verbose, trim, debug, overwrite;
std::string inputformat, labelpattern;
double datetolerance;
bool logscale;
unsigned int n_per_decade;
unsigned int nsegments, divisor, padfactor;
double overlap;
bool compute_psd, compute_npsd, compute_coherency, compute_transfer;
bool compute_phase;
std::string outfile_psd, outfile_npsd, outfile_coherency, outfile_transfer;
std::string outfile_phase;
std::string prefix_psd, prefix_npsd, prefix_transfer;
std::string prefix_phase, prefix_coherency;
}; // struct Options
// a struct to hold meta data // a struct to hold meta data
struct Meta { struct Meta {
tfxx::cmdline::Filename filearguments; tfxx::cmdline::Filename filearguments;
...@@ -139,8 +156,7 @@ namespace croposp { ...@@ -139,8 +156,7 @@ namespace croposp {
const std::string& comment, const std::string& comment,
psd::TDseries f, psd::TDseries f,
const TNamedSeriesVector& nsv, const TNamedSeriesVector& nsv,
const bool& verbose, const Options& opt);
const bool& overwrite=true);
} // namespace croposp } // namespace croposp
......
...@@ -46,16 +46,15 @@ namespace croposp { ...@@ -46,16 +46,15 @@ namespace croposp {
const std::string& comment, const std::string& comment,
psd::TDseries f, psd::TDseries f,
const TNamedSeriesVector& nsv, const TNamedSeriesVector& nsv,
const bool& verbose, const Options& opt)
const bool& overwrite)
{ {
if (verbose) if (opt.verbose)
{ {
cout << endl cout << endl
<< "output to file " << filename << ":" << endl << "output to file " << filename << ":" << endl
<< comment << endl; << comment << endl;
} }
if (!overwrite) if (!opt.overwrite)
{ {
std::ifstream file(filename.c_str(), std::ios_base::in); std::ifstream file(filename.c_str(), std::ios_base::in);
TFXX_assert((!file.good()),"ERROR: output file exists!"); TFXX_assert((!file.good()),"ERROR: output file exists!");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment