From ff46e12e734b3872cf10f0321fcbfd8004a057e9 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Mon, 8 Oct 2012 23:10:50 +0200 Subject: [PATCH] Correction and validation of covariance in 3DVAR --- src/daComposant/daAlgorithms/3DVAR.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/daComposant/daAlgorithms/3DVAR.py b/src/daComposant/daAlgorithms/3DVAR.py index 6cd3fee..28a8af9 100644 --- a/src/daComposant/daAlgorithms/3DVAR.py +++ b/src/daComposant/daAlgorithms/3DVAR.py @@ -255,16 +255,21 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # Calcul de la covariance d'analyse # --------------------------------- if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]: + Ht = H["Tangent"].asMatrix(ValueForMethodForm = Xa) + Ht = Ht.reshape(-1,len(Xa.A1)) # ADAO HessienneI = [] nb = len(Xini) for i in range(nb): _ee = numpy.matrix(numpy.zeros(nb)).T _ee[i] = 1. - _HmEE = Hm(_ee) - _HmEE = numpy.asmatrix(numpy.ravel( _HmEE )).T - HessienneI.append( ( BI*_ee + Ha((Xa,RI*_HmEE)) ).A1 ) + _HtEE = Ht * _ee + _HtEE = numpy.asmatrix(numpy.ravel( _HtEE )).T + HessienneI.append( ( BI*_ee + Ha((Xa,RI*_HtEE)) ).A1 ) HessienneI = numpy.matrix( HessienneI ) - A = HessienneI.I + if numpy.alltrue(numpy.isfinite( HessienneI )): + A = HessienneI.I + else: + raise ValueError("The 3DVAR a posteriori covariance matrix A can not be calculated. Your problem is perhaps too non-linear?") if logging.getLogger().level < logging.WARNING: # La verification n'a lieu qu'en debug try: L = numpy.linalg.cholesky( A ) -- 2.39.2