Source code for genericROM.BasicAlgorithms.GappyPOD

# -*- coding: utf-8 -*-
#
# This file is subject to the terms and conditions defined in
# file 'LICENSE', which is part of this source code package.
#
#

import os
import numpy as np

from scipy.optimize import lsq_linear as lsq_linear


[docs] def Fit(modesAtMask, fieldAtMask): """ Fits GappyPOD approximation Parameters ---------- modesAtMask: np.ndarray of size (nbeModes, maskSize) fieldAtMask: np.ndarray np.ndarray of size (maskSize,) Returns ------- np.ndarray of size (nbeModes,) """ lstqr = lsq_linear(modesAtMask.T, fieldAtMask) return lstqr['x']
[docs] def FitAndCost(modesAtMask, fieldAtMask): """ Fits GappyPOD approximation an return prediction and cost Parameters ---------- modesAtMask: np.ndarray of size (nbeModes, maskSize) fieldAtMask: np.ndarray np.ndarray of size (maskSize,) Returns ------- np.ndarray of size (nbeModes,) float evaluation of the cost function at convergence """ lstqr = lsq_linear(modesAtMask.T, fieldAtMask) normFieldAtMask = np.linalg.norm(fieldAtMask) if normFieldAtMask > 1.e-10: cost = lstqr['cost']/np.linalg.norm(fieldAtMask) else:# pragma: no cover cost = lstqr['cost'] return lstqr['x'], cost
if __name__ == "__main__":# pragma: no cover from genericROM import RunTestFile RunTestFile(__file__)