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;
using std::cerr;
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
......@@ -236,7 +220,7 @@ int main(int iargc, char* argv[])
exit(0);
}
Options opt;
croposp::Options opt;
opt.verbose=cmdline.optset(1);
opt.inputformat=cmdline.string_arg(2);
opt.trim=cmdline.optset(3);
......@@ -469,10 +453,7 @@ int main(int iargc, char* argv[])
{
write_named_series(opt.outfile_psd,
"total power spectral density of signals",
frequencies,
PSD_vector,
opt.verbose,
opt.overwrite);
frequencies, PSD_vector, opt);
} // if (opt.compute_psd)
} // if (opt.compute_psd || opt.compute_npsd ||
// opt.compute_coherency)
......@@ -617,10 +598,7 @@ int main(int iargc, char* argv[])
write_named_series(opt.outfile_coherency,
"coherency of pairs of signals",
frequencies,
coherency_vector,
opt.verbose,
opt.overwrite);
frequencies, coherency_vector, opt);
} // if (opt.compute_coherency)
......@@ -673,10 +651,7 @@ int main(int iargc, char* argv[])
write_named_series(opt.outfile_phase,
"phase transfer function of pairs of signals",
frequencies,
phase_vector,
opt.verbose,
opt.overwrite);
frequencies, phase_vector, opt);
} // if (opt.compute_phase)
......@@ -727,10 +702,7 @@ int main(int iargc, char* argv[])
write_named_series(opt.outfile_transfer,
"amplitude transfer ratio of pairs of signals",
frequencies,
transfer_vector,
opt.verbose,
opt.overwrite);
frequencies, transfer_vector, opt);
} // if (opt.compute_transfer)
......@@ -813,10 +785,7 @@ int main(int iargc, char* argv[])
write_named_series(opt.outfile_npsd,
"power spectral density of incoherent component",
frequencies,
npsd_vector,
opt.verbose,
opt.overwrite);
frequencies, npsd_vector, opt);
} // if (opt.compute_npsd)
......
......@@ -49,6 +49,23 @@
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
struct Meta {
tfxx::cmdline::Filename filearguments;
......@@ -139,8 +156,7 @@ namespace croposp {
const std::string& comment,
psd::TDseries f,
const TNamedSeriesVector& nsv,
const bool& verbose,
const bool& overwrite=true);
const Options& opt);
} // namespace croposp
......
......@@ -46,16 +46,15 @@ namespace croposp {
const std::string& comment,
psd::TDseries f,
const TNamedSeriesVector& nsv,
const bool& verbose,
const bool& overwrite)
const Options& opt)
{
if (verbose)
if (opt.verbose)
{
cout << endl
<< "output to file " << filename << ":" << endl
<< comment << endl;
}
if (!overwrite)
if (!opt.overwrite)
{
std::ifstream file(filename.c_str(), std::ios_base::in);
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