76 "usage: gatherdiff infile1 infile2 outfile [-v] [-n]" "\n" 77 " [--overwrite] [--type f] [--Type f]" "\n" 78 " [--srtol r] [--ignorecoo]" "\n" 79 " or: gatherdiff --help|-h" "\n" 80 " or: gatherdiff --xhelp" "\n" 86 "This program takes two data files as input. It assumes" "\n" 87 "that both contain full record gathers with identical recording" "\n" 88 "parameters. Typically these will be two sets of synthetic" "\n" 89 "seismograms that were calculated for different subsurface" "\n" 90 "models. The residual of these two sets is calculated and written" "\n" 91 "to the output, together with shot an receiver coordinates of" "\n" 92 "the first input set." "\n" 94 "infile1 name of first SFF input file" "\n" 95 "infile2 name of second SFF input file" "\n" 96 "outfile name of output file (outfile=infile1-infile2)" "\n" 99 "-n normalize input time series to their absolute maximum" "\n" 100 "--overwrite overwrite out put file (in case it already exists)" "\n" 101 "--type f input files have data file format \"f\"" "\n" 102 "--Type f output file will be written in data file format \"f\"" "\n" 103 "--srtol r set sampling rate tolerance for comaprison of" "\n" 105 "--ignorecoo ignore coordinates when checking trace consistency\n" 109 using namespace tfxx::cmdline;
110 static Declare options[]=
117 {
"DEBUG",arg_no,
"-"},
121 {
"overwrite",arg_no,
"-"},
123 {
"type",arg_yes,
"sff"},
125 {
"Type",arg_yes,
"sff"},
127 {
"srtol",arg_yes,
"0.001"},
129 {
"ignorecoo",arg_no,
"-"},
134 Commandline cmdline(iargc, argv, options);
137 if (cmdline.optset(0))
139 cerr << usage_text << endl;
140 cerr << help_text << endl;
147 cerr << usage_text << endl;
153 opt.
debug=cmdline.optset(2);
158 opt.
srtol=cmdline.double_arg(7);
161 TFXX_assert(cmdline.extra(),
"ERROR: missing parameter: infile1!");
162 std::string infile1=cmdline.next();
163 TFXX_assert(cmdline.extra(),
"ERROR: missing parameter: infile2!");
164 std::string infile2=cmdline.next();
165 TFXX_assert(cmdline.extra(),
"ERROR: missing parameter: outfile!");
166 std::string outfile=cmdline.next();
170 cout <<
"tolerance when comparing sampling interval: " << opt.
srtol <<
172 cout <<
"input format: " << cmdline.string_arg(5) <<
"\n";
173 cout <<
"output format: " << cmdline.string_arg(6) <<
"\n";
176 if (opt.
verbose) { cout <<
"open input file (#1) " << infile1 << endl; }
177 std::ios_base::openmode iopenmode
179 std::ifstream ifs1(infile1.c_str(), iopenmode);
186 if (opt.
verbose) { cout <<
"open input file (#2) " << infile2 << endl; }
187 std::ifstream ifs2(infile2.c_str(), iopenmode);
196 TFXX_assert((source1.cs == source2.cs) &&
197 (source1.cx == source2.cx) &&
198 (source1.cy == source2.cy) &&
199 (source1.cz == source2.cz),
200 "ERROR: coordinates do not match!");
203 if (opt.
verbose) { cout <<
"open output file " << outfile << endl; }
204 std::ios_base::openmode oopenmode
206 std::ofstream ofs(outfile.c_str(), oopenmode);
208 sff::FREE outfilefree;
210 outfilefree.append(
"input file #1: "+infile1);
211 outfilefree.append(
"input file #2: "+infile2);
212 outfilefree.append(
"input FREE #1:");
213 outfilefree.append(filefree1);
214 outfilefree.append(
"input FREE #2:");
215 outfilefree.append(filefree2);
216 if (os.handlessrce()) { os << source1; }
217 if (os.handlesfilefree()) { os << outfilefree; }
220 while (is1.good() && is2.good())
222 if (opt.
verbose) { cout <<
"process trace #" << ++itrace << endl; }
224 sff::WID2 wid2in1, wid2in2, wid2out;
225 sff::INFO infoin1, infoin2;
226 sff::FREE tracefreein1, tracefreein2, outtracefree;
236 outtracefree.append(
"input FREE #1:");
237 outtracefree.append(tracefreein1);
238 outtracefree.append(
"input FREE #2:");
239 outtracefree.append(tracefreein2);
240 TFXX_assert((wid2in1.date-source1.date) == (wid2in2.date-source2.date),
241 "ERROR: times do not match!");
242 double dtreldev=1-(wid2in1.dt/wid2in2.dt);
243 if (dtreldev<0) { dtreldev *= -1.; }
244 TFXX_debug(opt.
debug,
"gatherdiff",
245 "dt infile 1: "<< wid2in1.dt
246 <<
" dt infile 2: "<< wid2in2.dt
247 <<
" relative deviation: "<< dtreldev);
248 TFXX_assert(dtreldev <= opt.
srtol,
249 "ERROR: sampling interval does not match!");
250 TFXX_assert(wid2in1.nsamples == wid2in2.nsamples,
251 "ERROR: numer of samples does not match!");
254 TFXX_assert((infoin1.cs == infoin2.cs) &&
255 (infoin1.cx == infoin2.cx) &&
256 (infoin1.cy == infoin2.cy) &&
257 (infoin1.cz == infoin2.cz),
258 "ERROR: coordinates do not match!");
261 wid2out.channel=
"dif";
264 outtracefree.append(
"input series are normalized to their absolute maximum of 1");
265 double max1=aff::func::absmax(series1);
266 double max2=aff::func::absmax(series2);
269 cout <<
"normalize input time series to absolute maximum of 1" <<
271 cout <<
"absolute maximum of first input series: " << max1 << endl;
272 cout <<
"absolute maximum of second input series: " << max2 << endl;
277 Tseries outseries=series1-series2;
279 if (os.handlesinfo()) { os << infoin1; }
280 if (os.handlesfilefree()) { os << outtracefree; }
#define GATHERDIFF_VERSION
aff::Series< double > Tseries