]> SALOME platform Git repositories - tools/adao_interface.git/commitdiff
Salome HOME
Go pour le cas crue
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 12 Jul 2019 08:15:47 +0000 (10:15 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 12 Jul 2019 08:15:47 +0000 (10:15 +0200)
Cases/crue-ADAO-3DVAR-1parametre.py [new file with mode: 0644]
README.txt [new file with mode: 0644]

diff --git a/Cases/crue-ADAO-3DVAR-1parametre.py b/Cases/crue-ADAO-3DVAR-1parametre.py
new file mode 100644 (file)
index 0000000..373c175
--- /dev/null
@@ -0,0 +1,75 @@
+# -*- 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
diff --git a/README.txt b/README.txt
new file mode 100644 (file)
index 0000000..3a07fde
--- /dev/null
@@ -0,0 +1,5 @@
+_internal->_py_call_back : Py function intercepting multifunc call
+
+_internal->_decorator_func : Decoration func around _internal->_py_call_back to deal with returned values of _internal->_py_call_back
+
+