Waveform filter programs
geophone.cc
Go to the documentation of this file.
1 
49 #define GEOPHON_VERSION \
50  "GEOPHONE V1.4 calculate geophone response"
51 
52 #include <iostream>
53 #include <fstream>
54 #include <string>
55 #include <sstream>
56 #include <tfxx/commandline.h>
57 #include <tfxx/error.h>
58 #include <tfxx/misc.h>
59 #include <aff/series.h>
60 #include <aff/seriesoperators.h>
61 #include <sffostream.h>
62 
63 using std::cout;
64 using std::cerr;
65 using std::endl;
66 
67 struct Tparameters {
68  /* basic parameters
69  * hoc: open circuit damping
70  * C: geophone constant
71  * heff: effective damping
72  * Rc: coil resistance
73  * Ri: effective damping resistance
74  * in standard application (without extra damping) this is the input
75  * resistance of the recording system essentially
76  * in case of additional damping, this is the effective resistance
77  * shunting the geophone
78  * fn: natural frequency
79  */
80  double hoc, C, heff, Rc, Ri, fn;
81  /* divider parameters
82  * R1: resistance in series to geophone
83  * Rd: resistance parallel to recording system
84  * V: division factor relative to standard application (only recorder
85  * shunts the geophone)
86  */
87  double R1, Rd, V;
88  /* geophone type */
89  std::string type;
90 }; // struct Tparameters
91 
92 struct Toptions {
94  bool debug;
95  std::string outfile,resfile;
96  double T, dt, V, Rd, R1;
97 }; // struct Toptions
98 
99 const double pi=3.1415926535;
100 
101 typedef aff::Series<double> Tseries;
102 
103 /*----------------------------------------------------------------------*/
104 
105 /* for the given parameters
106  * fn: natural frequency
107  * h: effective damping
108  * dt: sampling interval
109  * n: number of samples
110  *
111  * this function calculates the impulse response of the system
112  * and returns it as a series
113  */
114 Tseries response(const double& fn, const double& h, const double& dt,
115  const int& n)
116 {
117  const double eps=1.e-4;
118  Tseries result(n);
119  for (int i=result.first(); i<=result.last(); i++)
120  {
121  double t=double(i)*dt;
122  double omn=2.*pi*fn;
123  if (h>(1.+eps))
124  {
125  double hfac=std::sqrt(h*h-1.);
126  result(i)=std::exp(-omn*h*t)*
127  (std::exp(-omn*t*hfac)-std::exp(omn*t*hfac))/
128  (-2.*omn*hfac);
129  } else if (h<(1.-eps))
130  {
131  double hfac=std::sqrt(1.-h*h);
132  result(i)=std::sin(omn*t*hfac)*std::exp(-omn*h*t)/(omn*hfac);
133  } else
134  {
135  result(i)=t*std::exp(-omn*t);
136  }
137  }
138  return(result);
139 } // response
140 
141 /*----------------------------------------------------------------------*/
142 
143 /* returns effectice damping as a fraction of critical damping for
144  * fn: natural frequency
145  * hoc: open circuit damping
146  * C: geophone constant
147  * Rc: coil resistance
148  * Rs: effective shunt resistance
149  */
150 inline double func_heff(const double& fn, const double& hoc, const double& C,
151  const double& Rc, const double& Rs)
152 {
153  double heff;
154  heff=hoc+(C/((Rs+Rc)*fn));
155  return heff;
156 }
157 
158 /*----------------------------------------------------------------------*/
159 
160 /* returns shunt resistance required for
161  * fn: natural frequency
162  * hoc: open circuit damping
163  * C: geophone constant
164  * Rc: coil resistance
165  * heff: desiresd effective damping
166  */
167 inline double func_Rs(const double& fn, const double& hoc, const double& C,
168  const double& Rc, const double& heff)
169 {
170  double Rs;
171  Rs=(C/((heff-hoc)*fn))-Rc;
172  return Rs;
173 }
174 
175 /*----------------------------------------------------------------------*/
176 
177 /* returns effective shunt resistance parallel to geophone for
178  * Ri: input resistance of recording system
179  * Rd: damping resistance parallel to recorder
180  * R1: resistance in series to geophone
181  */
182 inline double func_Rs(const double& Ri, const double& Rd,
183  const double& R1)
184 {
185  double Rs;
186  Rs=R1+1./((1./Rd)+(1./Ri));
187  return Rs;
188 }
189 
190 /*----------------------------------------------------------------------*/
191 
192 /* returns external damping resistance parallel to recorder for
193  * Rs: effective shunt resistance
194  * Ri: input resistance of recording system
195  */
196 inline double func_Rd(const double& Rs, const double& Ri)
197 {
198  double Rd;
199  Rd=1./((1./Rs)-(1./Ri));
200  return Rd;
201 }
202 
203 /*----------------------------------------------------------------------*/
204 
205 /* returns voltage divider for standard application with given
206  * Ri: input resistance of recording system
207  * Rc: coil resistance
208  */
209 inline double func_V(const double& Ri, const double& Rc)
210 {
211  double V;
212  // factor for standard application
213  V=1./((Rc/Ri)+1.);
214  return V;
215 }
216 
217 /*----------------------------------------------------------------------*/
218 
219 /* returns voltage divider for full external damping
220  * Ri: input resistance of recording system
221  * Rc: coil resistance
222  * R1: resistance in series to geophone
223  * Rd: resistance parallel to recorder
224  */
225 inline double func_V(const double& Ri, const double& Rc,
226  const double& R1, const double& Rd)
227 {
228  double V;
229  // factor for standard application
230  V=func_V(func_Rs(Ri, Rd, 0.), (R1+Rc));
231  return V;
232 }
233 
234 /*----------------------------------------------------------------------*/
235 
236 /* returns external damping resistance parallel to recorder for
237  * Ri: input resistance of recording system
238  * Rc: coil resistance
239  * V: desired divider constant (V <= 1)
240  */
241 inline double func_RdV(const double& Ri, const double& Rc,
242  const double& V)
243 {
244  double Rd;
245  TFXX_assert((V <= 1),"ERROR (func_RdV): division factor not less than 1!");
246  TFXX_assert((V > 0),"ERROR (func_RdV): division factor not greater than 0!");
247  Rd=Rc/((1./V-(Rc/Ri)-1.));
248  return Rd;
249 }
250 
251 /*----------------------------------------------------------------------*/
252 
253 /* returns value for resistance in series with geophone for
254  * Rc: coil resistance
255  * Ri: input resistance of recording system
256  * Rs: desired shunt resistance
257  * which is R1 in series of (Ri and Rd in parallel)
258  * V: desired divider constant (V <= 1)
259  */
260 inline double func_R1(const double& Ri, const double& Rc,
261  const double& Rs, const double& V)
262 {
263  double R1;
264  TFXX_assert((V <= 1),"ERROR (func_R1): division factor not less than 1!");
265  TFXX_assert((V > 0),"ERROR (func_R1): division factor not greater than 0!");
266  R1=Rs-V*(Rc+Rs);
267  return R1;
268 }
269 
270 /*----------------------------------------------------------------------*/
271 
272 /* returns value for resistance parallel to recorder for
273  * Rc: coil resistance
274  * Ri: input resistance of recording system
275  * Rs: desired shunt resistance
276  * which is R1 in series of (Ri and Rd in parallel)
277  * V: desired divider constant (V <= 1)
278  */
279 inline double func_R2(const double& Ri, const double& Rc,
280  const double& Rs, const double& V)
281 {
282  double R2;
283  TFXX_assert((V <= 1),"ERROR (func_R1): division factor not less than 1!");
284  TFXX_assert((V > 0),"ERROR (func_R1): division factor not greater than 0!");
285  R2=1./((1./(V*(Rc+Rs)))-(1./Ri));
286  return R2;
287 }
288 
289 /*----------------------------------------------------------------------*/
290 /* write parameters to output stream
291  */
292 void writeparameters(std::ostream& os,
293  const std::string& prefix,
294  const Tparameters& para,
295  const double& hnd,
296  const double& heff, const double& Rs,
297  const double& R1, const double& Rd,
298  const double& Afac, const double& Afaceff)
299 {
300  os << prefix << GEOPHON_VERSION << endl;
301  os << prefix << endl;
302  os << prefix << "geophone parameters:" << endl;
303  os << prefix << "--------------------" << endl;
304  os << prefix << " geophone type: " << para.type
305  << endl;
306  os << prefix << " natural frequency: " << para.fn << " Hz"
307  << endl;
308  os << prefix << " coil resistance: " << para.Rc << " Ohm"
309  << endl;
310  os << prefix << " open circuit damping: " << para.hoc
311  << endl;
312  os << prefix << " geophone constant C: " << para.C << " Ohm*Hz"
313  << endl;
314  os << prefix << " C=Rt*Bc*fn=(K**2)/(4*pi*m)" << endl;
315 
316  os << prefix << endl;
317  os << prefix << " recorder input resistance: " << para.Ri << " Ohm"
318  << endl;
319 
320  os << prefix << endl;
321  os << prefix << "reference parameters:" << endl;
322  os << prefix << "---------------------" << endl;
323  os << prefix << "(parameters for the case that the geophones are" << endl
324  << prefix << "connected directly to the recorder, without any" << endl
325  << prefix << "external resitance)" << endl;
326  os << prefix << " damping: "
327  << hnd << endl;
328  os << prefix << " amplitude as a fraction of open circuit amplitude: "
329  << 100.*Afac << "%" << endl;
330 
331  os << prefix << endl;
332  os << prefix << "parameters with external damping resistance:" << endl;
333  os << prefix << "--------------------------------------------" << endl;
334  os << prefix << " shunt resistance parallel to recorder terminals: "
335  << Rd << " Ohm" << endl;
336  os << prefix << " additional resistance in series to the geophone: "
337  << R1 << " Ohm" << endl;
338  os << prefix << " effective damping: "
339  << heff << endl;
340  os << prefix << " amplitude as a fraction of open circuit amplitude: "
341  << 100.*Afaceff << "%" << endl;
342  os << prefix << " amplitude as a fraction of reference fraction: "
343  << 100.*Afaceff/Afac << "%" << endl;
344 
345  os << prefix << endl;
346  os << prefix
347  << " effective shunt resistance parallel to geophone terminals: "
348  << Rs << " Ohm" << endl;
349  os << prefix
350  << " effective geophone resistance (with series resistance): "
351  << para.Rc+R1 << " Ohm" << endl;
352  os << prefix
353  << " eff. recorder resistance (with ext. resistance in parallel): "
354  << func_Rs(para.Ri, Rd, 0.) << " Ohm" << endl;
355 
356  os << prefix << endl;
357  os << prefix
358  << "All damping values are given as a fraction of critical damping."
359  << endl;
360 } // writeparameters
361 
362 /*----------------------------------------------------------------------*/
363 
364 int main(int iargc, char* argv[])
365 {
366 
367  // define usage information
368  char usage_text[]=
369  {
370  GEOPHON_VERSION "\n"
371  "usage: geophone [-hoc hoc] [-heff heff] [-Ri Ri] [-Rc Rc]" "\n"
372  " [-C C] [-fn fn] [-type type] [-o file]" "\n"
373  " [-T T] [-dt dt] [-Rd1 Rd,R1]" "\n"
374  " or: geophone --help|-h" "\n"
375  };
376 
377  // define full help text
378  char help_text[]=
379  {
380  "-v be verbose" "\n"
381  "-DEBUG debug mode" "\n"
382  "\n"
383  "geophone parameters:\n"
384  "-hoc hoc open circuit damping" "\n"
385  "-Rc Rc coil resistance" "\n"
386  "-C C geophone constant" "\n"
387  " C=Rt*Bc*fn=(K**2)/(4*pi*m)" "\n"
388  "-fn fn natural frequency" "\n"
389  "-type type geophone type" "\n"
390  "\n"
391  "recorder parameters:\n"
392  "-Ri Ri recorder input resistance" "\n"
393  "\n"
394  "desired damping:\n"
395  "-heff heff desired effective damping" "\n"
396  "\n"
397  "output parameters:\n"
398  "-o file name of file to save impulse response" "\n"
399  " parameters T and dt specify the sampling for\n"
400  " the impulse response time series\n"
401  "-T T length of time series" "\n"
402  " as a fraction of the natural period" "\n"
403  "-dt dt sampling interval" "\n"
404  " as a fraction of the natural period" "\n"
405  "\n"
406  "-resfile file Write an appropriate seife deconvolution" "\n"
407  " filter to \"file\". The filter is designed" "\n"
408  " to deconvolve the output of the damped geophone" "\n"
409  " to the repsonse of the standard application (i.e." "\n"
410  " geophone connected directly to recorder)." "\n"
411  "\n"
412  "alternative modes of operation:\n"
413  "-R2 V return R2 for voltage division factor V" "\n"
414  " specified relative to the voltage obtained" "\n"
415  " by standard operation (Ri being the only" "\n"
416  " resistance external to the geophone)." "\n"
417  " heff is ignored in this case." "\n"
418  "-R1 V return R1 and R2 for voltage division factor V" "\n"
419  " maintaining a damping of heff." "\n"
420  " V is specified like with option -R2." "\n"
421  "-Rd1 Rd,R1 The values R1 and Rd specify the additional" "\n"
422  " resistance in series with the geophone (R1) and" "\n"
423  " parallel to the recorder (Rd). The program" "\n"
424  " returns the resulting response." "\n"
425  "\n"
426  "All damping values are given as a fraction of critical damping." "\n"
427  "\n"
428  "Usually you specify hoc, Ri, Rc, C, fn, and heff. Then the program" "\n"
429  "will tell you which shunt resistance to use parallel to the recorder" "\n"
430  "input terminals." "\n"
431  "\n"
432  "In case you specify V by option -R2, the program will ignore the" "\n"
433  "desired effective damping heff and will tell you, which shunt" "\n"
434  "resistance to use to obtain the desired voltage division factor V." "\n"
435  "\n"
436  "In case you specify V by option -R1, the program will tell you," "\n"
437  "which shunt and series resistance to use to obtain the desired" "\n"
438  "voltage division factor V and damping heff." "\n"
439  "\n"
440  "In case you specify the series resistance R1 and the shunt resistantce\n"
441  "Rd in parallel to the recorder by option -Rd1, the program returns" "\n"
442  "the resulting response." "\n"
443  "\n"
444  "Circuit diagram:\n"
445  "\n"
446  " +--------+ +-----+ +--------+\n"
447  " | +----|-----| R1 |-----+-----|---+ |\n"
448  " | | | +-----+ | | | |\n"
449  " | +---+ | +---+ | +---+ |\n"
450  " | | | | | | | | | |\n"
451  " | |Rc | | |Rd | | |Ri | |\n"
452  " | | | | | | | | | |\n"
453  " | +---+ | +---+ | +---+ |\n"
454  " | | | | | | |\n"
455  " | +----|-----------------+-----|---+ |\n"
456  " | | | |\n"
457  " |geophone| |recorder|\n"
458  " +--------+ +--------+\n"
459  " ||||\n"
460  " |||| usually R1=0 and Rd=infinity\n"
461  " ||\n"
462  " || use finite Rd for larger \n"
463  " || effective damping\n"
464  " ||\n"
465  " || use R1 to set up a voltage divider\n"
466  " \\/ and small effective damping\n"
467  "\n"
468  "Background:\n"
469  "Usually geophones are directly connected to the recording system.\n"
470  "This is equivalent to R1=0 and Rd=infinity. With Ri >> Rc the\n"
471  "effective damping of the geophone is only slightly larger than\n"
472  "the open circuit damping of the geophone.\n"
473  "\n"
474  "If a damping of the geophone larger than the open circuit damping\n"
475  "is desired, a finite Rd can be connected in parallel to the input\n"
476  "of the recording system. This program provides the appropriate value\n"
477  "if the desired effective damping is passed in the parameter to\n"
478  "option -heff. Alternatively the effective damping heff is\n"
479  "provided as output, if values for R1 and Rd are passed as\n"
480  "parameters to option -Rd1.\n"
481  "\n"
482  "In some cases near offset geophones are saturated in the recording\n"
483  "system by ground motion close to the seismic source. In this case a\n"
484  "small resistance Rd can be used to set up a voltage divider with\n"
485  "the coil resistance Rc thus makeing the voltage to be recorded\n"
486  "smaller accordingly. At the same time this will strongly damp the\n"
487  "geophone itself thus preventing mechanical saturation and clipping.\n"
488  "If this is desired, the parallel resistance required for a given\n"
489  "amplitude factor V is provided by the program, if V is passed as\n"
490  "a parameter to option -R1.\n"
491  "\n"
492  "If strong overdamping of the geophone has to be avoided, for\n"
493  "example to maintain the same effective damping for all geophones\n"
494  "in a profile, a series resistance R1 together with a parallel\n"
495  "resistance Rd can be used to adjust a voltage divider with\n"
496  "factor V and a desired effective damping heff at the same time.\n"
497  "In this case pass V as a parameter to option -R2 and heff as a\n"
498  "parameter to option -heff.\n"
499  "\n"
500  "If R1 and Rd are known from the configuration of the seismic\n"
501  "experiment, you can use both values as parameters to option\n"
502  "-Rd1 in order to obtain the effective response characteristic\n"
503  "of the geophone.\n"
504  "\n"
505  "Geophone response are provided in three ways:\n"
506  "1. Effective geophone parameters are printed to standard output.\n"
507  "2. A filename passed as a parameter to option -resfile will\n"
508  " cause the program to create a filter control file with this\n"
509  " name. This filter control file can be used together with\n"
510  " stufi or tidofi in order to restore the response of a\n"
511  " geophone as used with R1=0 and Rd=infinity in terms of\n"
512  " effective damping as well as singal amplitude.\n"
513  "3. A filename passed as a parameter to option -o will cause\n"
514  " the program to produce an SFF data file containing the\n"
515  " the impulse response of the geophone. The first trace contains\n"
516  " the response of the geophone as if recorded with R1=0 and\n"
517  " Rd=infinity. The second trace contains the impulse response\n"
518  " of a geophone if operated with a finite R1 and Rd as\n"
519  " specified by the command line arguments. The effective\n"
520  " geophone parameters are given in the first line of the\n"
521  " trace FREE block.\n"
522  };
523 
524  // define commandline options
525  using namespace tfxx::cmdline;
526  static Declare options[]=
527  {
528  // 0: print help
529  {"help",arg_no,"-"},
530  // 1: verbose mode
531  {"v",arg_no,"-"},
532  // 2: open circuit damping
533  {"hoc",arg_yes,"0.315"},
534  // 3: desired effective damping
535  {"heff",arg_yes,"0.707"},
536  // 4: recorder input resistance
537  {"Ri",arg_yes,"20000."},
538  // 5: coil resistance
539  {"Rc",arg_yes,"375."},
540  // 6: geophone constant
541  {"C",arg_yes,"6000."},
542  // 7: natural frequency
543  {"fn",arg_yes,"8."},
544  // 8: geophone type
545  {"type",arg_yes,"SM-4"},
546  // 9: geophone type
547  {"o",arg_yes,"response.sff"},
548  // 10: length of time series
549  {"T",arg_yes,"10."},
550  // 11: sampling interval
551  {"dt",arg_yes,"1.e-2"},
552  // 12: series resistance
553  {"R1",arg_yes,"0."},
554  // 13: series resistance
555  {"R2",arg_yes,"1.e12"},
556  // 14: Rd and R1
557  {"Rd1", arg_yes, "-"},
558  // 15: deconvolution filter
559  {"resfile", arg_yes, "res.fil"},
560  // 16: deconvolution filter
561  {"DEBUG", arg_no, "-"},
562  {NULL}
563  };
564 
565  // no arguments? print usage...
566  if (iargc<1)
567  {
568  cerr << usage_text << endl;
569  exit(0);
570  }
571 
572  // collect options from commandline
573  Commandline cmdline(iargc, argv, options);
574 
575  // help requested? print full help text...
576  if (cmdline.optset(0))
577  {
578  cerr << usage_text << endl;
579  cerr << help_text << endl;
580  exit(0);
581  }
582 
583  /*
584  // dummy operation: print option settings
585  for (int iopt=0; iopt<2; iopt++)
586  {
587  cout << "option: '" << options[iopt].opt_string << "'" << endl;
588  if (cmdline.optset(iopt)) { cout << " option was set"; }
589  else { cout << "option was not set"; }
590  cout << endl;
591  cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
592  cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
593  cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
594  cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
595  cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
596  cout << " argument (bool): '";
597  if (cmdline.bool_arg(iopt))
598  { cout << "true"; } else { cout << "false"; }
599  cout << "'" << endl;
600  }
601  while (cmdline.extra()) { cout << cmdline.next() << endl; }
602 
603  // dummy operation: print rest of command line
604  while (cmdline.extra()) { cout << cmdline.next() << endl; }
605  */
606 
607  Tparameters para;
608  para.hoc=cmdline.double_arg(2);
609  para.heff=cmdline.double_arg(3);
610  para.Ri=cmdline.double_arg(4);
611  para.Rc=cmdline.double_arg(5);
612  para.C=cmdline.double_arg(6);
613  para.fn=cmdline.double_arg(7);
614  para.type=cmdline.string_arg(8);
615 
616  Toptions opt;
617  opt.verbose=cmdline.optset(1);
618  opt.saveresponse=cmdline.optset(9);
619  opt.outfile=cmdline.string_arg(9);
620  opt.T=cmdline.double_arg(10);
621  opt.dt=cmdline.double_arg(11);
622  opt.R1mode=cmdline.optset(12);
623  opt.V=cmdline.double_arg(12);
624  opt.R2mode=cmdline.optset(13);
625  if (!opt.R1mode) { opt.V=cmdline.double_arg(13); }
626  opt.Rd1mode=cmdline.optset(14);
627  if (opt.Rd1mode)
628  {
629  std::string args=cmdline.string_arg(14);
630  args.replace(args.find(","),1," ");
631  std::istringstream is(args);
632  is >> opt.Rd >> opt.R1;
633  }
634  opt.writeresfile=cmdline.optset(15);
635  opt.resfile=cmdline.string_arg(15);
636  opt.debug=cmdline.optset(16);
637 
638  /*----------------------------------------------------------------------*/
639 
640 /*
641  double Rd=1./(1./((para.C/((para.heff-para.hoc)*para.fn))-para.Rc)
642  -(1./para.Ri));
643  double hnd=para.hoc+para.C/(para.fn*(para.Ri+para.Rc));
644  double Rs=1./((1./Rd)+(1./para.Ri));
645  double Afac=100.*para.Ri/(para.Ri+para.Rc);
646  double Afacs=100.*Rs/(Rs+para.Rc);
647 */
648 
649  // calculate reference parameters
650  double hnd=func_heff(para.fn, para.hoc, para.C, para.Rc, para.Ri);
651  double Afac=func_V(para.Ri, para.Rc);
652 
653  double Rd, R1=0., heff, Afaceff, Rs;
654  // case Rd1
655  if (opt.Rd1mode)
656  {
657  Rd=opt.Rd;
658  R1=opt.R1;
659  Rs=func_Rs(para.Ri, Rd, R1);
660  heff=func_heff(para.fn, para.hoc, para.C, para.Rc, Rs);
661  Afaceff=func_V(para.Ri, para.Rc, R1, Rd);
662  }
663  // case R1
664  else if (opt.R1mode)
665  {
666  Afaceff=opt.V*Afac;
667  heff=para.heff;
668  Rs=func_Rs(para.fn, para.hoc, para.C, para.Rc, para.heff);
669  Rd=func_R2(para.Ri, para.Rc, Rs, Afaceff);
670  R1=func_R1(para.Ri, para.Rc, Rs, Afaceff);
671  }
672  // case R2
673  else if (opt.R2mode)
674  {
675  R1=0.;
676  Afaceff=opt.V*Afac;
677  Rd=func_RdV(para.Ri, para.Rc, Afaceff);
678  Rs=func_Rs(para.Ri, Rd, 0.);
679  heff=func_heff(para.fn, para.hoc, para.C, para.Rc, Rs);
680  }
681  // default case
682  else
683  {
684  R1=0.;
685  heff=para.heff;
686  Rs=func_Rs(para.fn, para.hoc, para.C, para.Rc, para.heff);
687  Rd=func_Rd(Rs, para.Ri);
688  // effective input resistance
689  Afaceff=func_V(para.Ri, para.Rc, R1, Rd);
690  }
691 
692  /*----------------------------------------------------------------------*/
693  // report
694  writeparameters(cout, "", para, hnd, heff, Rs, R1, Rd, Afac, Afaceff);
695 
696  if (opt.saveresponse) {
697  if (opt.verbose) {
698  cout << endl;
699  cout << "write impulse response to " << opt.outfile << endl;
700  }
701 
702  double dt=opt.dt/para.fn;
703  int n=int(opt.T/opt.dt);
704  Tseries srnd=response(para.fn,hnd,dt,n);
705  srnd *= Afac;
706  Tseries sreff=response(para.fn,heff,dt,n);
707  sreff *= Afaceff;
708 
709  sff::WID2 wid2;
710  wid2.dt=dt;
711 
712  std::ostringstream oss;
713  sff::FREE ndfree, efffree;
714  oss.str("");
715  oss << para.type << " geophone impulse response ("
716  << "fn=" << para.fn << "Hz, " << "h=" << hnd << ")";
717  ndfree.append(oss.str());
718  oss.str("");
719  oss << para.type << " geophone impulse response ("
720  << "fn=" << para.fn << "Hz, " << "h=" << heff << ")";
721  efffree.append(oss.str());
722 
723  TFXX_debug(opt.debug, "geophon (main):",
724  "para.heff = " << heff << "\n"
725  "oss.str(): " << oss.str());
726 
727  std::ofstream ofs(opt.outfile.c_str());
728  sff::SFFostream<Tseries> os(ofs);
729  os << srnd;
730  os << wid2;
731  os << ndfree;
732  os << sreff;
733  os << wid2;
734  os << efffree;
735 
736  } // if (opt.saveresponse)
737 
738  if (opt.writeresfile)
739  {
740  if (opt.verbose) {
741  cout << endl;
742  cout << "write deconvolution filter to " << opt.resfile << endl;
743  }
744 
745  std::ofstream os(opt.resfile.c_str());
746  os << "rem deconvolution filter calculated by" << endl;
747  writeparameters(os, "rem ", para, hnd, heff, Rs, R1, Rd, Afac, Afaceff);
748  os << "fac " << (Afac/Afaceff) << endl;
749  os << "he2 " << 1./para.fn << ","
750  << heff << ","
751  << 1./para.fn << ","
752  << hnd << endl;
753  os << "end " << endl;
754  } // if (opt.writeresfile)
755 }
756 
757 /* ----- END OF geophon.cc ----- */
double T
Definition: geophone.cc:96
bool saveresponse
Definition: geophone.cc:93
#define GEOPHON_VERSION
Definition: geophone.cc:49
bool verbose
Definition: geophone.cc:93
double func_V(const double &Ri, const double &Rc)
Definition: geophone.cc:209
aff::Series< double > Tseries
Definition: geophone.cc:101
double Rc
Definition: geophone.cc:80
bool debug
Definition: geophone.cc:94
std::string resfile
Definition: geophone.cc:95
double fn
Definition: geophone.cc:80
double func_heff(const double &fn, const double &hoc, const double &C, const double &Rc, const double &Rs)
Definition: geophone.cc:150
double Rd
Definition: geophone.cc:96
double C
Definition: geophone.cc:80
double Rd
Definition: geophone.cc:87
double R1
Definition: geophone.cc:87
bool writeresfile
Definition: geophone.cc:93
bool R1mode
Definition: geophone.cc:93
std::string outfile
Definition: geophone.cc:95
double func_R2(const double &Ri, const double &Rc, const double &Rs, const double &V)
Definition: geophone.cc:279
double func_RdV(const double &Ri, const double &Rc, const double &V)
Definition: geophone.cc:241
void writeparameters(std::ostream &os, const std::string &prefix, const Tparameters &para, const double &hnd, const double &heff, const double &Rs, const double &R1, const double &Rd, const double &Afac, const double &Afaceff)
Definition: geophone.cc:292
std::string type
Definition: geophone.cc:89
double func_R1(const double &Ri, const double &Rc, const double &Rs, const double &V)
Definition: geophone.cc:260
double R1
Definition: geophone.cc:96
bool R2mode
Definition: geophone.cc:93
double hoc
Definition: geophone.cc:80
double Ri
Definition: geophone.cc:80
const double pi
Definition: geophone.cc:99
double V
Definition: geophone.cc:96
double func_Rd(const double &Rs, const double &Ri)
Definition: geophone.cc:196
double dt
Definition: geophone.cc:96
double heff
Definition: geophone.cc:80
double func_Rs(const double &fn, const double &hoc, const double &C, const double &Rc, const double &heff)
Definition: geophone.cc:167
aff::Series< double > Tseries
Definition: cross.cc:69
bool Rd1mode
Definition: geophone.cc:93
int main(int iargc, char *argv[])
Definition: geophone.cc:364
Tseries response(const double &fn, const double &h, const double &dt, const int &n)
Definition: geophone.cc:114
double V
Definition: geophone.cc:87