Commit a8fce93c authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

provide gnuplot gap plot

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 4554
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 6503d8c5
......@@ -132,6 +132,7 @@ GAPANALYSISOBS=sub/completenessbins.o \
sub/fncompleteness.o \
sub/fngaps.o \
sub/fnprintgaps.o \
sub/fngnuplotplot.o \
sub/fnseriesofmissingsamples.o \
sub/structgapanalysis.o \
sub/structgapseries.o
......
......@@ -60,6 +60,7 @@
* - 13/02/2012 V1.17 gap and completeness series is implemented and
* tested
* - 14/02/2012 V1.18 provide gap summary
* - 14/02/2012 V1.19 provide gnuplot gap plot
*
* TODO:
* * properly handle cases in which the output format can take only single
......@@ -72,7 +73,7 @@
*/
#define ANYEXTRACT_VERSION \
"ANYEXTRACT V1.18 extract data files, using index file"
"ANYEXTRACT V1.19 extract data files, using index file"
#define ANYEXTRACT_CVSID \
"$Id$"
......@@ -126,6 +127,8 @@ struct Options {
std::string gapoutputfile;
std::string binsize;
unsigned int summarizelevel;
bool providegnuplotplot;
std::string gnuplotfile;
}; // struct Options
/*----------------------------------------------------------------------*/
......@@ -364,7 +367,7 @@ int main(int iargc, char* argv[])
" [-RANGECHECK]\n"
"gap options are:\n"
" [-GAPFIND] [-Ggs f] [-Gcs f] [-Gprint[=file]]" "\n"
" [-Gbin s] [-Gsummarize l]" "\n"
" [-Gbin s] [-Gsummarize l] [-Ggpt f]" "\n"
};
// define help text
......@@ -465,6 +468,7 @@ int main(int iargc, char* argv[])
" l=2: summarize total results only\n"
" l=3: just output total number of gaps\n"
" l=4: just output total number of missing samples\n"
" -Ggpt f create gnuplot plot file \"f\"\n"
};
// define extended help text
......@@ -560,6 +564,8 @@ int main(int iargc, char* argv[])
{"Gcs",arg_yes,"-"},
// 29: set summarize level
{"Gsummarize",arg_yes,"0"},
// 30: gnuplot file
{"Ggpt",arg_yes,"-"},
{NULL}
};
......@@ -637,10 +643,13 @@ int main(int iargc, char* argv[])
opt.writecompleteness=cmdline.optset(28);
opt.completenessseriesfile=cmdline.string_arg(28);
opt.summarizelevel=static_cast<unsigned int>(cmdline.int_arg(29));
opt.providegnuplotplot=cmdline.optset(30);
opt.gnuplotfile=cmdline.string_arg(30);
// is any of the GAP analysis modes activated
bool doGAPanalysis=opt.findgapsonly
|| opt.printgaps || opt.writegapseries || opt.writecompleteness;
|| opt.printgaps || opt.writegapseries || opt.writecompleteness
|| opt.providegnuplotplot;
// hierarchical definition of duplicate sample conditions
if (opt.allowduplicatesamples) opt.breakonduplicatesamples=false;
......@@ -1463,6 +1472,10 @@ int main(int iargc, char* argv[])
cout << "chunks of contiguous data:" << std::endl;
}
bool analyzecompleteness=opt.printgaps
|| opt.writegapseries || opt.writecompleteness
|| opt.providegnuplotplot;
// cycle through traces
for (unsigned int itrace=0; itrace<trace.size(); ++itrace)
{
......@@ -1512,10 +1525,7 @@ int main(int iargc, char* argv[])
/*----------------------------------------------------------------------*/
// record statistics
bool recordcontiguous=opt.printgaps
|| opt.writegapseries || opt.writecompleteness;
if (recordcontiguous)
if (analyzecompleteness)
{
// initalize times or record time span and statistics
if (itrace==0)
......@@ -1544,8 +1554,6 @@ int main(int iargc, char* argv[])
/*----------------------------------------------------------------------*/
// any further gap analysis?
bool analyzecompleteness=opt.printgaps
|| opt.writegapseries || opt.writecompleteness;
if (analyzecompleteness)
{
TFXX_debug(opt.debug, "main",
......@@ -1570,6 +1578,21 @@ int main(int iargc, char* argv[])
}
} // if (opt.printgaps)
/*----------------------------------------------------------------------*/
// produce gnuplot plot file
if (opt.providegnuplotplot)
{
std::string gnuplotfile=opt.gnuplotfile+".gpt";
if (!opt.overwrite)
{
datrw::abort_if_exists(gnuplotfile);
}
std::ofstream ofs(gnuplotfile.c_str());
libtime::TRelativeTime binsize(opt.binsize);
CompletenessBins cs(earliesttime,latesttime,binsize);
gnuplotplot(ofs, opt.gnuplotfile+".ps", cs, vecofgaps);
} // if (opt.providegnuplotplot)
/*----------------------------------------------------------------------*/
// write time series with gap information
if (opt.writegapseries || opt.writecompleteness)
......
/*! \file fngnuplotplot.cc
* \brief create a gnuplot plot file (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Thomas Forbriger
* \date 14/02/2012
*
* create a gnuplot plot file (implementation)
*
* Copyright (c) 2012 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
*
* REVISIONS and CHANGES
* - 14/02/2012 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_FNGNUPLOTPLOT_CC_VERSION \
"TF_FNGNUPLOTPLOT_CC V1.0 "
#define TF_FNGNUPLOTPLOT_CC_CVSID \
"$Id$"
#include <gapfunctions.h>
#include <aff/functions/max.h>
void gnuplotplot(std::ostream& os,
const std::string& psname,
const CompletenessBins& cb,
const Tvecofgaps& vog)
{
// find limits
Tvecofgaps::const_iterator I=vog.begin();
GapSeries::Tgapseries total(0,cb.nbins()-1);
total=0;
I=vog.begin();
while (I!=vog.end())
{
GapSeries gs=seriesofmissingsamples(*I, cb);
for (unsigned j=0; j<cb.nbins(); ++j)
{
total(j)+=gs.gapseries(j);
}
++I;
}
int maxval=aff::func::max(total);
// create header
os << "set terminal postscript color solid\n";
os << "set output \"" << psname << "\"\n";
os << "set title \"data gaps in bins of "
<< cb.binsize().timestring() << "\"\n";
os << "set ylabel \"number of missing samples\"\n";
os << "set timefmt \"%Y/%m/%d-%H:%M:%S\"\n";
os << "set xdata time\n";
libtime::TRelativeTime dur=cb.latest()-cb.earliest();
if (dur > libtime::TRelativeTime(5))
{
os << "set format x \"%d.%m.%y\"\n";
}
else if (dur > libtime::TRelativeTime(1))
{
os << "set format x \"%d.%m.%y %H\"\n";
}
else
{
os << "set format x \"%d.%m.%y %H:%M\"\n";
}
os << "set boxwidth 0.9 relative\n";
os << "set style fill solid 0.2 border -1\n";
os << "set xtic rotate by -45 scale 0\n";
os << "set grid\n";
os << "set key outside enhanced horizontal\n";
os << "set auto x\n";
os << "set yrange [" << -0.05 * maxval << ":" << 1.05*maxval << "]\n";
os << "plot ";
// setup plot command
I=vog.begin();
while (I!=vog.end())
{
os << "\'-\' using 1:3 title \"" << I->ID.ID << "\" with boxes, \\\n";
os << " \'-\' using 1:3:2 with labels center offset 0,-0.8 notitle";
++I;
if (I!=vog.end())
{
os << ", \\\n ";
}
else
{
os << "\n";
}
}
// setup data
I=vog.begin();
while (I!=vog.end())
{
GapSeries gs=seriesofmissingsamples(*I, cb);
for (unsigned int i=0; i<2; ++i)
{
for (unsigned j=0; j<cb.nbins(); ++j)
{
libtime::TAbsoluteTime time=cb.bin(j)+cb.binsize()/2;
os << time.hierarchicalstring()
<< " " << gs.gapseries(j) << " " << total(j) << "\n";
}
os << "e\n";
}
for (unsigned j=0; j<cb.nbins(); ++j)
{
total(j)-=gs.gapseries(j);
}
++I;
}
}
/* ----- END OF fngnuplotplot.cc ----- */
......@@ -63,6 +63,11 @@ GapSeries seriesofmissingsamples(const Gapsofstream& gos,
const CompletenessBins& cb,
const bool& debug=false);
void gnuplotplot(std::ostream& os,
const std::string& psname,
const CompletenessBins& cb,
const Tvecofgaps& vog);
#endif // TF_GAPFUNCTIONS_H_VERSION (includeguard)
/* ----- END OF gapfunctions.h ----- */
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