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
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
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
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
--- /dev/null
+
+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
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
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
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',),),
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',),),
# --------------------------------------> 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__":
[ 0., 4. ], # Bound on the second parameter
[ 0., None ], # Bound on the third parameter
],
+ "StoreInternalVariables":True,
}
#
# ==============================================================================
#
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) )
#
#
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
# -----------------------------------
#
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]
# 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
#
# ==============================================================================