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

place any to any tools in their own subdirectory

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: 4549
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent ef32cd77
This is a legacy version of the repository. It may be incomplete as well as
inconsistent. See README.history for details. For the old stock of the
repository copyright and licence conditions apply as specified for versions
commited after 2015-03-01. Use recent versions as a base for new development.
The legacy version is only stored to keep a record of history.
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id$
#
# Copyright (c) 2003 by Thomas Forbriger (BFO Schiltach)
#
# convert from SFF and convert GSE to SFF
#
# ----
# 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
# ----
#
# The targets in this package require some libraries.
#
# Fortran Code:
# gse2sff listsff sff2ascii
# require: libtf.a libsff.a libsffu.a libts.a libtime.a
#
# C++ code:
# sffextract
# require: libsffxx.a libtime++.a libgsexx.a libaff.a libtfxx.a
# anyextract any2sff anyindex
# additionally require: libdatrwxx.a
# anyextract
# additionally requires: libregexx.a
# or libboost.a
# (depends on your settings; see README.compile)
#
# REVISIONS and CHANGES
# 16/09/2003 V1.0 Thomas Forbriger
# 29/03/2006 V1.1 provide package
# 05/12/2007 V1.2 use new regex module after migration to fenoglio
# removed DOS exe-targets
# 17/12/2007 V1.3 moved to gfortran and 64bit
# 06/10/2010 V1.4 start migration to SVN scheme
# - remove fallback
# - check variables
# - package creation is not yet configured
# - libboost_regex is hardwired now
# 19/03/2011 V1.5 added libseife to snapshot package and reordered
# libraries in package
#
# ============================================================================
#
PROGRAMS=any2sff anyindex anyextract any2ascii gse2sff listsff \
sffextract sff2ascii sff2refra sff2seife codeco any2any
.PHONY: all
all: install doc
.PHONY: install
install: $(addprefix $(LOCBINDIR)/,$(PROGRAMS))
$(LOCBINDIR)/%: %
mkdir -pv $(LOCBINDIR)
/bin/mv -fv $< $(LOCBINDIR)
.PHONY: doc
doc: doxydoc
.PHONY: allstatic
allstatic:
$(MAKE) install \
PROGRAMS="any2sffstat anyindexstat anyextractstat any2asciistat"
flist: README Makefile $(wildcard *.f *.cc) doxydoc.cfg \
$(wildcard sub/*.cc sub/*.h)
echo $^ | tr ' ' '\n' | sort > $@
.PHONY: edit
edit: flist; vim $<
.PHONY: clean
clean:
-/bin/rm *.o *.bak *.o77 *.exe flist *.ps $(PROGRAMS) *.xxx *.d
-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
-find . -name \*.d | xargs --no-run-if-empty /bin/rm -v
# ============================================================================
#
CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1)))
CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var)))
#
$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR)
ifndef SERVERINCLUDEDIR
SERVERINCLUDEDIR=.
endif
ifndef SERVERLIBDIR
SERVERLIBDIR=.
endif
AR=ar
AS=as
RANLIB=ranlib
FLAGS += $(MYFLAGS) $(STATIC)
CFLAGS += -O2
FFLAGS += -ff2c -ffixed-line-length-none
CXXFLAGS += -Wall $(FLAGS)
LDFLAGS+=$(addprefix -L,$(LOCLIBDIR) $(subst :, ,$(SERVERLIBDIR)))
CPPFLAGS+=$(addprefix -I,$(LOCINCLUDEDIR) $(subst :, ,$(SERVERINCLUDEDIR))) \
$(FLAGS) -I sub
#======================================================================
# dependencies
# ------------
#
# The compiler is used to create dependency files, which are included below.
%.d: %.cc
$(SHELL) -ec '$(CXX) -M $(CPPFLAGS) $< \
| sed '\''s,\($(notdir $*)\)\.o[ :]*,$(dir $@)\1.o $@ : ,g'\'' \
> $@; \
[ -s $@ ] || rm -f $@'
SRCFILES=$(wildcard *.cc sub/*.cc)
include $(patsubst %.cc,%.d,$(SRCFILES))
#----------------------------------------------------------------------
%.o: %.f
$(FC) $(FFLAGS) -c $< -o $@
codeco: codecoLinux.o
$(FC) $(FFLAGS) $< -o $@
gse2sff listsff sff2ascii sff2refra sff2seife: %: %.o
$(FC) -o $@ $< $(FFLAGS) -ltf -lts -lsffu -lsff -ltime -lm -lc \
-L${LOCLIBDIR} $(LDFLAGS)
sffextract: %: %.o
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -lsffxx -ltime++ -lgsexx -laff \
-ltfxx -L$(LOCLIBDIR) $(CXXFLAGS) $(FLAGS) $(LDFLAGS)
GAPANALYSISOBS=sub/completenessbins.o \
sub/fncompleteness.o \
sub/fngaps.o \
sub/fnprintgaps.o \
sub/fnseriesofmissingsamples.o \
sub/structgapanalysis.o \
sub/structgapseries.o
anyextract: %: %.o $(GAPANALYSISOBS)
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -ldatrwxx \
-lsffxx -ltime++ -lgsexx -laff -ltfxx -lboost_regex \
-L$(LOCLIBDIR) $(CXXFLAGS) $(FLAGS) $(STATIC) $(LDFLAGS)
anyextractstat: %stat: %.o $(GAPANALYSISOBS)
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -ldatrwxx -static \
-lsffxx -ltime++ -lgsexx -laff -ltfxx -lboost_regex \
-L$(LOCLIBDIR) $(CXXFLAGS) $(FLAGS) $(STATIC) $(LDFLAGS)
any2any: %: %.o
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -ldatrwxx \
-lsffxx -ltime++ -lgsexx -laff -ltfxx \
-L$(LOCLIBDIR) $(CXXFLAGS) $(FLAGS) $(STATIC) $(LDFLAGS)
anyindex any2ascii any2sff: %: %.o
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -ldatrwxx \
-lsffxx -ltime++ -lgsexx -laff \
-ltfxx -L$(LOCLIBDIR) $(CXXFLAGS) $(FLAGS) $(LDFLAGS)
any2asciistat any2sffstat anyindexstat: %stat: %.o
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -static -ldatrwxx \
-lsffxx -ltime++ -lgsexx -laff -ltfxx -lboost_regex \
-L$(LOCLIBDIR) $(CXXFLAGS) $(FLAGS) $(LDFLAGS)
%.ps: %.cc
a2ps -1 -o $@ \
--center-title="$(shell ident $< | grep $< | tail -1 | tr '$$' ' ')" \
$<
%.psp: %.ps; gv $<; /bin/rm -fv $<
#======================================================================
# documentation part
# ------------------
#
# targets commonly used:
# ----------------------
#
# make doxyclean removes all documentation
# make doxydoc creates doxygen documentation in the DOXYWWWPATH
# make doxyview creates doxygen documentation and launches netscape to
# browse in the documentation
# make doxyconf edit the doxygen configuration file
#
# If you launch "make doxydoc" the documentation will be written to
# DOXYWWWPATH (see below). This is meant to export the documentation through
# your homepage. The doxyfull directory is just a symbolic link to this
# directory.
#
$(call CHECKVARS,TF_WWWBASEDIR TF_BROWSER)
DOXYWWWPATH=$(TF_WWWBASEDIR)/convsff
.PHONY: doxyclean doxyview doxydoc doxyconf
doxyclean: ;/bin/rm -rfv $(DOXYWWWPATH)
DOXYSRC=Makefile README $(wildcard *.cc *.c *.h *.f sub/*.cc sub/*.h)
# create doxygen intermediate configuration
PWD=$(shell env pwd)
doxydoc.xxx: doxydoc.cfg
sed 's,<OUTPUTDIRECTORY>,$(DOXYWWWPATH),g;s,<STRIPFROMPATH>,$(PWD),g' \
$< > $@
# create commented version of doxygen configuration
doxycomm.xxx: doxydoc.cfg
/bin/cp -vf $< $@; doxygen -u $@
$(DOXYWWWPATH)/html/index.html: doxydoc.xxx $(DOXYSRC)
mkdir -vp $(DOXYWWWPATH)
doxygen $<
doxydoc: $(DOXYWWWPATH)/html/index.html
doxyview: $(DOXYWWWPATH)/html/index.html
$(TF_BROWSER) file:$< &
#======================================================================
# create package
# --------------
# is delegated to Makefile.packages
ifdef TF_MAKEPKG
.PHONY: package
package: $(TF_MAKEPKG)
$(MAKE) -f $< \
PACKAGE=convsff \
PACKAGEEXPORT="trunk/src/conv/sff:src" \
PACKAGETARGETS="src:all" \
PACKAGELIBS="-"
.PHONY: fullpackage
fullpackage: $(TF_MAKEPKG)
$(MAKE) -f $< \
PACKAGE=convsffwithlibs \
PACKAGEEXPORT="trunk/src/conv/sff:src" \
PACKAGETARGETS="src:all" \
PACKAGELIBS="libsff:libseife:libtime:libaff:libsffu:libts:libgsexx:libsffxx:libdatrwxx:libtsxx:libtfxx:libtf"
endif
# ----- END OF Makefile -----
/*! \file README
\mainpage SFF conversion tools and friends
- \ref any2any.cc
- \ref any2ascii.cc
- \ref any2sff.cc
- \ref anyextract.cc
- \ref anyindex.cc
- \ref codecoLinux.f
- \ref gse2sff.f
- \ref listsff.f
- \ref Makefile
- \ref sff2ascii.f
- \ref sff2refra.f
- \ref sff2seife.f
- \ref sffextract.cc
\verbatim
this is <README>
============================================================================
SFF conversion tools and friends
--------------------------------
$Id$
============================================================================
General format conversion
-------------------------
any2any
Converts files for any input format supported by lindatrwxx reading modules
to any output format supported by libdatrwxx writing modules. This program
not at all is SFF specific.
any2ascii
Converts files to ASCII for any input format supported by lindatrwxx reading
modules.
any2sff
Converts files to SFF for any input format supported by lindatrwxx reading
modules.
anyindex
Create index files for any format supported by lindatrwxx reading modules.
anyextract
Evaluates the anyindex output files for data completeness and extracts
specific subsets of the data based on time window and channel and station
codes. This program is able to string time series (data blocks) of the same
data stream to one long time series. It perform consistency checks and is
able to identify duplicate samples and gaps in the input. A special option
is provided to produce a liast of contiguous data time windows as listed in
the input index file.
SFF specific format conversion
------------------------------
sffextract
Extracts a specific time window from an SFF data file.
gse2sff
This program converts any GSE formatted CM6 encoded waveform data file to
SFF (the Stuttgart File Format). SFF adds some IDs to GSE format.
You may provide any waveform data in the form of the text file received
directly from an AutoDRM via e-mail. All text surrounding the data traces
will be enclosed within FREE-blocks.
codeco
If you can't receive GSE format data in CM6 compression you may use this
program to convert the data sample representation. Agein you may feed full
e-mail text messages to this programm.
codeco.f was written by Urs Kradolfer and Karl Koch and is distributed
together with the sources of the Swiss AutoDRM.
sff2ascii
You may convert any SFF data file to a set of pure ASCII one- or two-column
data files.
listsff
This program helps reading the SFF trace headers. It will output the whole
data file except the DAT2-blocks (i.e. encoded data samples).
sff2seife
This program converts SFF data to seife format (Erhard Wielandt's seismic
analysis and filter tools).
sff2refra
This program converts SFF data to refra format (refraction seismics
data inversion, K.J. Sandmeier).
Most programs support an online help options. Just call the
program without any option to get a hint.
============================================================================
Installation:
The Makefile supports program compilation and linking. Some binary libraries
are required. See the comments in the Makefile for details.
============================================================================
Contents of subdirectories:
gseC: GSE reading and writing functions from Stefan Stange
res: codeco conversion program distributed together with SwissDRM
============================================================================
Please send bug reports and suggestions to
Thomas.Forbriger@kit.edu
----- END OF README -----
\endverbatim
*/
/*! \file any2any.cc
* \brief conversion between libdatrwxx data file formats
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Thomas Forbriger
* \date 26/11/2010
*
* conversion between libdatrwxx data file formats
*
* Copyright (c) 2010 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
* - 26/11/2010 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define ANY2ANY_VERSION \
"ANY2ANY V1.0 conversion between libdatrwxx data file formats"
#define ANY2ANY_CVSID \
"$Id$"
#include <iostream>
#include <fstream>
#include <tfxx/commandline.h>
#include <tfxx/xcmdline.h>
#include <tfxx/error.h>
#include <tfxx/misc.h>
#include <tfxx/rangestring.h>
#include <tfxx/rangelist.h>
#include <datrwxx/readany.h>
#include <datrwxx/writeany.h>
#include <datrwxx/datatypes.h>
using std::cout;
using std::cerr;
using std::endl;
struct Options {
bool verbose, overwrite, debug, integer, single;
bool verboseconversion;
std::string inputformat, outputformat;
}; // struct Options
/*======================================================================*/
int main(int iargc, char* argv[])
{
// define usage information
char usage_text[]=
{
ANY2ANY_VERSION "\n"
"usage: any2any [--verbose] [--overwrite] [--integer] [--single]" "\n"
" [--itype t] [--otype t] [--vconversion]" "\n"
" outfile infile [t:T] [f:F] [infile [t:T] [f:F] ... ]" "\n"
" or: any2any --help|-h" "\n"
" or: any2any --xhelp" "\n"
};
// define full help text
char help_text[]=
{
ANY2ANY_CVSID "\n"
"\n"
"Options may be abbreviated to a short string as long as they" "\n"
"remain unique. \"-v\" is identical to \"--verbose\"." "\n"
"\n"
"--verbose be verbose" "\n"
"--vconversion be verbose on type conversion" "\n"
"--overwrite overwrite output if file already exists" "\n"
"--integer use integer values for copying" "\n"
"--single use single precision floats for copying" "\n"
" default data type for copying is double presicion floats\n"
"--itype t standard format of input file(s) (see below)" "\n"
"--otype t data format of output file (see below)" "\n"
"\n"
"outfile output data file name" "\n"
"infile input data file name" "\n"
"\n"
"File specific options:" "\n"
"t:T select specfic traces from input file" "\n"
" T can be a list of traces like \"1,4,5\" or" "\n"
" a range like \"6-19\" or mixed like \"5,8,12-17,20\"" "\n"
"f:F specify file format (overrides --itype setting)" "\n"
"\n"
"The output format might not be able to store all header information" "\n"
"from the input data." "\n"
};
// define commandline options
using namespace tfxx::cmdline;
static Declare options[]=
{
// 0: print help
{"help",arg_no,"-"},
// 1: print help
{"xhelp",arg_no,"-"},
// 2: verbose mode
{"verbose",arg_no,"-"},
// 3: overwrite output
{"overwrite",arg_no,"-"},
// 4: overwrite output
{"itype",arg_yes,"sff"},
// 5: overwrite output
{"otype",arg_yes,"sff"},
// 6: overwrite output
{"DEBUG",arg_no,"-"},
// 7: read integer data
{"integer",arg_no,"-"},
// 8: read single precision data
{"single",arg_no,"-"},
// 9: read single precision data
{"vconversion",arg_no,"-"},
{NULL}
};
static const char tracekey[]="t";
static const char formatkey[]="f";
// define commandline argument modifier keys
static const char* cmdlinekeys[]={tracekey, formatkey, 0};
/*----------------------------------------------------------------------*/
// action!
// 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) || cmdline.optset(1))
{
cerr << usage_text << endl;
cerr << help_text << endl;
datrw::supported_data_types(cerr);
if (cmdline.optset(1))
{
cerr << endl;
datrw::online_help(cerr);
}
exit(0);
}
// extract command line options
Options opt;
opt.verbose=cmdline.optset(2);
opt.overwrite=cmdline.optset(3);
opt.inputformat=cmdline.string_arg(4);
opt.outputformat=cmdline.string_arg(5);
opt.debug=cmdline.optset(6);
opt.integer=cmdline.optset(7);
opt.single=cmdline.optset(8);
opt.verboseconversion=cmdline.optset(9);
if (opt.verbose) { cout << ANY2ANY_VERSION "\n" << ANY2ANY_CVSID "\n"; }
if (opt.verboseconversion)
{
::datrw::report_type_conversion();
}
// extract commandline arguments
TFXX_assert(cmdline.extra(), "missing output file");
std::string outfile=cmdline.next();
TFXX_assert(cmdline.extra(), "missing input file");
tfxx::cmdline::Tparsed arguments=parse_cmdline(cmdline, cmdlinekeys);
if ((arguments.size()>1) && opt.verbose)
{
cout << "NOTICE: file specific information (SRCE line and file FREE)\n"
<< " of the second and subsequent files might get lost!\n";
}
/*----------------------------------------------------------------------*/
// full action!
// check whether output file exists
if (opt.verbose)
{
cout << "open output file " << outfile
<< " with format " << opt.outputformat << endl;
}
if (!opt.overwrite) { datrw::abort_if_exists(outfile); }
std::ofstream ofs(outfile.c_str(),
datrw::oanystream::openmode(opt.outputformat));
datrw::oanystream os(ofs, opt.outputformat, opt.debug);
if (opt.verbose) {
cout << "file data is stored in ";
// report output data format
switch (os.seriestype()) {
case datrw::Fint:
cout << "integer";
break;
case datrw::Ffloat:
cout << "single precision floating point";
break;
case datrw::Fdouble:
cout << "double precision floating point";
break;
case datrw::Fall:
cout << "any desired";
break;
default:
TFXX_abort("output stream uses unknown variable type!");
} // switch (os.seriestype())
cout << " variable type" << endl;
}
// cycle through all input files
// -----------------------------
bool firstfile=true;
tfxx::cmdline::Tparsed::const_iterator infile=arguments.begin();
while (infile != arguments.end())
{
// open input file
std::string inputformat=opt.inputformat;
if (infile->haskey(formatkey))
{ inputformat=infile->value(formatkey); }
if (opt.verbose)
{
cout << "open input file " << infile->name
<< " of format " <<