Example #1
0
int ObsReadDepth::cal_simualpha() {
	char id[]="Alpha";
	simualpha.init(id, nGene);

	for(int i=0; i<1000; i++) {
		double a=cal_alpha(simugene[i], medianSample);
		simualpha.set_data(i, a);
	}
	return 1;
}
Example #2
0
float calVelUpdateStepLen(const FwiParams &params,
    const float *wlt,
    const float *dobs,
    const float *derr,
    float epsil,
    const EnquistAbc2d &fmMethod,
    const ShotPosition &allSrcPos,
    const ShotPosition &allGeoPos
    )
{
  int nt = params.nt;
  int nz = params.nz;
  int nx = params.nx;
  int ng = params.ng;
  int ns = params.ns;

  std::vector<float> dcal(ng, 0); /* calculated/synthetic seismic data */
  std::vector<float> sp0(nz * nx); /* source wavefield p0 */
  std::vector<float> sp1(nz * nx); /* source wavefield p1 */
  std::vector<float> sp2(nz * nx); /* source wavefield p2 */

  std::vector<float> alpha1(ng, 0); /* numerator of alpha, length=ng */
  std::vector<float> alpha2(ng, 0); /* denominator of alpha, length=ng */

  for (int is = 0; is < ns; is++) {
    std::fill(sp0.begin(), sp0.end(), 0);
    std::fill(sp1.begin(), sp1.end(), 0);
    ShotPosition currSrcPos = allSrcPos.clip(is);

    for (int it = 0; it < nt; it++) {
      fmMethod.addSource(&sp1[0], &wlt[it], currSrcPos);
      fmMethod.stepForward(&sp0[0], &sp1[0], &sp2[0]);

      cycleSwap(sp0, sp1, sp2);

      fmMethod.recordSeis(&dcal[0], &sp0[0], allGeoPos);

      sum_alpha12(&alpha1[0], &alpha2[0], &dcal[0], &dobs[is * nt * ng + it * ng], &derr[is * ng * nt + it * ng], ng);
    }
  }

  float alpha = cal_alpha(&alpha1[0], &alpha2[0], epsil, ng);

  return alpha;
}