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

proceeding

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: 2990
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 63496d13
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.4 2010-02-20 22:05:29 tforb Exp $
# $Id: Makefile,v 1.5 2010-02-24 07:53:11 tforb Exp $
#
# Copyright (c) 2006 by Thomas Forbriger (BFO Schiltach)
#
......@@ -28,7 +28,6 @@
# ============================================================================
#
MODULES=sff ascii
MODULES=sff
HEADERS=$(wildcard *.h $(addsuffix /*.h,$(MODULES)))
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: datwrite.cc,v 1.7 2010-02-20 22:05:29 tforb Exp $
* $Id: datwrite.cc,v 1.8 2010-02-24 07:53:11 tforb Exp $
* \author Thomas Forbriger
* \date 11/04/2006
*
......@@ -36,12 +36,21 @@
#define DATWRITE_DATWRITE_CC_VERSION \
"TF_DATWRITE_CC V1.0 "
#define DATWRITE_DATWRITE_CC_CVSID \
"$Id: datwrite.cc,v 1.7 2010-02-20 22:05:29 tforb Exp $"
"$Id: datwrite.cc,v 1.8 2010-02-24 07:53:11 tforb Exp $"
#include<fstream>
#include <datwritexx/datwrite.h>
namespace datwrite {
void abort_if_exists(const std::string& filename)
{
std::ifstream file(filename.c_str(),std::ios_base::in);
DATWRITE_assert((!file.good()),"ERROR: file exists!");
}
/*----------------------------------------------------------------------*/
odatstream::odatstream(std::ostream& os):
Mos(os), Mwid2set(false), Msrceset(false), Minfoset(false),
Mfreeset(false), Mheaderflushed(false)
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: datwrite.h,v 1.9 2010-02-21 20:09:10 tforb Exp $
* $Id: datwrite.h,v 1.10 2010-02-24 07:53:11 tforb Exp $
* \author Thomas Forbriger
* \date 11/04/2006
*
......@@ -40,8 +40,9 @@
#define DATWRITE_DATWRITE_H_VERSION \
"TF_DATWRITE_H V1.0 "
#define DATWRITE_DATWRITE_H_CVSID \
"$Id: datwrite.h,v 1.9 2010-02-21 20:09:10 tforb Exp $"
"$Id: datwrite.h,v 1.10 2010-02-24 07:53:11 tforb Exp $"
#include<string>
#include<iostream>
#include<aff/series.h>
#include<sffxx.h>
......@@ -53,6 +54,16 @@ namespace datwrite {
typedef aff::Series<float> Tfseries;
typedef aff::Series<int> Tiseries;
/*----------------------------------------------------------------------*/
/*! check for existing output fil
*
* aborts, if file with given filename exists
*/
void abort_if_exists(const std::string& filename);
/*----------------------------------------------------------------------*/
/*! output stream to write seismic data (abstract base)
*
* The concept is based on SFF data contents and we will make use of SFF
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sff.h,v 1.9 2010-02-21 20:09:10 tforb Exp $
* $Id: sff.h,v 1.10 2010-02-24 07:53:11 tforb Exp $
* \author Thomas Forbriger
* \date 11/04/2006
*
......@@ -40,7 +40,7 @@
#define DATWRITE_SFF_H_VERSION \
"TF_SFF_H V1.0 "
#define DATWRITE_SFF_H_CVSID \
"$Id: sff.h,v 1.9 2010-02-21 20:09:10 tforb Exp $"
"$Id: sff.h,v 1.10 2010-02-24 07:53:11 tforb Exp $"
#include<datwritexx/datwrite.h>
#include<datwritexx/reservoir.h>
......@@ -76,12 +76,17 @@ namespace datwrite {
*/
void flushwaitingtrace(const bool& last=false);
protected:
bool Mdebug;
private:
bool Mwid2iswaiting, Mfreeiswaiting, Minfoiswaiting;
sff::WID2 Mwid2waiting;
sff::FREE Mfreewaiting;
sff::INFO Minfowaiting;
datwrite::util::seriesreservoir Mserieswaiting;
protected:
::sff::Enormmode Mnormmode;
}; // class osffstream
/*----------------------------------------------------------------------*/
......@@ -90,22 +95,20 @@ namespace datwrite {
*
* \ingroup sff
*/
/*
class ogsestream: public odatstream {
class ogsestream: public osffstream {
public:
typedef odatstream Tbase;
typedef osffstream Tbase;
ogsestream(std::ostream& os, const bool& debug=false);
virtual ~ogsestream() { }
static void help(std::ostream& os=std::cout)
{ Tbase::help(os, "ogsestream"); }
inline virtual ~ogsestream() { }
static void help(std::ostream& os=std::cout);
/*
protected:
virtual void writefileheader();
virtual void writetrace(const Tiseries& series);
private:
bool Msffos;
bool Mdebug;
virtual void writetrace(const Tdseries& series)
{ DATWRITE_abort("ogsestream cannot write doubles"); }
virtual void writetrace(const Tfseries& series)
{ DATWRITE_abort("ogsestream cannot write floats"); }
*/
}; // class ogsestream
*/
} // namespace datwrite
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sff.cc,v 1.5 2010-02-21 12:31:33 tforb Exp $
* $Id: sff.cc,v 1.6 2010-02-24 07:53:11 tforb Exp $
* \author Thomas Forbriger
* \date 11/04/2006
*
......@@ -36,7 +36,7 @@
#define DATWRITE_SFF_CC_VERSION \
"DATWRITE_SFF_CC V1.0 "
#define DATWRITE_SFF_CC_CVSID \
"$Id: sff.cc,v 1.5 2010-02-21 12:31:33 tforb Exp $"
"$Id: sff.cc,v 1.6 2010-02-24 07:53:11 tforb Exp $"
#include <datwritexx/sff.h>
#include <datwritexx/util.h>
......@@ -49,7 +49,8 @@ namespace datwrite {
Mdebug(debug),
Mwid2iswaiting(false),
Mfreeiswaiting(false),
Minfoiswaiting(false)
Minfoiswaiting(false),
Mnormmode(::sff::NM_maxdyn)
{
Mdebug=debug;
DATWRITE_debug(Mdebug, "osffstream::osffstream",
......@@ -60,7 +61,7 @@ namespace datwrite {
void osffstream::help(std::ostream& os)
{
os << "This module write standard SFF data." << std::endl;
os << "This module writes standard SFF data." << std::endl;
} // void osffstream::help(std::ostream& os=std::cout)
/*----------------------------------------------------------------------*/
......@@ -121,7 +122,7 @@ namespace datwrite {
datwrite::sff::writesfftrace(Mos,
traceheader,
Mserieswaiting,
::sff::NM_maxdyn);
Mnormmode);
}
else
{
......@@ -141,6 +142,28 @@ namespace datwrite {
}
}
/*======================================================================*/
ogsestream::ogsestream(std::ostream& os, const bool& debug):
Tbase(os, debug)
{
Mnormmode=::sff::NM_one;
DATWRITE_debug(Mdebug, "ogsestream::ogsestream",
"new instance established");
} // ogsestream::ogsestream(std::ostream& os, const bool& debug)
/*----------------------------------------------------------------------*/
void ogsestream::help(std::ostream& os)
{
os << "This modules write standard GSE data." << std::endl;
os << "Essentially SFF data is written but without normalising"
<< std::endl;
os << "them. Notice that floating point data will by truncated to"
<< std::endl;
os << "integers." << std::endl;
} // void ogsestream::help(std::ostream& os=std::cout)
} // namespace datwrite
/* ----- END OF sff.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: writetest.cc,v 1.2 2010-02-21 20:09:10 tforb Exp $
* $Id: writetest.cc,v 1.3 2010-02-24 07:53:11 tforb Exp $
* \author Thomas Forbriger
* \date 20/02/2010
*
......@@ -36,12 +36,13 @@
#define WRITETEST_VERSION \
"WRITETEST V1.0 test writing a file"
#define WRITETEST_CVSID \
"$Id: writetest.cc,v 1.2 2010-02-21 20:09:10 tforb Exp $"
"$Id: writetest.cc,v 1.3 2010-02-24 07:53:11 tforb Exp $"
#include <iostream>
#include <fstream>
#include <tfxx/commandline.h>
#include <datwritexx/sff.h>
#include <datwritexx/writeany.h>
using std::cout;
using std::cerr;
......@@ -51,6 +52,13 @@ struct Options {
bool verbose, debug;
bool sfftest;
std::string sfffilename;
bool gsetest;
std::string gsefilename;
bool anytest;
std::string anyfilename;
datwrite::Eformat format;
double amplitude;
bool overwrite;
}; // struct Options
int main(int iargc, char* argv[])
......@@ -60,7 +68,8 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
WRITETEST_VERSION "\n"
"usage: writetest [-v] [-D] [-sff n]" "\n"
"usage: writetest [-v] [-D] [-sff n] [-gse n] [-any n]" "\n"
" [-t type] [-A amp] [-o]" "\n"
" or: writetest --help|-h" "\n"
};
......@@ -69,9 +78,16 @@ int main(int iargc, char* argv[])
{
WRITETEST_CVSID
"\n"
"-v be verbose" "\n"
"-D enter debug mode" "\n"
"-sff n write to SFF file \"n\"" "\n"
"-v be verbose" "\n"
"-D enter debug mode" "\n"
"-sff n write to SFF file \"n\"" "\n"
"-gse n write to GSE file \"n\"" "\n"
"-any n write to file \"n\"" "\n"
"\n"
"options to define \"any\" test:" "\n"
"-t type select output format type for any" "\n"
"-A amp select signal amplitude" "\n"
"-o overwrite existing output file" "\n"
};
// define commandline options
......@@ -84,8 +100,18 @@ int main(int iargc, char* argv[])
{"v",arg_no,"-"},
// 2: debug mode
{"D",arg_no,"-"},
// 3: verbose mode
// 3: write SFF data
{"sff",arg_yes,"-"},
// 4: write GSE data
{"gse",arg_yes,"-"},
// 5: write any format
{"any",arg_yes,"-"},
// 6: write any format
{"t",arg_yes,"sff"},
// 7: write any format
{"A",arg_yes,"1."},
// 8: write any format
{"o",arg_no,"-"},
{NULL}
};
......@@ -104,6 +130,8 @@ int main(int iargc, char* argv[])
{
cerr << usage_text << endl;
cerr << help_text << endl;
datwrite::supported_data_types(cerr);
datwrite::online_help(cerr);
exit(0);
}
......@@ -136,6 +164,13 @@ int main(int iargc, char* argv[])
opt.debug=cmdline.optset(2);
opt.sfftest=cmdline.optset(3);
opt.sfffilename=cmdline.string_arg(3);
opt.gsetest=cmdline.optset(4);
opt.gsefilename=cmdline.string_arg(4);
opt.anytest=cmdline.optset(5);
opt.anyfilename=cmdline.string_arg(5);
opt.format=datwrite::anyID(cmdline.string_arg(6));
opt.amplitude=cmdline.double_arg(7);
opt.overwrite=cmdline.optset(8);
/*======================================================================*/
......@@ -146,19 +181,156 @@ int main(int iargc, char* argv[])
std::ofstream ofs(opt.sfffilename.c_str());
datwrite::osffstream os(ofs, opt.debug);
sff::FREE free;
free.append("my comment");
free.append("my file comment");
sff::SRCE srce;
os << free;
os << srce;
{
datwrite::Tiseries s(10);
for (int i=s.f(); i<=s.l(); ++i)
sff::WID2 wid2;
wid2.dt=10;
wid2.channel="LIN";
wid2.station="THOF";
{
datwrite::Tiseries s(10);
sff::FREE tracefree;
tracefree.append("linear integer trace");
sff::INFO info;
for (int i=s.f(); i<=s.l(); ++i)
{
s(i)=i;
}
os << wid2;
os << tracefree;
os << info;
os << s;
}
{
s(i)=i;
datwrite::Tdseries s(100);
sff::FREE tracefree;
tracefree.append("double sine trace");
for (int i=s.f(); i<=s.l(); ++i)
{
s(i)=5.e4*sin(2*3.14159265358979311599*i/(s.size()-1));
}
wid2.dt=1.;
wid2.channel="SIN";
os << wid2;
os << tracefree;
os << s;
}
{
datwrite::Tfseries s(1000);
sff::FREE tracefree;
tracefree.append("float cosine trace");
for (int i=s.f(); i<=s.l(); ++i)
{
s(i)=6.e-12*cos(2*3.14159265358979311599*i/(s.size()-1));
}
wid2.dt=.1;
wid2.channel="COS";
os << wid2;
os << tracefree;
os << s;
}
}
}
/*======================================================================*/
if (opt.gsetest)
{
if (opt.verbose)
{ cout << "GSE test: write to file " << opt.gsefilename << endl; }
std::ofstream ofs(opt.gsefilename.c_str());
datwrite::ogsestream os(ofs, opt.debug);
sff::FREE free;
free.append("my file comment");
sff::SRCE srce;
os << free;
os << srce;
{
sff::WID2 wid2;
wid2.dt=10;
os << wid2;
os << s;
wid2.channel="LIN";
wid2.station="THOF";
{
datwrite::Tiseries s(100);
sff::FREE tracefree;
tracefree.append("linear integer trace");
sff::INFO info;
for (int i=s.f(); i<=s.l(); ++i)
{
s(i)=i/5-10;
}
os << wid2;
os << tracefree;
os << info;
os << s;
}
{
datwrite::Tdseries s(100);
sff::FREE tracefree;
tracefree.append("double sine trace");
for (int i=s.f(); i<=s.l(); ++i)
{
s(i)=30.*sin(2*3.14159265358979311599*i/(s.size()-1));
}
wid2.dt=1.;
wid2.channel="SIN";
os << wid2;
os << tracefree;
os << s;
}
{
datwrite::Tfseries s(1000);
sff::FREE tracefree;
tracefree.append("float cosine trace");
for (int i=s.f(); i<=s.l(); ++i)
{
s(i)=6.*cos(2*3.14159265358979311599*i/(s.size()-1));
}
wid2.dt=.1;
wid2.channel="COS";
os << wid2;
os << tracefree;
os << s;
}
}
}
/*======================================================================*/
if (opt.anytest)
{
if (opt.verbose)
{
cout << "ANY test: write to file " << opt.anyfilename << endl;
cout << "using " << datwrite::anyID(opt.format) << endl;
}
if (!opt.overwrite) { datwrite::abort_if_exists(opt.anyfilename); }
std::ofstream ofs(opt.anyfilename.c_str());
datwrite::oanystream os(ofs, opt.format, opt.debug);
sff::FREE free;
free.append("my file comment");
sff::SRCE srce;
os << free;
os << srce;
sff::WID2 wid2;
wid2.dt=10;
wid2.channel="SIN";
wid2.station="THOF";
datwrite::Tdseries s(100);
sff::FREE tracefree;
tracefree.append("double sine trace");
for (int i=s.f(); i<=s.l(); ++i)
{
s(i)=opt.amplitude*sin(2*3.14159265358979311599*i/(s.size()-1));
}
wid2.dt=1.;
wid2.channel="SIN";
os << wid2;
os << tracefree;
os << s;
}
}
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: writeany.cc,v 1.5 2010-02-21 15:02:59 tforb Exp $
* $Id: writeany.cc,v 1.6 2010-02-24 07:53:11 tforb Exp $
* \author Thomas Forbriger
* \date 17/02/2010
*
......@@ -36,7 +36,7 @@
#define DATWRITE_WRITEANY_CC_VERSION \
"TF_WRITEANY_CC V1.0 "
#define DATWRITE_WRITEANY_CC_CVSID \
"$Id: writeany.cc,v 1.5 2010-02-21 15:02:59 tforb Exp $"
"$Id: writeany.cc,v 1.6 2010-02-24 07:53:11 tforb Exp $"
#include <datwritexx/writeany.h>
#include <datwritexx/error.h>
......@@ -49,7 +49,7 @@ namespace datwrite {
Mformat(format)
{
if (Mformat==Fsff) { Mos=new osffstream(os); }
// else if (Mformat==Fgse) { Mos=new ogsestream(os); }
else if (Mformat==Fgse) { Mos=new ogsestream(os); }
else
{ DATWRITE_abort("ERROR (ianystream): unknown format!"); }
}
......@@ -103,11 +103,11 @@ namespace datwrite {
void online_help(std::ostream& os)
{
os << std::endl
<< "Online help obtained from data extraction facilities:"
<< "Online help obtained from writing facilities:"
<< std::endl;
os << "SFF data: "; osffstream::help(os);
os << std::endl;
//os << "GSE data: "; ogsestream::help(os);
os << "GSE data: "; ogsestream::help(os);
}
} // namespace datwrite
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: writeany.h,v 1.4 2010-02-20 22:05:29 tforb Exp $
* $Id: writeany.h,v 1.5 2010-02-24 07:53:11 tforb Exp $
* \author Thomas Forbriger
* \date 17/02/2010
*
......@@ -40,7 +40,7 @@
#define DATWRITE_WRITEANY_H_VERSION \
"DATWRITE_WRITEANY_H V1.0 "
#define DATWRITE_WRITEANY_H_CVSID \
"$Id: writeany.h,v 1.4 2010-02-20 22:05:29 tforb Exp $"
"$Id: writeany.h,v 1.5 2010-02-24 07:53:11 tforb Exp $"
#include<datwritexx/datwrite.h>
......@@ -91,8 +91,8 @@ namespace datwrite {
void online_help(std::ostream& os=std::cout);
template<class C>
oanystream& operator>>(oanystream& os, C& c)
{ os.odatstream() >> c; return(os); }
oanystream& operator<<(oanystream& os, C& c)
{ os.odatstream() << c; return(os); }
} // namespace datwrite
......
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