Utilities#

Lower-level building blocks used across DarSIA. Most users will not need these directly, but they are public and stable.

Grids and finite volumes#

Grid(shape[, voxel_size])

Tensor grid.

generate_grid(image)

Build a Grid matching an image's voxel count and voxel size.

FVDivergence(grid)

Finite volume divergence operator.

FVMass(grid[, mode, lumping])

Finite volume mass matrix.

FVFullFaceReconstruction(grid)

Reconstruct full face fluxes from their normal and tangential components.

FVTangentialFaceReconstruction(grid)

Projection of normal fluxes on grid onto tangential components.

cell_to_face_average(grid, cell_qty, mode)

Project scalar cell quantity to scalar face quantity via averaging.

face_to_cell(grid, flat_flux[, pt])

Reconstruct the vector fluxes on the cells from normal fluxes on the faces.

Points, voxels and coordinates#

Coordinate([input_array])

Cartesian coordinate.

CoordinateArray([input_array])

Container for collection of Coordinate.

Voxel(input_array[, matrix_indexing])

Voxel coordinate.

VoxelArray(input_array[, matrix_indexing])

Container for collection of Voxel.

VoxelCenter(input_array[, matrix_indexing])

Voxel center coordinate.

VoxelCenterArray(input_array[, matrix_indexing])

Container for collection of VoxelCenter.

make_coordinate(pts)

Quick-access constructor for Coordinate or CoordinateArray.

make_voxel(pts[, matrix_indexing])

Quick-access constructor for Voxel or VoxelArray.

make_voxel_center(pts[, matrix_indexing])

Quick-access constructor for VoxelCenter or VoxelCenterArray.

to_coordinate(self[, coordinatesystem])

Conversion of point to Coordinate.

to_voxel(self[, coordinatesystem])

Conversion of point to Voxel.

to_voxel_center(self[, coordinatesystem])

Conversion of point to VoxelCenter.

Derivatives#

forward_diff(img, axis[, dim, h])

Forward difference of image matrix in direction of axis.

backward_diff(img, axis[, dim, h])

Backward difference of image matrix in direction of axis.

laplace(img[, axis, dim, h, diffusion_coeff])

Laplace operator with homogeneous boundary conditions.

Interpolation#

polynomial_interpolation(measurements, ...)

Determine a voxeled spatial map from measurements through polynomial interpolation.

interpolate_to_image(data, image[, method])

Interpolate data to image.

interpolate_to_image_from_csv(csv_file, key, ...)

Interpolate data from CSV to image.

interpolate_measurements_2d(measurements, ...)

Build a voxelised spatial map from scattered measurements by RBF interpolation.

illumination_interpolation(measurements, ...)

Determine a voxeled spatial map from measurements through polynomial interpolation.

Kernels#

BaseKernel()

Abstract base class for kernel.

GaussianKernel([gamma])

Gaussian kernel.

LinearKernel([a])

Linear kernel.

Linear solvers#

Solver([maxiter, tol, dim, mass_coeff, ...])

Abstract base class for solvers for the problem: mass_coeff * x - diffusion_coeff * laplace(x) = rhs

CG([maxiter, tol, dim, mass_coeff, ...])

Conjugate gradient solver based on scipy's cg for the problem: mass_coeff * x - diffusion_coeff * laplace(x) = rhs

Jacobi([maxiter, tol, dim, mass_coeff, ...])

Jacobi solver for the problem: mass_coeff * x - diffusion_coeff * laplace(x) = rhs

MG([depth, smoother_iterations, maxiter, ...])

Muiltilvel solver for the problem: mass_coeff * x - diffusion_coeff * laplace(x) = rhs.

Approximation and acceleration#

AndersonAcceleration([dimension, depth, restart])

Anderson acceleration for fixed-point methods.

ApproximationSpace()

Abstract class for approximation spaces.

LinearApproximation(space, dim[, domain])

Linear combination of any approximation space.

PolynomialApproximationSpace(degree)

Global polynomial approximation space in 2d.

RadialPolynomialApproximationSpace(degree[, ...])

Global radial polynomial approximation space in 2d.

Detection#

detect_color(img, color[, tolerance])

Detects a color in an image.

detect_value(img, value[, tolerance])

Detects a value in an image.

detect_closest_point(points, target)

Detects the point closest to a target.

orthogonal_colors(color)

Returns the orthogonal colors to the input color.

monochromatic_concentration_analysis(img, color)

Performs monochromatic concentration analysis on an image.

Data types and miscellany#

convert_dtype(img, dtype)

Convert image to the specified dtype.

Format(*values)

Enumeration of formats for data.

FeatureDetection()

Class containing two class methods, once detecting features, and matching features.

ConvergenceStatus(*values)

Enum to represent the convergence status of an iterative solver.

extract_characteristic_data(signal[, mask, ...])

Extract representative colours from an image for given patches.

hsv_spectrum(img, roi[, bins])

Plot histograms for all HSV components present in a ROI of an image.

bounding_box(voxels[, padding, max_size])

Determine bounding box for a set of given coordinates.

bounding_box_inverse(bounding_box)

Inverse of bounding_box().

perimeter(box)

Returns the perimeter of a box.

random_patches(mask, width, num_patches)

Utility to extract random patches from a mask.

sort_quad(pts)

Sorts the four points of a quadrilateral in a clockwise fashion.

full_like(image, fill_value[, mode, dtype])

Analog of np.full_like but for darsia.Image objects.

ones_like(image[, mode, dtype])

Analog of np.ones_like but for darsia.Image objects.

zeros_like(image[, mode, dtype])

Analog of np.zeros_like but for darsia.Image objects.