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

first SFF writing version

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: 1429
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 04f82d9e
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sfftest.cc,v 1.4 2003-12-23 14:00:00 tforb Exp $
* $Id: sfftest.cc,v 1.5 2003-12-23 15:47:22 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -19,8 +19,9 @@
#define SFFTEST_VERSION \
"SFFTEST V1.0 test library modules"
#define SFFTEST_CVSID \
"$Id: sfftest.cc,v 1.4 2003-12-23 14:00:00 tforb Exp $"
"$Id: sfftest.cc,v 1.5 2003-12-23 15:47:22 tforb Exp $"
#include <fstream>
#include <iostream>
#include <sffxx.h>
#include <aff/series.h>
......@@ -168,11 +169,57 @@ void test_waveform_normalizer()
/*----------------------------------------------------------------------*/
void test_write_file()
{
char filename[]="junk.dat";
cout << "test writing to file: " << filename << endl
<< "---------------------" << endl;
const int msamp=1000;
Tseries series(msamp);
for (int i=series.first(); i<=series.last(); i++)
{ series(i)=1.e6*sin(3.1415926*i*5/msamp); }
sff::SRCE mysrce;
mysrce.cx=1.;
mysrce.cy=2.;
mysrce.cz=3.;
mysrce.type="Quelle";
sff::INFO myinfo;
sff::FREE myfree;
myfree.lines.push_back("auch ein text");
sff::WID2 mywid2;
mywid2.station="BFO";
mywid2.channel="UGZ";
mywid2.instype="ET-19";
mywid2.nsamples=2048;
mywid2.dt=10.;
sff::FileHeader fhd(mysrce,myfree);
std::ofstream os(filename);
os << fhd;
{
sff::TraceHeader hd(mywid2,myinfo,myfree);
os << sff::OutputWaveform<Tseries>(series, hd, sff::NM_maxdyn);
}
{
myinfo.cx=10.;
sff::TraceHeader hd(mywid2,myinfo,myfree,true);
os << sff::OutputWaveform<Tseries>(series, hd, sff::NM_ifneeded);
}
}
/*----------------------------------------------------------------------*/
int main(int iargc, char* argv[])
{
test_line_functions(); cout << endl;
test_write_wrappers(); cout << endl;
test_waveform_normalizer(); cout << endl;
test_write_file(); cout << endl;
}
/* ----- END OF sfftest.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sffxx.cc,v 1.4 2003-12-23 14:00:00 tforb Exp $
* $Id: sffxx.cc,v 1.5 2003-12-23 15:47:22 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -19,7 +19,7 @@
#define TF_SFFXX_CC_VERSION \
"TF_SFFXX_CC V1.0 "
#define TF_SFFXX_CC_CVSID \
"$Id: sffxx.cc,v 1.4 2003-12-23 14:00:00 tforb Exp $"
"$Id: sffxx.cc,v 1.5 2003-12-23 15:47:22 tforb Exp $"
#include <sffxx.h>
#include <gsexx.h>
......@@ -27,7 +27,7 @@
namespace sff {
//! Fortran library version (to ensure compatibility)
const double STAT::libversion=1.09;
const double STAT::libversion=1.10;
const char* const STAT::LINEID="STAT";
const char* const FREE::LINEID="FREE";
const char* const SRCE::LINEID="SRCE";
......@@ -85,7 +85,7 @@ namespace sff {
std::string code("");
if (this->hasfree) { code.append("F"); }
if (this->hassrce) { code.append("S"); }
sprintf(charline, "%4s %6.2f %13s %10s\n",
sprintf(charline, "%-4s %6.2f %-13s %-10s\n",
STAT::LINEID,
STAT::libversion,
timestamp.c_str(),
......@@ -108,7 +108,7 @@ namespace sff {
int yeardigits, century;
century=int(date.year()/100);
yeardigits=date.year()-100*century;
sprintf(charline, "%4s %20s %1c %15.6f%15.6f%15.6f "
sprintf(charline, "%-4s %-20s %1c %15.6f%15.6f%15.6f "
"%2.2i%2.2li%2.2li %2.2li%2.2li%2.2li.%3.3li\n",
SRCE::LINEID,
type.c_str(),
......@@ -134,7 +134,7 @@ namespace sff {
if (this->hasfree) { code.append("F"); }
if (this->hasinfo) { code.append("I"); }
if (!this->last) { code.append("D"); }
sprintf(charline, "%4s %10i %16.6e %10s\n",
sprintf(charline, "%-4s %10i %16.6E %-10s\n",
DAST::LINEID,
nchar, ampfac, code.c_str());
std::string retval(charline);
......@@ -149,11 +149,11 @@ namespace sff {
void FREE::write(std::ostream& os) const
{
os << FREE::LINEID << std::endl;
os << FREE::LINEID << " " << std::endl;
for(Tlines::const_iterator I=lines.begin();
I != lines.end(); I++)
{ os << *I << std::endl; }
os << FREE::LINEID << std::endl;
os << FREE::LINEID << " " << std::endl;
} // FREE::write
/*----------------------------------------------------------------------*/
......@@ -198,7 +198,7 @@ namespace sff {
std::string INFO::line() const
{
char charline[60];
sprintf(charline, "%4s %1c %15.6f%15.6f%15.6f %4i\n",
sprintf(charline, "%-4s %1c %15.6f%15.6f%15.6f %4i\n",
INFO::LINEID,
coosysID(cs), cx, cy, cz, nstacks);
std::string retval(charline);
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sffxx.h,v 1.4 2003-12-23 14:00:00 tforb Exp $
* $Id: sffxx.h,v 1.5 2003-12-23 15:47:23 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -23,7 +23,7 @@
#define TF_SFFXX_H_VERSION \
"TF_SFFXX_H V1.0 "
#define TF_SFFXX_H_CVSID \
"$Id: sffxx.h,v 1.4 2003-12-23 14:00:00 tforb Exp $"
"$Id: sffxx.h,v 1.5 2003-12-23 15:47:23 tforb Exp $"
#include<string>
#include<list>
......@@ -212,13 +212,12 @@ namespace sff {
typedef typename C::Tcoc Tcoc;
OutputWaveform(const Tcoc& c, const TraceHeader& th,
const Enormmode& nm=NM_maxdyn):
Mseries(c), Mheader(th), Mnorm(nm)
{ Mheader.scan(Mseries,Mnorm); }
Mseries(c), Mheader(th)
{ Mheader.scanseries(Mseries,nm); }
void write(std::ostream& os) const;
private:
Tcoc Mseries;
TraceHeader Mheader;
WaveformNormalizer Mnorm;
}; // class Waveform
class InputWaveform {
......@@ -263,9 +262,9 @@ namespace sff {
const Enormmode& nm)
{
Mwid2.nsamples=0;
typename C::Tvalue maxval=0.;
typename C::Tvalue absval, value;
typename C::Tvalue null(0);
double maxval=0.;
double absval, value;
double null(0);
for(aff::Browser<C> i(c); i.valid(); ++i)
{
Mwid2.nsamples++;
......@@ -288,16 +287,16 @@ namespace sff {
void OutputWaveform<C>::write(std::ostream& os) const
{
Mheader.writeheader(os);;
GSE2::waveform::TDAT2writeCM6 fwriter(Mwid2.nsamples);
GSE2::waveform::TDAT2writeCM6 fwriter(Mheader.wid2().nsamples);
int idata;
typename C::Tvalue data;
for(aff::Iterator<C> i(c); i.valid(); ++i)
for(aff::Browser<C> i(Mseries); i.valid(); ++i)
{
data= *i;
if (Mheader.scale())
{ idata=int(std::nearbyint(data*Mheader.dast().ampfac)); }
{ idata=int(round(data*Mheader.dast().ampfac)); }
else
{ idata=int(std::nearbyint(data)); }
{ idata=int(round(data)); }
os << fwriter(idata);
}
Mheader.writetrailer(os);;
......
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