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

reading works

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: 1458
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 5bae673a
# ---------------------------------------
#
# $Id: Makefile,v 1.15 2003-01-22 09:50:58 forbrig Exp $
# $Id: Makefile,v 1.16 2004-01-28 14:54:16 tforb Exp $
#
# Makefile fuer tools /src/ts/wf
#
......@@ -16,12 +16,18 @@ CC=gcc
CFLAGS=-O2
F2CFLAGS=-f -u
FLAGS=
CXXFLAGS=-fhonor-std -Wall $(FLAGS)
CXXFLAGS=-Wall $(FLAGS)
LDFLAGS=-L$(LOCLIBDIR)
CPPFLAGS=-I$(LOCINCLUDEDIR) $(FLAGS)
.f.o:
f2c $(F2CFLAGS) $<
gcc $(CFLAGS) $(<:.f=.c) -c -I${SERVERINCLUDEDIR} -I${LOCINCLUDEDIR}
@rm $(<:.f=.c)
flist: $(wildcard *.f *.inc Makefile); echo $^ | tr ' ' '\n' | sort > $@
flist: $(wildcard *.f *.inc Makefile *.cc); echo $^ | tr ' ' '\n' | sort > $@
.PHONY: edit
edit: flist; vim $<
......@@ -51,4 +57,8 @@ hamres siggen smoos dise: %: %.o
-L$(LOCLIBDIR)
newprog $@
sigfit: sigfit.o
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -lsffxx -lgsexx -laff \
-ltfxx -ltime++ -L$(LOCLIBDIR) $(CXXFLAGS) $(FLAGS)
newprog $@
/*! \file sigfit.cc
* \brief fit signal by trial-signals
*
* ----------------------------------------------------------------------------
*
* $Id: sigfit.cc,v 1.1 2004-01-28 14:54:16 tforb Exp $
* \author Thomas Forbriger
* \date 28/01/2004
*
* fit signal by trial-signals
*
* Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 28/01/2004 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define SIGFIT_VERSION \
"SIGFIT V1.0 fit signal by trial-signals"
#define SIGFIT_CVSID \
"$Id: sigfit.cc,v 1.1 2004-01-28 14:54:16 tforb Exp $"
#include <fstream>
#include <iostream>
#include <list>
#include <vector>
#include <tfxx/commandline.h>
#include <sffxx.h>
#include <tsxx/bundles.h>
typedef std::list<std::string> Tnamelist;
typedef ts::TDsffbundle Tbundle;
typedef Tbundle::Tseries Tseries;
typedef std::vector<Tbundle> Tbundlevec;
using std::cout;
using std::cerr;
using std::endl;
// structure to store commandline options
struct Options {
bool verbose;
}; // struct Options
int main(int iargc, char* argv[])
{
// define usage information
char usage_text[]=
{
SIGFIT_VERSION "\n"
"usage: sigfit [-v] signal trial [trial ...]" "\n"
" or: sigfit --help|-h" "\n"
};
// define full help text
char help_text[]=
{
SIGFIT_CVSID "\n"
"\n"
"-v be verbose" "\n"
"-Sramp add a ramp to the set of trial signals" "\n"
"-Sconst add a constant to the set of trial signals" "\n"
"\n"
"signal signal to by explained by a linear combination" "\n"
" of trial signals" "\n"
"trial any set of trial signals"
};
// define commandline options
using namespace tfxx::cmdline;
static Declare options[]=
{
// 0: print help
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
{NULL}
};
// no arguments? print usage...
if (iargc<2)
{
cerr << usage_text << endl;
exit(0);
}
// collect options from commandline
Commandline cmdline(iargc, argv, options);
// help requested? print full help text...
if (cmdline.optset(0))
{
cerr << usage_text << endl;
cerr << help_text << endl;
exit(0);
}
/*
// dummy operation: print option settings
for (int iopt=0; iopt<2; iopt++)
{
cout << "option: '" << options[iopt].opt_string << "'" << endl;
if (cmdline.optset(iopt)) { cout << " option was set"; }
else { cout << "option was not set"; }
cout << endl;
cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
cout << " argument (bool): '";
if (cmdline.bool_arg(iopt))
{ cout << "true"; } else { cout << "false"; }
cout << "'" << endl;
}
while (cmdline.extra()) { cout << cmdline.next() << endl; }
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
*/
// read options
Options opt;
opt.verbose=cmdline.optset(1);
// read file names
Tnamelist namelist;
while (cmdline.extra()) { namelist.push_back(cmdline.next()); }
if (opt.verbose)
{ cout << namelist.size() << "files to read" << endl; }
// read files
Tbundlevec bundlevec;
for (Tnamelist::const_iterator i=namelist.begin(); i!=namelist.end(); i++)
{
if (opt.verbose)
{ cout << "read file \"" << *i << "\"" << endl; }
std::ifstream is(i->c_str());
sff::FileHeader fileheader(is);
bool last=false;
while(!last)
{
if (opt.verbose)
{ cout << " read trace #" << bundlevec.size()+1 << endl; }
sff::InputWaveform<Tseries> inputwaveform(is);
sff::TraceHeader traceheader=inputwaveform.header();
Tbundle bundle;
bundle.header=traceheader.wid2();
bundle.series=inputwaveform.series();
bundlevec.push_back(bundle);
last=traceheader.last();
std::string wid2line=bundle.header.line();
if (opt.verbose)
{ cout << " " << wid2line.substr(0,69) << endl; }
}
}
}
/* ----- END OF sigfit.cc ----- */
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