# set up plots:
    filename, ext = splitext(sys.argv[0])
    if isdir(filename + '/'): rmtree(filename + '/')
    myplot = PlotFenics(filename + str(Nxy))
    myplot.set_varname('a_target')
    myplot.plot_vtk(a_target_fn)

    # define objective function:
    regul = LaplacianPrior({
        'Vm': Vm,
        'gamma': 5e-4,
        'beta': 5e-4,
        'm0': a_target_fn
    })
    waveobj = ObjectiveAcoustic(wavepde, mysrc, 'a', regul)
    waveobj.obsop = obsop

    # noisy data
    print 'generate noisy data'
    waveobj.solvefwd()
    skip = 20
    myplot.plot_timeseries(waveobj.solfwd[0], 'pd', 0, skip, dl.Function(V))
    DD = waveobj.Bp[:]
    noiselevel = 0.1  # = 10%
    for ii, dd in enumerate(DD):
        np.random.seed(11)
        nbobspt, dimsol = dd.shape
        sigmas = np.sqrt((dd**2).sum(axis=1) / dimsol) * noiselevel
        rndnoise = np.random.randn(nbobspt * dimsol).reshape((nbobspt, dimsol))
        DD[ii] = dd + sigmas.reshape((len(sigmas), 1)) * rndnoise
예제 #2
0
mpilocalrank = MPI.rank(mpicomm_local)
mpiglobalrank = MPI.rank(mpicomm_global)
mpiworldsize = MPI.size(dl.mpi_comm_world())
print 'mpiworldrank={}, mpiglobalrank={}, mpilocalrank={}, sources={}, timestep=[{},{}]'.format(\
mpiworldrank, mpiglobalrank, mpilocalrank, sources,\
timesteps[0], timesteps[-1])

# observation operator:
obspts = [[ii * float(X) / float(Nxy), Y] for ii in range(1, Nxy)]

tfilterpts = [t0, t1, t2, tf]
obsop = TimeObsPtwise({'V': V, 'Points': obspts}, tfilterpts)

# define objective function:
if FDGRAD:
    waveobj = ObjectiveAcoustic(mpicomm_global, Wave, [Ricker, Pt, srcv],\
    sources, timesteps, PARAM)
else:
    # REGULARIZATION:
    amg = 'hypre_amg'
    #regul = V_TV(Vl, {'k':k, 'eps':eps, 'amg':amg,\
    #'print':PRINT, 'GNhessian':False})
    regul = V_TVPD(Vl, {'k':k, 'eps':eps, 'amg':amg,\
    'rescaledradiusdual':1.0, 'print':PRINT, 'PCGN':False})
    waveobj = ObjectiveAcoustic(mpicomm_global, Wave, [Ricker, Pt, srcv],\
    sources, timesteps, PARAM, regul)
waveobj.obsop = obsop
#waveobj.GN = True

# Generate synthetic observations
if PRINT: print 'generate noisy data'
waveobj.solvefwd()
예제 #3
0
Wave.update({'b':bt, 'a':at, 't0':0.0, 'tf':tf, 'Dt':Dt,\
'u0init':dl.Function(V), 'utinit':dl.Function(V)})
# observation operator:
obspts = [[0.0, ii/10.] for ii in range(1,10)] + \
[[1.0, ii/10.] for ii in range(1,10)] + \
[[ii/10., 0.0] for ii in range(1,10)] + \
[[ii/10., 1.0] for ii in range(1,10)]
tfilterpts = [t0, t1, t2, tf]
obsop = TimeObsPtwise({'V':V, 'Points':obspts}, tfilterpts)

# Regularization
regula = LaplacianPrior({'Vm':Vl, 'gamma':1e-4, 'beta':1e-4, 'm0':at})
regulab = SingleRegularization(regula, 'a', (not mpirank))

# define objective function:
waveobjab = ObjectiveAcoustic(Wave, [Ricker, Pt, srcv], 'a', regulab)
waveobjabnoregul = ObjectiveAcoustic(Wave, [Ricker, Pt, srcv], 'a')
waveobjab.obsop = obsop
waveobjabnoregul.obsop = obsop
# Generate synthetic observations
if mpirank == 0:    print 'generate noisy data'
waveobjab.solvefwd()
DD = waveobjab.Bp[:]
if NOISE:
    SNRdB = 20.0   # [dB], i.e, log10(mu/sigma) = SNRdB/10
    np.random.seed(11)
    for ii, dd in enumerate(DD):
        if mpirank == 0:    print 'source {}'.format(ii)
        nbobspt, dimsol = dd.shape

        #mu = np.abs(dd).mean(axis=1)