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

ts/hd/tijerasxx [FIX]: handle binary data input index range correctly

The previous version of tijerasxx silently assumed that time series index
range upon input would start with index zero. When reading data in binary
format (libdatrwxx) the time series index range is provided in data file such
that input time series index range may start with any integer value.

The new version correctly handles these cases by operating in the index range
of the input series when extracting a subset of the series.
parent 9b4dff36
......@@ -3,9 +3,8 @@
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Daniel Armbruster
* \date 02/03/2012
* \date 25/08/2016
*
* Purpose: Simply cut off timeseries.
*
......@@ -37,14 +36,14 @@
* 18/12/2012 V1.1 empty intersection is error condition by default
* evaluate smallest time window considering all
* parameters
* 25/08/2016 V1.2 handle input time series index range correctly, where
* first index differs from zero
*
* ============================================================================
*/
#define TIJERASXX_VERSION \
"TIJERASXX V1.1 simply cut off timeseries data"
#define TIJERASXX_SVNID \
"$Id$"
"TIJERASXX V1.2 simply cut off timeseries data"
#include <iostream>
#include <fstream>
......@@ -98,7 +97,6 @@ int main(int iargc, char* argv[])
// define full help text
char help_text[]=
{
TIJERASXX_SVNID "\n"
"\n"
"Options may be abbreviated to a short string as long as they" "\n"
"remain unique. \"-v\" is identical to \"--verbose\"." "\n"
......@@ -393,6 +391,8 @@ int main(int iargc, char* argv[])
TFXX_assert(is.providesi(),
"ERROR: input data is not provided as integer values");
is >> iseries;
TFXX_debug(opt.debug, "tijerasxx: index range at input",
iseries.first() << " - " << iseries.last());
}
else if (opt.single)
{
......@@ -400,6 +400,8 @@ int main(int iargc, char* argv[])
"ERROR: input data is not provided as "
"single precision floats");
is >> fseries;
TFXX_debug(opt.debug, "tijerasxx: index range at input",
fseries.first() << " - " << fseries.last());
}
else
{
......@@ -407,6 +409,8 @@ int main(int iargc, char* argv[])
"ERROR: input data is not provided as "
"double precision floats");
is >> dseries;
TFXX_debug(opt.debug, "tijerasxx: index range at input",
dseries.first() << " - " << dseries.last());
}
// pass WID2
......@@ -570,7 +574,6 @@ int main(int iargc, char* argv[])
is >> freeblock;
freeblock.append("Edited with: ");
freeblock.append(TIJERASXX_VERSION);
freeblock.append(TIJERASXX_SVNID);
os << freeblock;
}
else
......@@ -609,20 +612,26 @@ int main(int iargc, char* argv[])
TFXX_abort("output stream uses unknown variable type!");
} // switch (os.seriestype())
TFXX_debug(opt.debug, "tijerasxx: index range for output",
newFirstSample << " - " << newLastSample);
// write output
if (opt.integer)
{
iseries.setindexrange(newFirstSample, newLastSample);
iseries.setindexrange(newFirstSample+iseries.first(),
newLastSample +iseries.first());
os << iseries;
}
else if (opt.single)
{
fseries.setindexrange(newFirstSample, newLastSample);
fseries.setindexrange(newFirstSample+fseries.first(),
newLastSample +fseries.first());
os << fseries;
}
else
{
dseries.setindexrange(newFirstSample, newLastSample);
dseries.setindexrange(newFirstSample+dseries.first(),
newLastSample +dseries.first());
os << dseries;
}
} // if (!ResultIsEmpty)
......
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