Commit a5ce04e8 authored by thomas.forbriger's avatar thomas.forbriger

ts/croposp [FIX]: bug fixes regarding work flow

In cases, where no PSD is required, the PSD computation is skipped. This
was not properly accounted for in the checks done in the program:

PSD is not required for transfer of phase and the existence of these
value shall not be checked in these cases; check for frequency array
being smaller than 2 (rather than 1); add verbosity output
parent 1a2f7642
......@@ -32,6 +32,11 @@
* its suqare root
* commonly in literature coherence refers to the
* magnitude squared coherence
* - 12/04/2019 V1.3 bux fixes:
* PSD is not required for transfer of phase and the
* existence of these value shall not be checked in
* these cases; check for frequency array being smaller
* than 2 (rather than 1); add verbosity output
*
* ============================================================================
*/
......@@ -39,7 +44,7 @@
* version string is set in croposp.h
*
#define CROPOSP_VERSION \
"CROPOSP V1.2 Cross power spectral density"
"CROPOSP V1.3 Cross power spectral density"
*/
#include "croposp.h"
......@@ -500,11 +505,19 @@ int main(int iargc, char* argv[])
{
if (opt.logscale && !opt.avg_on_output)
{
if (opt.verbose)
{
cout << "Compute logarithmic frequency scale" << endl;
}
frequencies=psd::log_frequency(psd.interval, psd.data.size(),
opt.n_per_decade);
}
else
{
if (opt.verbose)
{
cout << "Compute linear frequency scale" << endl;
}
frequencies=psd::lin_frequency(psd.interval, psd.data.size());
} // if (opt.logscale && !opt.avg_on_output) ... else
} // if (i_series==collection_of_series.begin())
......@@ -549,6 +562,16 @@ int main(int iargc, char* argv[])
// provide container for CPSD values
croposp::TNamedCPSDVector CPSD_vector(pairs.pairs());
if (opt.verbose)
{
cout << endl
<< "Provide storage for " << pairs.pairs() << " pairs "
<< "composed from " << pairs.size() << " signals."
<< endl
<< "CPSD_vector size is " << CPSD_vector.size()
<< endl;
}
if (opt.compute_transfer || opt.compute_phase || opt.compute_npsd ||
opt.compute_coherence)
{
......@@ -589,16 +612,25 @@ int main(int iargc, char* argv[])
TFXX_debug(opt.debug, "croposp",
"CPSD " << TFXX_value(cpsd.data.size()));
//cout << TFXX_value(frequencies.size()) << endl;
// compute array of frequency values, if not yet done
if (frequencies.size()<1)
if (frequencies.size()<2)
{
if (opt.logscale && !opt.avg_on_output)
{
if (opt.verbose)
{
cout << "Compute logarithmic frequency scale" << endl;
}
frequencies=psd::log_frequency(cpsd.interval, cpsd.data.size(),
opt.n_per_decade);
}
else
{
if (opt.verbose)
{
cout << "Compute linear frequency scale" << endl;
}
frequencies=psd::lin_frequency(cpsd.interval, cpsd.data.size());
} // if (opt.logscale && !opt.avg_on_output) ... else
} // if (frequencies.size()<1)
......@@ -704,8 +736,16 @@ int main(int iargc, char* argv[])
croposp::Triples triples(pairs, false);
croposp::TNamedSeriesVector phase_vector(triples.triples());
TFXX_assert(PSD_vector.size()==pairs.size(),
"inconsistency; report this as a bug");
if (opt.verbose)
{
cout << endl
<< "Provide storage for " << triples.triples() << " triples "
<< "composed from " << pairs.size() << " signals."
<< endl
<< "phase_vector size is " << phase_vector.size()
<< endl;
}
TFXX_assert(CPSD_vector.size()==pairs.pairs(),
"inconsistency; report this as a bug");
......@@ -763,8 +803,16 @@ int main(int iargc, char* argv[])
croposp::Triples triples(pairs, false);
croposp::TNamedSeriesVector transfer_vector(triples.triples());
TFXX_assert(PSD_vector.size()==pairs.size(),
"inconsistency; report this as a bug");
if (opt.verbose)
{
cout << endl
<< "Provide storage for " << triples.triples() << " triples "
<< "composed from " << pairs.size() << " signals."
<< endl
<< "transfer_vector size is " << transfer_vector.size()
<< endl;
}
TFXX_assert(CPSD_vector.size()==pairs.pairs(),
"inconsistency; report this as a bug");
......@@ -822,6 +870,16 @@ int main(int iargc, char* argv[])
croposp::Triples triples(pairs, true);
croposp::TNamedSeriesVector npsd_vector(triples.triples());
if (opt.verbose)
{
cout << endl
<< "Provide storage for " << triples.triples() << " triples "
<< "composed from " << pairs.size() << " signals."
<< endl
<< "npsd_vector size is " << npsd_vector.size()
<< endl;
}
TFXX_assert(PSD_vector.size()==pairs.size(),
"inconsistency; report this as a bug");
TFXX_assert(CPSD_vector.size()==pairs.pairs(),
......
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