]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Updating some examples
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Thu, 3 Oct 2013 08:40:59 +0000 (10:40 +0200)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Thu, 3 Oct 2013 08:40:59 +0000 (10:40 +0200)
12 files changed:
examples/daSalome/Makefile.am
examples/daSalome/test001_ADAO_JDC_using_strings.comm
examples/daSalome/test002_ADAO_JDC_using_strings.comm
examples/daSalome/test008_ADAO_Elementary_GradientTest.comm [new file with mode: 0644]
examples/daSalome/test009_ADAO_Simple_GradientTest.comm
examples/daSalome/test010_ADAO_Simple_AdjointTest.comm
examples/daSkeletons/External_data_definition_by_scripts/ADAO_Case.comm.in
examples/daSkeletons/External_data_definition_by_scripts/Physical_simulation_functions.py
examples/daSkeletons/External_data_definition_by_scripts/Script_AlgorithmParameters.py
examples/daSkeletons/External_data_definition_by_scripts/Script_ObservationError_R.py
examples/daSkeletons/External_data_definition_by_scripts/Script_Observation_yo.py
examples/daSkeletons/External_data_definition_by_scripts/Script_UserPostAnalysis.py

index 0dc24034ed2e46e7c799512917a96083a578b305..ef667f03acc9bf22bfa11c437c11489821f8f4f9 100644 (file)
@@ -37,6 +37,7 @@ DATA_INST = \
        test006_Observers_init.py \
        test006_Observers_Observation_Operator.py \
        test006_Observers_var.py \
+        test008_ADAO_Elementary_GradientTest.comm \
        test009_ADAO_Simple_GradientTest.comm \
        test010_ADAO_Simple_AdjointTest.comm
 
@@ -59,5 +60,6 @@ EXTRA_DIST = \
        test006_Observers_init.py \
        test006_Observers_Observation_Operator.py \
        test006_Observers_var.py \
+        test008_ADAO_Elementary_GradientTest.comm \
        test009_ADAO_Simple_GradientTest.comm \
        test010_ADAO_Simple_AdjointTest.comm
