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

support format modifiers for libdatrwxx I/O

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: 4120
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent b29dc301
......@@ -31,11 +31,12 @@
* REVISIONS and CHANGES
* - 16/05/2011 V1.0 Thomas Forbriger
* - 27/05/2011 V1.1 test copy constructor and default constructor
* - 08/09/2011 V1.2 avoid deprecated ?anystream constructors
*
* ============================================================================
*/
#define CXXFFTWARTEST_VERSION \
"CXXFFTWARTEST V1.1 test fftw3 array engine"
"CXXFFTWARTEST V1.2 test fftw3 array engine"
#define CXXFFTWARTEST_CVSID \
"$Id$"
......@@ -235,15 +236,13 @@ int main(int iargc, char* argv[])
// open input file
// ---------------
if (opt.verbose) { cout << "open input file " << infilename << endl; }
// select file format
datrw::Eformat inputformat=datrw::anyID(opt.fileformat);
// open the input file with appropriate input mode
std::ios_base::openmode iopenmode
=datrw::ianystream::openmode(inputformat);
=datrw::ianystream::openmode(opt.fileformat);
// open file stream
std::ifstream ifs(infilename.c_str(), iopenmode);
// open seismic time series stream
datrw::ianystream is(ifs, inputformat);
datrw::ianystream is(ifs, opt.fileformat);
// read file specific header information
sff::SRCE srce;
......@@ -410,9 +409,9 @@ int main(int iargc, char* argv[])
// create output stream of desired file format
std::ios_base::openmode oopenmode
=datrw::oanystream::openmode(datrw::anyID(opt.fileformat));
=datrw::oanystream::openmode(opt.fileformat);
std::ofstream ofs(outfilename.c_str(), oopenmode);
datrw::oanystream os(ofs, datrw::anyID(opt.fileformat));
datrw::oanystream os(ofs, opt.fileformat);
// write srce data and file free block if supported
if (os.handlessrce()) { os << srce; }
......
......@@ -30,11 +30,12 @@
* REVISIONS and CHANGES
* - 11/03/2011 V1.0 Thomas Forbriger
* - 16/03/2011 V1.1 first operational version
* - 08/09/2011 V1.2 support format modifiers
*
* ============================================================================
*/
#define FIDASEXX_VERSION \
"FIDASEXX V1.1 FIt DAtaSEts - a C++ successor of fidase"
"FIDASEXX V1.2 FIt DAtaSEts - a C++ successor of fidase"
#define FIDASEXX_CVSID \
"$Id$"
......@@ -347,12 +348,12 @@ int main(int iargc, char* argv[])
// ---------------
if (opt.verbose) { cout << "open input file " << infile.filename << endl; }
// select file format
datrw::Eformat inputformat=datrw::anyID(opt.fileformat);
std::string inputformat=opt.fileformat;
// change file format if a specific format was given on the command line
// for this file
if (infilearg->haskey(formatkey))
{
inputformat=datrw::anyID(infilearg->value(formatkey));
inputformat=infilearg->value(formatkey);
}
// open the input file with appropriate input mode
std::ios_base::openmode iopenmode
......@@ -685,9 +686,9 @@ int main(int iargc, char* argv[])
// create output stream of desired file format
std::ios_base::openmode oopenmode
=datrw::oanystream::openmode(datrw::anyID(opt.fileformat));
=datrw::oanystream::openmode(opt.fileformat);
std::ofstream ofs(ofilename.c_str(), oopenmode);
datrw::oanystream os(ofs, datrw::anyID(opt.fileformat), opt.debug);
datrw::oanystream os(ofs, opt.fileformat, opt.debug);
// write srce data and file free block if supported
if (os.handlessrce()) { os << currentfile.srce; }
......
......@@ -13,11 +13,12 @@
*
* REVISIONS and CHANGES
* - 05/07/2011 V1.0 Thomas Forbriger
* - 08/09/2011 V1.1 support format modifiers
*
* ============================================================================
*/
#define FREGRA_VERSION \
"FREGRA V1.0 Spectrogram for unevenly sampled frequencies"
"FREGRA V1.1 Spectrogram for unevenly sampled frequencies"
#define FREGRA_CVSID \
"$Id$"
......@@ -229,10 +230,9 @@ int main(int iargc, char* argv[])
// open input file
if (opt.verbose) { cout << "open input file " << infile->name << endl; }
datrw::Eformat informat=datrw::anyID(opt.inputformat);
std::ifstream ifs(infile->name.c_str(),
datrw::ianystream::openmode(informat));
datrw::ianystream is(ifs, informat);
datrw::ianystream::openmode(opt.inputformat));
datrw::ianystream is(ifs, opt.inputformat);
// work on filoe header
sff::FREE infilefree;
......@@ -285,7 +285,6 @@ int main(int iargc, char* argv[])
tfxx::string::trimws(oss.str()));
}
if (opt.verbose) { cout << "open output file " << outfile << endl; }
datrw::Eformat outformat=datrw::anyID(opt.outputformat);
// check if output file exists and open
if (!opt.overwrite)
{
......@@ -293,8 +292,8 @@ int main(int iargc, char* argv[])
TFXX_assert((!file.good()),"ERROR: output file exists!");
}
std::ofstream ofs(outfile.c_str(),
datrw::oanystream::openmode(outformat));
datrw::oanystream os(ofs, outformat);
datrw::oanystream::openmode(opt.outputformat));
datrw::oanystream os(ofs, opt.outputformat);
// prepare and write file header
::sff::FREE outfilefree;
......
......@@ -31,11 +31,12 @@
* - 15/03/2005 V1.0 Thomas Forbriger
* - 09/03/2010 V1.1 added normalization
* - 22.12.2010 V1.2 implement libdatrwxx writing functions
* - 08.09.2011 V1.3 support format modifiers
*
* ============================================================================
*/
#define GATHERDIFF_VERSION \
"GATHERDIFF V1.2 calculate difference between shot gathers"
"GATHERDIFF V1.3 calculate difference between shot gathers"
#define GATHERDIFF_CVSID \
"$Id$"
......@@ -59,7 +60,7 @@ using std::endl;
struct Options {
bool verbose, debug, normalize, overwrite;
datrw::Eformat inputformat, outputformat;
std::string inputformat, outputformat;
double srtol;
}; // struct Options
......@@ -153,8 +154,8 @@ int main(int iargc, char* argv[])
opt.debug=cmdline.optset(2);
opt.normalize=cmdline.optset(3);
opt.overwrite=cmdline.optset(4);
opt.inputformat=datrw::anyID(cmdline.string_arg(5));
opt.outputformat=datrw::anyID(cmdline.string_arg(6));
opt.inputformat=cmdline.string_arg(5);
opt.outputformat=cmdline.string_arg(6);
opt.srtol=cmdline.double_arg(7);
TFXX_assert(cmdline.extra(), "ERROR: missing parameter: infile1!");
......
......@@ -33,11 +33,12 @@
* - 10/02/2011 V1.2 added option to calculate overall rms
* - 10/02/2011 V1.3 write trace coordinates
* - 04/03/2011 V1.4 report trace offset
* - 08/09/2011 V1.5 support format modifiers
*
* ============================================================================
*/
#define SIGVAL_VERSION \
"SIGVAL V1.4 extract values from input signals"
"SIGVAL V1.5 extract values from input signals"
#define SIGVAL_CVSID \
"$Id$"
......@@ -204,7 +205,7 @@ int main(int iargc, char* argv[])
{
// open input file
std::ifstream ifs(infile->name.c_str());
datrw::ianystream is(ifs, datrw::anyID(opt.inputformat));
datrw::ianystream is(ifs, opt.inputformat);
sff::SRCE srce;
is >> srce;
......
......@@ -13,11 +13,12 @@
*
* REVISIONS and CHANGES
* - 06/05/2011 V1.0 Thomas Forbriger
* - 08/09/2011 V1.1 support format modifiers
*
* ============================================================================
*/
#define SOUTIFU_VERSION \
"SOUTIFU V1.0 inversion for source time function"
"SOUTIFU V1.1 inversion for source time function"
#define SOUTIFU_CVSID \
"$Id$"
......@@ -55,7 +56,7 @@ struct Options {
bool verbose, debug, overwrite;
bool writestf, writeconvolved;
std::string stffilename, convolvedfilename, debuglevel;
datrw::Eformat datafileformat;
std::string datafileformat, outputfileformat;
}; // struct Options
/*----------------------------------------------------------------------*/
......@@ -67,7 +68,7 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
SOUTIFU_VERSION "\n"
"usage: soutifu [-v] [-o] [-wc f] [-ws f] [--type f]\n"
"usage: soutifu [-v] [-o] [-wc f] [-ws f] [--type f] [--Type f]\n"
" [-DEBUG=level]\n"
" parameters data synthetics" "\n"
" or: soutifu --help|-h" "\n"
......@@ -92,7 +93,10 @@ int main(int iargc, char* argv[])
"-v be verbose\n"
"-DEBUG=level produce debug output at level \"level\"\n"
"-o overwrite existing output files\n"
"--type f use file format type \"f\" for file I/O\n"
"--type f use file format type \"f\" for file input\n"
"--Type f use file format type \"f\" for file output\n"
" if --Type is not used input and output format will\n"
" be the same\n"
"-wc f write convolved synthetics to file \"f\"\n"
"-ws f write source time function to file \"f\"\n"
"\n"
......@@ -121,6 +125,8 @@ int main(int iargc, char* argv[])
{"xhelp",arg_no,"-"},
// 7: present full details
{"DEBUG",arg_yes,"0"},
// 8: file format
{"Type",arg_yes,"-"},
{NULL}
};
......@@ -153,13 +159,15 @@ int main(int iargc, char* argv[])
Options opt;
opt.verbose=cmdline.optset(1);
opt.overwrite=cmdline.optset(2);
opt.datafileformat=datrw::anyID(cmdline.string_arg(3));
opt.datafileformat=cmdline.string_arg(3);
opt.writeconvolved=cmdline.optset(4);
opt.convolvedfilename=cmdline.string_arg(4);
opt.writestf=cmdline.optset(5);
opt.stffilename=cmdline.string_arg(5);
opt.debug=cmdline.optset(7);
opt.debuglevel=cmdline.string_arg(7);
opt.outputfileformat=opt.datafileformat;
if (cmdline.optset(8)) { opt.outputfileformat=cmdline.optset(8); }
TFXX_assert(cmdline.extra(), "missing parameter string");
std::string parameters=cmdline.next();
......@@ -356,9 +364,9 @@ int main(int iargc, char* argv[])
TFXX_assert((!file.good()),"ERROR: output file exists!");
}
std::ios_base::openmode oopenmode
=datrw::oanystream::openmode(opt.datafileformat);
=datrw::oanystream::openmode(opt.outputfileformat);
std::ofstream ofs(opt.stffilename.c_str(), oopenmode);
datrw::oanystream os(ofs, opt.datafileformat, opt.debug);
datrw::oanystream os(ofs, opt.outputfileformat, opt.debug);
os << stffile.fileheader.srce();
for (unsigned int itrace=0; itrace<stffile.size(); ++itrace)
......@@ -382,9 +390,9 @@ int main(int iargc, char* argv[])
TFXX_assert((!file.good()),"ERROR: output file exists!");
}
std::ios_base::openmode oopenmode
=datrw::oanystream::openmode(opt.datafileformat);
=datrw::oanystream::openmode(opt.outputfileformat);
std::ofstream ofs(opt.convolvedfilename.c_str(), oopenmode);
datrw::oanystream os(ofs, opt.datafileformat, opt.debug);
datrw::oanystream os(ofs, opt.outputfileformat, opt.debug);
os << convolvedsynthetics.fileheader.srce();
for (unsigned int itrace=0; itrace<convolvedsynthetics.size(); ++itrace)
......
......@@ -32,11 +32,12 @@
* - 18/12/2007 V1.1 hunting bugs...
* - 21.12.2010 V1.2 implement output file type option
* - 27.07.2011 V1.3 implement apply trace modifier
* - 08.09.2011 V1.4 support format modifiers
*
* ============================================================================
*/
#define TIDOFI_VERSION \
"TIDOFI V1.3 time domain filter"
"TIDOFI V1.4 time domain filter"
#define TIDOFI_CVSID \
"$Id$"
......@@ -379,11 +380,10 @@ int main(int iargc, char* argv[])
std::ifstream file(outfile.c_str(),std::ios_base::in);
TFXX_assert((!file.good()),"ERROR: output file exists!");
}
datrw::Eformat outputformat=datrw::anyID(opt.outputformat);
std::ios_base::openmode oopenmode
=datrw::oanystream::openmode(outputformat);
=datrw::oanystream::openmode(opt.outputformat);
std::ofstream ofs(outfile.c_str(), oopenmode);
datrw::oanystream os(ofs, outputformat, opt.debug);
datrw::oanystream os(ofs, opt.outputformat, opt.debug);
// set flag to process header of first input file
bool firstfile=true;
......@@ -394,10 +394,10 @@ int main(int iargc, char* argv[])
{
// open input file
if (opt.verbose) { cout << "open input file " << infile->name << endl; }
datrw::Eformat inputformat=datrw::anyID(opt.inputformat);
std::string inputformat=opt.inputformat;
if (infile->haskey(formatkey))
{
inputformat=datrw::anyID(infile->value(formatkey));
inputformat=infile->value(formatkey);
}
std::ios_base::openmode iopenmode
=datrw::ianystream::openmode(inputformat);
......
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