Commit 6785f1f0 authored by thomas.forbriger's avatar thomas.forbriger

ts/cropsop [FIX]: replace: coherency -> coherence

parent 2dc7add6
......@@ -5,7 +5,7 @@ croposp: cross power spectral density
croposp provides:
- computation of power spectral density from time series data
- computation of coherency from pairs of time series data
- computation of coherence from pairs of time series data
- computation of power spectral density of incoherent signal component,
amplitude and phase transfer functions from triples of time series data
(Sleeman, 2006)
......
......@@ -28,10 +28,10 @@
* REVISIONS and CHANGES
* - 25/12/2018 V1.0 Thomas Forbriger
* - 14/02/2019 V1.1 first operational version (coarsely tested)
* - 03/03/2019 V1.2 compute magnitude squared coherency rather than
* - 03/03/2019 V1.2 compute magnitude squared coherence rather than
* its suqare root
* commonly in literature coherency refers to the
* magnitude squared coherency
* commonly in literature coherence refers to the
* magnitude squared coherence
*
* ============================================================================
*/
......@@ -78,10 +78,10 @@ int main(int iargc, char* argv[])
" [-pattern p] [-overwrite] [-DEBUG]" "\n"
" [-log n] [-avgout]\n"
" [-nsegments n] [-divisor n] [-padfactor n] [-overlap f]\n"
" [-psd f] [-transfer f] [-phase f] [-coherency f]" "\n"
" [-psd f] [-transfer f] [-phase f] [-coherence f]" "\n"
" [-npsd f] [-npsdmode f]\n"
" [-prefixpsd s] [-prefixnpsd s] [-prefixtransfer s]\n"
" [-prefixphase s] [-prefixcoherency s]" "\n"
" [-prefixphase s] [-prefixcoherence s]" "\n"
" file [t:sel] [f:format] [n:label] [file [t:s] [f:f] [n:l]] [...]\n"
" or: croposp --help|-h" "\n"
};
......@@ -119,7 +119,7 @@ int main(int iargc, char* argv[])
" %1: label of first signal\n"
" %2: label of second signal\n"
" %3: label of reference signal\n"
"-patcoherency s set label pattern for coherency output to \"s\"\n"
"-patcoherence s set label pattern for coherence output to \"s\"\n"
" %1: label of first signal\n"
" %2: label of second signal\n"
"\n"
......@@ -152,7 +152,7 @@ int main(int iargc, char* argv[])
"-phase f compute phase transfer function for pairs of\n"
" signals and write to file \"f\"\n"
" Sleeman et al (2006, eq. 13)\n"
"-coherency f compute magnitude squared coherecy for pairs of signals\n"
"-coherence f compute magnitude squared coherecy for pairs of signals\n"
" and write to file \"f\"\n"
"\n"
"keys to be appended to file names if required:\n"
......@@ -185,8 +185,8 @@ int main(int iargc, char* argv[])
{"npsd",arg_yes,"-"},
// 9: compute transfer function
{"transfer",arg_yes,"-"},
// 10: compute coherency
{"coherency",arg_yes,"-"},
// 10: compute coherence
{"coherence",arg_yes,"-"},
// 11: map to logarithmic frequency sampling
{"log",arg_yes,"1"},
// 12: overwrite existing output files
......@@ -209,8 +209,8 @@ int main(int iargc, char* argv[])
{"pattransfer",arg_yes,"AMP %1/%2 (ref: %3)"},
// 21: set phase label pattern
{"patphase",arg_yes,"PHA %1-%2 (ref: %3)"},
// 22: set coherency label pattern
{"patcoherency",arg_yes,"MSC %1 %2"},
// 22: set coherence label pattern
{"patcoherence",arg_yes,"MSC %1 %2"},
// 23: average upon output
{"avgout",arg_no,"-"},
// 24: average upon output
......@@ -283,8 +283,8 @@ int main(int iargc, char* argv[])
opt.outfile_npsd=cmdline.string_arg(8);
opt.compute_transfer=cmdline.optset(9);
opt.outfile_transfer=cmdline.string_arg(9);
opt.compute_coherency=cmdline.optset(10);
opt.outfile_coherency=cmdline.string_arg(10);
opt.compute_coherence=cmdline.optset(10);
opt.outfile_coherence=cmdline.string_arg(10);
opt.logscale=cmdline.optset(11);
opt.n_per_decade=cmdline.int_arg(11);
......@@ -301,7 +301,7 @@ int main(int iargc, char* argv[])
opt.pattern_npsd=cmdline.string_arg(19);
opt.pattern_transfer=cmdline.string_arg(20);
opt.pattern_phase=cmdline.string_arg(21);
opt.pattern_coherency=cmdline.string_arg(22);
opt.pattern_coherence=cmdline.string_arg(22);
opt.avg_on_output=cmdline.optset(23);
opt.npsd_mode=cmdline.int_arg(24);
......@@ -420,7 +420,7 @@ int main(int iargc, char* argv[])
TFXX_assert(collection_of_series.are_consistent(comparer),
"time series are inconsistent");
if (opt.compute_npsd || opt.compute_coherency)
if (opt.compute_npsd || opt.compute_coherence)
{
if ((opt.nsegments < 2) && (!opt.logscale))
{
......@@ -453,7 +453,7 @@ int main(int iargc, char* argv[])
croposp::TNamedSeriesVector PSD_vector;
if (opt.compute_psd || opt.compute_npsd ||
opt.compute_coherency)
opt.compute_coherence)
{
if (opt.verbose)
{
......@@ -528,7 +528,7 @@ int main(int iargc, char* argv[])
frequencies, PSD_vector, opt);
} // if (opt.compute_psd)
} // if (opt.compute_psd || opt.compute_npsd ||
// opt.compute_coherency)
// opt.compute_coherence)
/* ---------------------------------------------------------------------- */
......@@ -538,7 +538,7 @@ int main(int iargc, char* argv[])
croposp::TNamedCPSDVector CPSD_vector(pairs.pairs());
if (opt.compute_transfer || opt.compute_phase || opt.compute_npsd ||
opt.compute_coherency)
opt.compute_coherence)
{
if (opt.verbose)
{
......@@ -620,23 +620,23 @@ int main(int iargc, char* argv[])
} // for (unsigned int l=0; l<k; ++l)
} // if (opt.compute_transfer || opt.compute_phase || opt.compute_npsd ||
// opt.compute_coherency)
// opt.compute_coherence)
/* ---------------------------------------------------------------------- */
/* compute magnitude squared coherency
/* compute magnitude squared coherence
* -----------------------------------
*/
if (opt.compute_coherency)
if (opt.compute_coherence)
{
if (opt.verbose)
{
cout << endl
<< "Compute coherency for all pairs of signals."
<< "Compute coherence for all pairs of signals."
<< endl;
}
croposp::TNamedSeriesVector coherency_vector(pairs.pairs());
croposp::TNamedSeriesVector coherence_vector(pairs.pairs());
TFXX_assert(PSD_vector.size()==pairs.size(),
"inconsistency; report this as a bug");
......@@ -649,29 +649,29 @@ int main(int iargc, char* argv[])
{
psd::TDseries::Tcoc mscpsd=psd::abssqr(CPSD_vector[pairs(k,l)].series);
coherency_vector[pairs(k,l)].series
coherence_vector[pairs(k,l)].series
=mscpsd/(PSD_vector[k].series*PSD_vector[l].series);
coherency_vector[pairs(k,l)].label=opt.pattern_coherency;
coherency_vector[pairs(k,l)].label
=croposp::patsubst(coherency_vector[pairs(k,l)].label, "%1",
coherence_vector[pairs(k,l)].label=opt.pattern_coherence;
coherence_vector[pairs(k,l)].label
=croposp::patsubst(coherence_vector[pairs(k,l)].label, "%1",
vector_of_metadata[k].label);
coherency_vector[pairs(k,l)].label
=croposp::patsubst(coherency_vector[pairs(k,l)].label, "%2",
coherence_vector[pairs(k,l)].label
=croposp::patsubst(coherence_vector[pairs(k,l)].label, "%2",
vector_of_metadata[l].label);
if (opt.verbose)
{
cout << " computed: " << coherency_vector[pairs(k,l)].label << endl;
cout << " computed: " << coherence_vector[pairs(k,l)].label << endl;
}
} // for (unsigned int l=0; l<k; ++l)
} // for (unsigned int l=0; l<k; ++l)
write_named_series(opt.outfile_coherency,
"coherency of pairs of signals",
frequencies, coherency_vector, opt);
write_named_series(opt.outfile_coherence,
"coherence of pairs of signals",
frequencies, coherence_vector, opt);
} // if (opt.compute_coherency)
} // if (opt.compute_coherence)
/* ---------------------------------------------------------------------- */
/* compute amplitude phase function
......
......@@ -59,12 +59,12 @@ namespace croposp {
unsigned int n_per_decade;
unsigned int nsegments, divisor, padfactor;
double overlap;
bool compute_psd, compute_npsd, compute_coherency, compute_transfer;
bool compute_psd, compute_npsd, compute_coherence, compute_transfer;
bool compute_phase;
std::string outfile_psd, outfile_npsd, outfile_coherency, outfile_transfer;
std::string outfile_psd, outfile_npsd, outfile_coherence, outfile_transfer;
std::string outfile_phase;
std::string pattern_psd, pattern_npsd, pattern_transfer;
std::string pattern_phase, pattern_coherency;
std::string pattern_phase, pattern_coherence;
unsigned int npsd_mode;
}; // struct Options
......
......@@ -34,7 +34,7 @@ CPSD_SET=1 2 3
CPSD_SET=1 2 3 4
ALLPDF=PSD.pdf PSDraw.pdf \
$(addprefix coherency_,$(addsuffix .pdf,$(CPSD_SET))) \
$(addprefix coherence_,$(addsuffix .pdf,$(CPSD_SET))) \
$(addprefix transfer_,$(addsuffix .pdf,A B)) \
$(addprefix phase_,$(addsuffix .pdf,A B)) \
$(addprefix NPSD_,$(addsuffix .pdf,$(CPSD_SET)))
......@@ -97,7 +97,7 @@ cpsdbgraw.bin:
siggenx 14 $@ $(CPSD_SIGGENOPT); \
echo seed: $$GSL_RNG_SEED'
# provide a time series plot to confirm incoherency
# provide a time series plot to confirm incoherence
rawsig.ps: cpsd1raw.bin cpsd2raw.bin cpsd3raw.bin cpsd4raw.bin cpsdbgraw.bin
stuplox -d $@/cps -s x -i -ty bin $^
......@@ -204,7 +204,7 @@ CPSD_NLOG=20
CPSD_LOG=--log $(CPSD_NLOG) $(CPSD_AVGOUT)
CPSD_OPT=--DEBUG
CPSD_OPT=
OUTPUTS=psd npsd coherency transfer phase
OUTPUTS=psd npsd coherence transfer phase
# define string summarizing essential croposp options
# this will be included in the title of diagrams
......@@ -229,7 +229,7 @@ $(addsuffix _out.xxx,$(OUTPUTS)): $(CPSD_BINFILES)
$(CPSD_CROPOSP_OPT) \
--psd psd_out.xxx \
--npsd npsd_out.xxx \
--coherency coherency_out.xxx \
--coherence coherence_out.xxx \
--transfer transfer_out.xxx \
--phase phase_out.xxx \
$^
......@@ -301,11 +301,11 @@ PSD.pdf: psd_out.xxx $(CPSD_REFFILES)
$(CROPOSPLOT_OPT) \
--titfontsize='small' -v --grid -o $@ $^
# display signal specific coherency
coherency_%.pdf: coherency_out.xxx
# display signal specific coherence
coherence_%.pdf: coherence_out.xxx
$(CROPOSPLOT) --title="$@ \n $(CPSD_CROPOSP_OPT)" \
$(CROPOSPLOT_OPT) --nology --ylabel="coherency" \
--match='SYN$(patsubst coherency_%.pdf,%,$@)' \
$(CROPOSPLOT_OPT) --nology --ylabel="coherence" \
--match='SYN$(patsubst coherence_%.pdf,%,$@)' \
--titfontsize='small' -v --grid -o $@ $^
# display signal specific transfer factor
......
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