Exemplo n.º 1
0
def perform_inversion(data, init, sigma, vel):
    op = LymanAlphaHydrogen(domain,
                            parameters_inversion,
                            redshift,
                            redshift,
                            hubble,
                            hubble,
                            vel_pec=vel,
                            codomain=codomain)

    setting = HilbertSpaceSetting(op=op, Hdomain=L2, Hcodomain=L2)

    richardson = RLHydrogen(op)

    richardson_lucy = Richardson_Lucy(setting, data, init, richardson, m=3)

    energy = EnergyNorm(sigma)

    stoprule = (rules.CombineRules(
        (rules.CountIterations(300),
         rules.Discrepancy(energy.norm,
                           data,
                           noiselevel=np.sqrt(N_spect),
                           tau=1),
         rules.RelativeChangeData(energy.norm, data, 0.0001))))

    return richardson_lucy.run(stoprule)
Exemplo n.º 2
0
def perform_inversion(data, init, sigma, vel):
    C_D = sigma

    op = LymanAlphaBar(domain,
                       parameters_inversion,
                       redshift,
                       redshift,
                       hubble,
                       hubble,
                       vel,
                       gamma=True,
                       codomain=codomain)

    setting = HilbertSpaceSetting(op=op, Hdomain=L2, Hcodomain=L2)

    solver = IRGN(setting,
                  data,
                  init,
                  C_0,
                  M_0,
                  C_D**2,
                  maxit=15,
                  tol=1e-3,
                  restart=10)

    energy = EnergyNorm(sigma)

    stoprule = (rules.CombineRules(
        (rules.CountIterations(10),
         rules.Discrepancy(energy.norm,
                           data,
                           noiselevel=np.sqrt(N_spect),
                           tau=1),
         rules.RelativeChangeData(energy.norm, data, 0.1))))

    return solver.run(stoprule)
Exemplo n.º 3
0
noise = gfu_noise.vec.FV().NumPy()

data = exact_data + noise

init = 1 + ngs.x**2
init_gfu = ngs.GridFunction(op.fes_domain)
init_gfu.Set(init)
init_solution = init_gfu.vec.FV().NumPy().copy()
init_data = op(init_solution)

setting = HilbertSpaceSetting(op=op, Hdomain=L2, Hcodomain=Sobolev)

landweber = Landweber(setting, data, init_solution, stepsize=1)
stoprule = (rules.CountIterations(1000) +
            rules.Discrepancy(setting.Hcodomain.norm,
                              data,
                              noiselevel=setting.Hcodomain.norm(noise),
                              tau=1.1))

reco, reco_data = landweber.run(stoprule)

ngs.Draw(exact_solution_coeff, op.fes_domain.mesh, "exact")
ngs.Draw(init, op.fes_domain.mesh, "init")

# Draw recondtructed solution
gfu_reco = ngs.GridFunction(op.fes_domain)
gfu_reco.vec.FV().NumPy()[:] = reco
coeff_reco = ngs.CoefficientFunction(gfu_reco)

ngs.Draw(coeff_reco, op.fes_domain.mesh, "reco")

# Draw data space
Exemplo n.º 4
0
Arquivo: mri.py Projeto: regpy/regpy
init = smoothed_op.domain.zeros()
init_density, _ = smoothed_op.domain.split(init)
init_density[...] = 1

setting = HilbertSpaceSetting(op=smoothed_op, Hdomain=L2, Hcodomain=L2)

solver = IrgnmCG(setting=setting,
                 data=data,
                 regpar=10,
                 regpar_step=0.8,
                 init=init)

stoprule = (
    rules.CountIterations(max_iterations=100) +
    rules.Discrepancy(setting.Hcodomain.norm,
                      data,
                      noiselevel=setting.Hcodomain.norm(exact_data - data),
                      tau=1.1))

# Plotting setup
plt.ion()
fig, axes = plt.subplots(ncols=2, constrained_layout=True)
bars = [cbar.make_axes(ax)[0] for ax in axes]

axes[0].set_title('exact solution')
axes[1].set_title('reconstruction')

# Plot exact solution
im = axes[0].imshow(normalize(*mri_op.domain.split(exact_solution)))
fig.colorbar(im, cax=bars[0])

# Run the solver, plot iterates