--- /dev/null
+# -*- coding: utf-8 -*-\r
+# Copyright (C) 2019 - Jean-Philippe Argaud\r
+\r
+import numpy as np\r
+import unittest\r
+np.set_printoptions(precision=3)\r
+from adao import adaoBuilder\r
+\r
+# Les entrées\r
+nbobs = 4\r
+Qobs = np.array([10.,20.,30.,40.])\r
+Hobs = np.array([0.19694513, 0.298513, 0.38073079, 0.45246109])\r
+\r
+# Définit les paramètres de l'AD\r
+KsInitial = 20.\r
+ZvInitial = 49.\r
+ZmInitial = 51.\r
+thetaB = [KsInitial,]\r
+\r
+def functionCrue(Q, K_s):\r
+ L = 5.0e3\r
+ B = 300.0\r
+ Z_v = ZvInitial\r
+ Z_m = ZmInitial\r
+ alpha = (Z_m - Z_v)/L\r
+ H = (Q/(K_s*B*np.sqrt(alpha)))**(3.0/5.0)\r
+ return H\r
+\r
+def obsFunction(theta):\r
+ # Evaluation de la sortie du modèle\r
+ K_s = float(theta)\r
+ sortie = np.zeros((nbobs,))\r
+ for i in range(nbobs):\r
+ sortie[i] = functionCrue(Qobs[i],K_s)\r
+ return sortie\r
+\r
+def obsFunctionMulti(thetas):\r
+ ret = []\r
+ for elt in thetas:\r
+ ret.append( np.array(obsFunction(elt)) )\r
+ return ret\r
+\r
+class TestRefFloodTest(unittest.TestCase):\r
+\r
+ def test0(self):\r
+ # define the problem bounds\r
+ boundsMin = [20.,]\r
+ boundsMax = [40.,]\r
+\r
+ # Ecart-type des paramètres\r
+ sigmaKs = 5.e10\r
+ sigmaZv = 1.\r
+ sigmaZm = 1.\r
+ sigmaTheta = [sigmaKs,]\r
+\r
+ # Ecart-type des observations\r
+ sigmaH = 0.5 # (m^2)\r
+\r
+ case = adaoBuilder.New()\r
+ case.set( 'AlgorithmParameters', Algorithm='3DVAR' )\r
+ case.set( 'Background', Vector=thetaB)\r
+ case.set( 'BackgroundError', DiagonalSparseMatrix=sigmaTheta )\r
+ case.set( 'Observation', Vector=Hobs)\r
+ case.set( 'ObservationError', ScalarSparseMatrix=sigmaH )\r
+ case.set( 'ObservationOperator', OneFunction= obsFunctionMulti, InputFunctionAsMulti = True)\r
+ case.execute()\r
+ res = case.get("Analysis")[-1][0]\r
+ self.assertAlmostEqual(res,25.,6)\r
+ pass\r
+ pass\r
+\r
+if __name__ == "__main__":\r
+ unittest.main()\r
+ pass\r
+\r