import { computeDasMap, createDasAnalysisPlan, estimateDasWorkload, } from "./das.js"; import { computeGccPhatMap, createGccPhatAnalysisPlan, estimateGccPhatWorkload, } from "./gcc-phat.js"; import { isDasAlgorithm, requireLocalizationAlgorithmDefinition, } from "./localization-algorithms.js"; function requestedAlgorithm(options) { return requireLocalizationAlgorithmDefinition( options?.experiment?.beamforming?.algorithm, ); } /** * Estimate implementation-level work for whichever localization algorithm the * experiment requests. */ export function estimateLocalizationWorkload(options) { const algorithm = requestedAlgorithm(options); return isDasAlgorithm(algorithm.id) ? estimateDasWorkload(options) : estimateGccPhatWorkload(options); } /** * Compile immutable geometry/workspace state for repeated CPU analyses. */ export function createLocalizationAnalysisPlan(options) { const algorithm = requestedAlgorithm(options); return isDasAlgorithm(algorithm.id) ? createDasAnalysisPlan(options) : createGccPhatAnalysisPlan(options); } /** * Compute a CPU localization map using the algorithm selected by the * experiment. The returned `algorithm` and each band's `rawScale` make the * result semantics explicit. */ export async function computeLocalizationMap(options) { const algorithm = requestedAlgorithm(options); return isDasAlgorithm(algorithm.id) ? computeDasMap(options) : computeGccPhatMap(options); }