49 #define GEOPHON_VERSION \ 50 "GEOPHONE V1.4 calculate geophone response" 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> 99 const double pi=3.1415926535;
117 const double eps=1.e-4;
119 for (
int i=result.first(); i<=result.last(); i++)
121 double t=double(i)*dt;
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))/
129 }
else if (h<(1.-eps))
131 double hfac=std::sqrt(1.-h*h);
132 result(i)=std::sin(omn*t*hfac)*std::exp(-omn*h*t)/(omn*hfac);
135 result(i)=t*std::exp(-omn*t);
150 inline double func_heff(
const double& fn,
const double& hoc,
const double& C,
151 const double& Rc,
const double& Rs)
154 heff=hoc+(C/((Rs+Rc)*fn));
167 inline double func_Rs(
const double& fn,
const double& hoc,
const double& C,
168 const double& Rc,
const double& heff)
171 Rs=(C/((heff-hoc)*fn))-Rc;
182 inline double func_Rs(
const double& Ri,
const double& Rd,
186 Rs=R1+1./((1./Rd)+(1./Ri));
196 inline double func_Rd(
const double& Rs,
const double& Ri)
199 Rd=1./((1./Rs)-(1./Ri));
209 inline double func_V(
const double& Ri,
const double& Rc)
225 inline double func_V(
const double& Ri,
const double& Rc,
226 const double& R1,
const double& Rd)
241 inline double func_RdV(
const double& Ri,
const double& Rc,
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.));
260 inline double func_R1(
const double& Ri,
const double& Rc,
261 const double& Rs,
const double& V)
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!");
279 inline double func_R2(
const double& Ri,
const double& Rc,
280 const double& Rs,
const double& V)
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));
293 const std::string& prefix,
296 const double& heff,
const double& Rs,
297 const double& R1,
const double& Rd,
298 const double& Afac,
const double& Afaceff)
301 os << prefix << endl;
302 os << prefix <<
"geophone parameters:" << endl;
303 os << prefix <<
"--------------------" << endl;
304 os << prefix <<
" geophone type: " << para.
type 306 os << prefix <<
" natural frequency: " << para.
fn <<
" Hz" 308 os << prefix <<
" coil resistance: " << para.
Rc <<
" Ohm" 310 os << prefix <<
" open circuit damping: " << para.
hoc 312 os << prefix <<
" geophone constant C: " << para.
C <<
" Ohm*Hz" 314 os << prefix <<
" C=Rt*Bc*fn=(K**2)/(4*pi*m)" << endl;
316 os << prefix << endl;
317 os << prefix <<
" recorder input resistance: " << para.
Ri <<
" Ohm" 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: " 328 os << prefix <<
" amplitude as a fraction of open circuit amplitude: " 329 << 100.*Afac <<
"%" << endl;
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: " 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;
345 os << prefix << endl;
347 <<
" effective shunt resistance parallel to geophone terminals: " 348 << Rs <<
" Ohm" << endl;
350 <<
" effective geophone resistance (with series resistance): " 351 << para.
Rc+R1 <<
" Ohm" << endl;
353 <<
" eff. recorder resistance (with ext. resistance in parallel): " 354 <<
func_Rs(para.
Ri, Rd, 0.) <<
" Ohm" << endl;
356 os << prefix << endl;
358 <<
"All damping values are given as a fraction of critical damping." 364 int main(
int iargc,
char* argv[])
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" 381 "-DEBUG debug mode" "\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" 391 "recorder parameters:\n" 392 "-Ri Ri recorder input resistance" "\n" 395 "-heff heff desired effective damping" "\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" 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" 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" 426 "All damping values are given as a fraction of critical damping." "\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" 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" 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" 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" 446 " +--------+ +-----+ +--------+\n" 447 " | +----|-----| R1 |-----+-----|---+ |\n" 448 " | | | +-----+ | | | |\n" 449 " | +---+ | +---+ | +---+ |\n" 450 " | | | | | | | | | |\n" 451 " | |Rc | | |Rd | | |Ri | |\n" 452 " | | | | | | | | | |\n" 453 " | +---+ | +---+ | +---+ |\n" 455 " | +----|-----------------+-----|---+ |\n" 457 " |geophone| |recorder|\n" 458 " +--------+ +--------+\n" 460 " |||| usually R1=0 and Rd=infinity\n" 462 " || use finite Rd for larger \n" 463 " || effective damping\n" 465 " || use R1 to set up a voltage divider\n" 466 " \\/ and small effective damping\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" 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" 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" 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" 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" 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" 525 using namespace tfxx::cmdline;
526 static Declare options[]=
533 {
"hoc",arg_yes,
"0.315"},
535 {
"heff",arg_yes,
"0.707"},
537 {
"Ri",arg_yes,
"20000."},
539 {
"Rc",arg_yes,
"375."},
541 {
"C",arg_yes,
"6000."},
545 {
"type",arg_yes,
"SM-4"},
547 {
"o",arg_yes,
"response.sff"},
551 {
"dt",arg_yes,
"1.e-2"},
555 {
"R2",arg_yes,
"1.e12"},
557 {
"Rd1", arg_yes,
"-"},
559 {
"resfile", arg_yes,
"res.fil"},
561 {
"DEBUG", arg_no,
"-"},
568 cerr << usage_text << endl;
573 Commandline cmdline(iargc, argv, options);
576 if (cmdline.optset(0))
578 cerr << usage_text << endl;
579 cerr << help_text << endl;
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);
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);
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;
635 opt.
resfile=cmdline.string_arg(15);
636 opt.
debug=cmdline.optset(16);
653 double Rd, R1=0., heff, Afaceff, Rs;
699 cout <<
"write impulse response to " << opt.
outfile << endl;
702 double dt=opt.
dt/para.
fn;
703 int n=int(opt.
T/opt.
dt);
712 std::ostringstream oss;
713 sff::FREE ndfree, efffree;
715 oss << para.
type <<
" geophone impulse response (" 716 <<
"fn=" << para.
fn <<
"Hz, " <<
"h=" << hnd <<
")";
717 ndfree.append(oss.str());
719 oss << para.
type <<
" geophone impulse response (" 720 <<
"fn=" << para.
fn <<
"Hz, " <<
"h=" << heff <<
")";
721 efffree.append(oss.str());
723 TFXX_debug(opt.
debug,
"geophon (main):",
724 "para.heff = " << heff <<
"\n" 725 "oss.str(): " << oss.str());
727 std::ofstream ofs(opt.
outfile.c_str());
728 sff::SFFostream<Tseries> os(ofs);
742 cout <<
"write deconvolution filter to " << opt.
resfile << endl;
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 <<
"," 753 os <<
"end " << endl;
double func_V(const double &Ri, const double &Rc)
aff::Series< double > Tseries
double func_heff(const double &fn, const double &hoc, const double &C, const double &Rc, const double &Rs)
double func_R2(const double &Ri, const double &Rc, const double &Rs, const double &V)
double func_RdV(const double &Ri, const double &Rc, const double &V)
void writeparameters(std::ostream &os, const std::string &prefix, const Tparameters ¶, const double &hnd, const double &heff, const double &Rs, const double &R1, const double &Rd, const double &Afac, const double &Afaceff)
double func_R1(const double &Ri, const double &Rc, const double &Rs, const double &V)
double func_Rd(const double &Rs, const double &Ri)
double func_Rs(const double &fn, const double &hoc, const double &C, const double &Rc, const double &heff)
aff::Series< double > Tseries
int main(int iargc, char *argv[])
Tseries response(const double &fn, const double &h, const double &dt, const int &n)