Distances#

To compare two mass distributions – two CO2 plumes, an experiment against a simulation – a pixel-wise difference is misleading: shifting a plume by one pixel should be a small change, not a large one. Transport-based distances measure how far mass has to move.

import darsia

d = darsia.wasserstein_distance(mass_a, mass_b, method="cv2.emd")

# DarSIA's own Beckmann solver also returns the optimal transport fields
d, info = darsia.wasserstein_distance(
    mass_a, mass_b, method="newton",
    options={"num_iter": 100, "return_info": True},
)

wasserstein_distance()

unified entry point; method is "cv2.emd", "newton", "bregman" or "gprox"

EMD

discrete Earth Mover’s Distance (OpenCV)

BeckmannProblem

the dynamic optimal-transport formulation

BeckmannNewtonSolver,

iterative solvers for the Beckmann problem

BeckmannBregmanSolver,

BeckmannGproxPGHDSolver

The distributions must have equal (integrated) mass. Turning a raw signal into a mass needs a Geometry (depth and porosity) – see PorousGeometry and darsia.wasserstein_distance_to_vtk() for exporting the solution.

See also#