index 8caf22b5aefe491fdc279b48d461d05287ebcfb3..4196350325308c016df2c81d4876d8d0ef301b67 100644 (file)
@@ -21,4 +21,11 @@ ASSIMILATION_STUDY(Study_name='Test',
                    ObservationOperator=_F(Stored=0,
                                           INPUT_TYPE='Matrix',
                                           data=_F(FROM='String',
-                                                  STRING='1 0 0 ; 0 1 0 ; 0 0 1',),),);
+                                                  STRING='1 0 0 ; 0 1 0 ; 0 0 1',),),
+                   UserPostAnalysis=_F(FROM='Template',
+                                       Template='AnalysisPrinter',
+                                       ValueTemplate=
+                                                  """import numpy
+xa=numpy.ravel(ADD.get('Analysis')[-1])
+print 'Analysis:',xa""",),);
+#CHECKSUM:05af4155253fa5540d31e30d50b2b2b3  -:FIN CHECKSUM
\ No newline at end of file
index afbde560b2271f651a7dbe7a4ed0a79a4b38291a..efb2bbdd54c336487cb1ceceb54504f2f0641775 100644 (file)
@@ -21,4 +21,11 @@ ASSIMILATION_STUDY(Study_name='Test',
                    ObservationOperator=_F(Stored=0,
                                           INPUT_TYPE='Matrix',
                                           data=_F(FROM='String',
-                                                  STRING='1 0 0 ; 0 1 0 ; 0 0 1',),),);
+                                                  STRING='1 0 0 ; 0 1 0 ; 0 0 1',),),
+                   UserPostAnalysis=_F(FROM='Template',
+                                       Template='AnalysisPrinter',
+                                       ValueTemplate=
+                                                  """import numpy
+xa=numpy.ravel(ADD.get('Analysis')[-1])
+print 'Analysis:',xa""",),);
+#CHECKSUM:17bc9d8f671d897f163b094a1e21d53f  -:FIN CHECKSUM
\ No newline at end of file
diff --git a/examples/daSalome/test008_ADAO_Elementary_GradientTest.comm b/examples/daSalome/test008_ADAO_Elementary_GradientTest.comm
new file mode 100644 (file)
index 0000000..b70cc22
--- /dev/null
@@ -0,0 +1,17 @@
+
+CHECKING_STUDY(Study_name='Elementary gradient test',
+               Study_repertory='/home/ahbhhjp/ADAO',
+               Debug=0,
+               Algorithm='GradientTest',
+               CheckingPoint=_F(Stored=0,
+                                INPUT_TYPE='Vector',
+                                data=_F(FROM='String',
+                                        STRING='1 1 1',),),
+               ObservationOperator=_F(Stored=0,
+                                      INPUT_TYPE='Matrix',
+                                      data=_F(FROM='String',
+                                              STRING='1 0 0 ; 0 1 0 ; 0 0 1',),),
+               AlgorithmParameters=_F(INPUT_TYPE='Dict',
+                                      data=_F(FROM='String',
+                                              STRING='{ "SetSeed" : 1000 }',),),);
+#CHECKSUM:195fb2032d0dcb0cb5668d4084352fb0  -:FIN CHECKSUM
\ No newline at end of file
index dddb3e6bab61eef4ee9ff1c1746f904c0806ab5b..3cc522ebbfed72e6a45106513e6563b4f2977766 100644 (file)
@@ -9,5 +9,8 @@ CHECKING_STUDY(Study_name='Test',
                ObservationOperator=_F(Stored=0,
                                       INPUT_TYPE='Matrix',
                                       data=_F(FROM='String',
-                                              STRING='1 0 0 ; 0 1 0 ; 0 0 1 ; 1 0 0 ; 0 1 0 ; 0 0 1',),),);
-#CHECKSUM:68032af53e12f34f4d709332ef02b294  -:FIN CHECKSUM
\ No newline at end of file
+                                              STRING='1 0 0 ; 0 1 0 ; 0 0 1 ; 1 0 0 ; 0 1 0 ; 0 0 1',),),
+               AlgorithmParameters=_F(INPUT_TYPE='Dict',
+                                      data=_F(FROM='String',
+                                              STRING='{ "SetSeed" : 1000 }',),),);
+#CHECKSUM:b61b9cb1c617749ecfcf3fbfa3fadde1  -:FIN CHECKSUM
\ No newline at end of file
index aac3dc04433174c50b980048c4e1168f7dd4ebc7..07f4668fca48d6e6ee6d407ff889fbe932032885 100644 (file)
@@ -9,5 +9,8 @@ CHECKING_STUDY(Study_name='Test',
                ObservationOperator=_F(Stored=0,
                                       INPUT_TYPE='Matrix',
                                       data=_F(FROM='String',
-                                              STRING='1 0 0 ; 0 1 0 ; 0 0 1 ; 1 0 0 ; 0 1 0 ; 0 0 1',),),);
-#CHECKSUM:f57c937e2c8bbc8e3f96a4b0ab10b907  -:FIN CHECKSUM
\ No newline at end of file
+                                              STRING='1 0 0 ; 0 1 0 ; 0 0 1 ; 1 0 0 ; 0 1 0 ; 0 0 1',),),
+               AlgorithmParameters=_F(INPUT_TYPE='Dict',
+                                      data=_F(FROM='String',
+                                              STRING='{ "SetSeed" : 1000 }',),),);
+#CHECKSUM:66b339da11b97e97e44e775a4cdb1824  -:FIN CHECKSUM
\ No newline at end of file
index 9752c17537a4d8c799d4fc0fbe187af6cf8b8c79..f4cf10fb26744ae7d014e81938b4661de7d5eb66 100644 (file)
@@ -3,7 +3,7 @@ ASSIMILATION_STUDY(Study_name='ADAO skeleton case',
                    Study_repertory='@prefix@/share/salome/adao_examples/daSkeletons/External_data_definition_by_scripts',
                    Debug=0,
                    Algorithm='3DVAR',
-                   Background=_F(Stored=0,
+                   Background=_F(Stored=1,
                                  INPUT_TYPE='Vector',
                                  data=_F(FROM='Script',
                                          SCRIPT_FILE='Script_Background_xb.py',),),
@@ -11,7 +11,7 @@ ASSIMILATION_STUDY(Study_name='ADAO skeleton case',
                                       INPUT_TYPE='Matrix',
                                       data=_F(FROM='Script',
                                               SCRIPT_FILE='Script_BackgroundError_B.py',),),
-                   Observation=_F(Stored=0,
+                   Observation=_F(Stored=1,
                                   INPUT_TYPE='Vector',
                                   data=_F(FROM='Script',
                                           SCRIPT_FILE='Script_Observation_yo.py',),),
index a1fadfcd0fdc72e9ec6cb6725550b7b892fed39b..9d2e281676145af4801051e0a1e678dde5efedfc 100644 (file)
@@ -47,64 +47,12 @@ def DirectOperator( XX ):
     # --------------------------------------> EXAMPLE TO BE REMOVED
     #
     return numpy.array( HX )
-#
-def TangentHMatrix( X, increment = 0.01, centeredDF = False ):
-    """ Tangent operator (Jacobian) calculated by finite differences """
-    #
-    dX  = increment * X.A1
-    #
-    if centeredDF:
-        # 
-        Jacobian  = []
-        for i in range( len(dX) ):
-            X_plus_dXi     = numpy.array( X.A1 )
-            X_plus_dXi[i]  = X[i] + dX[i]
-            X_moins_dXi    = numpy.array( X.A1 )
-            X_moins_dXi[i] = X[i] - dX[i]
-            #
-            HX_plus_dXi  = DirectOperator( X_plus_dXi )
-            HX_moins_dXi = DirectOperator( X_moins_dXi )
-            #
-            HX_Diff = ( HX_plus_dXi - HX_moins_dXi ) / (2.*dX[i])
-            #
-            Jacobian.append( HX_Diff )
-        #
-    else:
-        #
-        HX_plus_dX = []
-        for i in range( len(dX) ):
-            X_plus_dXi    = numpy.array( X.A1 )
-            X_plus_dXi[i] = X[i] + dX[i]
-            #
-            HX_plus_dXi = DirectOperator( X_plus_dXi )
-            #
-            HX_plus_dX.append( HX_plus_dXi )
-        #
-        HX = DirectOperator( X )
-        #
-        Jacobian = []
-        for i in range( len(dX) ):
-            Jacobian.append( ( HX_plus_dX[i] - HX ) / dX[i] )
-    #
-    Jacobian = numpy.matrix( Jacobian )
-    #
-    return Jacobian
-#
-def TangentOperator( X ):
-    """ Tangent operator """
-    _X = numpy.asmatrix(X).flatten().T
-    HtX = self.TangentHMatrix( _X ) * _X
-    return HtX.A1
-#
-def AdjointOperator( (X, Y) ):
-    """ Ajoint operator """
-    #
-    Jacobian = TangentHMatrix( X, centeredDF = False )
-    #
-    Y = numpy.asmatrix(Y).flatten().T
-    HaY = numpy.dot(Jacobian, Y)
-    #
-    return HaY.A1
+
+# ==============================================================================
+from ApproximatedDerivatives import FDApproximation
+FDA = FDApproximation( DirectOperator )
+TangentOperator = FDA.TangentOperator
+AdjointOperator = FDA.AdjointOperator
 
 # ==============================================================================
 if __name__ == "__main__":
index 8d3da3a8966687ddc33bec7021a38e7afb2d96cc..c5ce4ae847c3ed2f67bf60353281db8babcbccb2 100644 (file)
@@ -40,6 +40,7 @@ AlgorithmParameters = {
         [ 0., 4. ],              # Bound on the second parameter
         [ 0., None ],            # Bound on the third parameter
         ],
+    "StoreInternalVariables":True,
 }
 #
 # ==============================================================================
index d7f3f6b7ebefd03626e32e514f04b23206689798..3034a12717d913329e67ab0b9b63d1ea3481e983 100644 (file)
@@ -32,11 +32,11 @@ __author__ = "Jean-Philippe ARGAUD"
 #
 import sys, os ; sys.path.insert(0,os.path.dirname(os.path.abspath(__file__)))
 from Physical_data_and_covariance_matrices import True_state, Simple_Matrix
-from Physical_simulation_functions import FunctionH
+from Physical_simulation_functions import DirectOperator
 #
 xt, names = True_state()
 #
-yo = FunctionH( xt )
+yo = DirectOperator( xt )
 #
 R  = 0.0001 * Simple_Matrix( size = len(yo) )
 #
index 76e03133ea89ac2200d7b08fef15b891f93c9156..645f422d4cc9393dbeee99322c7314ea68a2e2aa 100644 (file)
@@ -32,11 +32,11 @@ __author__ = "Jean-Philippe ARGAUD"
 #
 import sys, os ; sys.path.insert(0,os.path.dirname(os.path.abspath(__file__)))
 from Physical_data_and_covariance_matrices import True_state
-from Physical_simulation_functions import FunctionH
+from Physical_simulation_functions import DirectOperator
 #
 xt, noms = True_state()
 #
-yo = FunctionH( xt )
+yo = DirectOperator( xt )
 #
 # Creating the required ADAO variable
 # -----------------------------------
index 61426e897668810924fd9a02695f49f94a0de25e..49de57cfb923aa4598520d00fc285d7265d18986 100644 (file)
@@ -32,6 +32,7 @@ __author__ = "Jean-Philippe ARGAUD"
 #
 from Physical_data_and_covariance_matrices import True_state
 import numpy
+numpy.set_printoptions(precision=4)
 #
 xt, names   = True_state()
 xa          = ADD.get("Analysis")[-1]
@@ -41,11 +42,14 @@ J           = ADD.get("CostFunctionJ")[:]
 # Verifying the results by printing
 # ---------------------------------
 print
-print "xt = %s"%xt
-print "xa = %s"%numpy.array(xa)
+print "obs = [%s]"%(", ".join(["%.4f"%v for v in ADD.get("Observation").A1]))
+print
+print "xb  = [%s]"%(", ".join(["%.4f"%v for v in ADD.get("Background").A1]))
+print "xt  = [%s]"%(", ".join(["%.4f"%v for v in numpy.array(xt)]))
+print "xa  = [%s]"%(", ".join(["%.4f"%v for v in numpy.array(xa)]))
 print
 for i in range( len(x_series) ):
-    print "Step %2i : J = %.5e  et  X = %s"%(i, J[i], x_series[i])
+    print "Step %2i : J = %.4e     X = [%s]"%(i, J[i], ", ".join(["%.4f"%v for v in x_series[i]]))
 print
 #
 # ==============================================================================