pofff.jobs.metric module#

Calculate segmented FluidFlower Wasserstein-distance metrics.

The job converts simulated saturation and dissolved-CO2 fields into benchmark segmentation classes, compares them with experimental segmentations using Earth Mover’s Distance, and writes per-observation metrics and the Everest objective.

pofff.jobs.metric._calculate_wasserstein_distance(file_1: str, file_2: str) float[source]#

Calculate the Earth Mover’s Distance between two segmented images.

Both images are converted to grayscale, resized to 140 by 60 pixels, normalized, and compared on the physical FluidFlower domain.

Parameters:
file_1str

Path to the first segmented PNG image.

file_2str

Path to the second segmented PNG image, resized in place.

Returns:
float

Wasserstein distance in physical x-z coordinates.

pofff.jobs.metric._prepare_distance_images(model_result: NDArray[int64], experimental_data: NDArray[int64], indx: int) float[source]#

Write segmentation images and calculate their Wasserstein distance.

The PNG round trip is retained to preserve the established metric calculation.

Parameters:
model_resultNDArray[np.int64]

Simulated benchmark classes on the 120 by 280 grid.

experimental_dataNDArray[np.int64]

Experimental benchmark classes on the same grid.

indxint | str

Evaluation-time identifier used in temporary filenames.

Returns:
float

Wasserstein distance between the generated images.

pofff.jobs.metric._segment_spatial_map(file_name: str, xlim: tuple[float, float], zlim: tuple[float, float], satmin: float, conmin: float) NDArray[int64][source]#

Convert saturation and concentration fields to benchmark classes.

Parameters:
file_namestr

Spatial-map CSV containing x, z, saturation, and concentration columns.

xlimtuple[float, float]

Minimum and maximum x coordinates, in metres.

zlimtuple[float, float]

Minimum and maximum z coordinates, in metres.

satminfloat

Minimum gas saturation for class 2.

conminfloat

Minimum dissolved-CO2 concentration for class 1.

Returns:
NDArray[np.int64]

Segmentation on the 120 by 280 benchmark reporting grid.

pofff.jobs.metric.main(argv=None) None[source]#

Calculate segmented metrics and the Everest objective.

Parameters:
argvlist[str] | None, optional

Arguments to parse instead of the process command line.