1 # -*- coding: utf-8 -*-
3 from numpy import array, ravel
4 def QuadFunction( coefficients ):
6 Fonction : y = a x^2 + b x + c
8 a, b, c = list(ravel(coefficients))
9 x_points = (-5, 0, 1, 3, 10)
12 y_points.append( a*x*x + b*x + c )
13 return array(y_points)
15 print("Résolution itérative du problème de calibration")
16 print("-----------------------.-----------------------")
18 from adao import adaoBuilder
19 case = adaoBuilder.New('')
20 case.setBackground( Vector = array([1., 1., 1.]), Stored=True )
21 case.setBackgroundError( ScalarSparseMatrix = 1.e6 )
22 case.setObservation( Vector=array([57, 2, 3, 17, 192]), Stored=True )
23 case.setObservationError( ScalarSparseMatrix = 1. )
24 case.setObservationOperator( OneFunction = QuadFunction )
25 case.setAlgorithmParameters(
28 'StoreSupplementaryCalculations': [
34 Info=" État intermédiaire en itération courante :",
35 Template='ValuePrinter',
36 Variable='CurrentState',
41 #-------------------------------------------------------------------------------
43 print("Calibration de %i coefficients pour une forme quadratique 1D sur %i mesures"%(
44 len(case.get('Background')),
45 len(case.get('Observation')),
47 print("------------------------------------------------------------------------")
49 print("Vecteur observation.......................:", ravel(case.get('Observation')))
50 print("État ébauche a priori.....................:", ravel(case.get('Background')))
52 print("Coefficients théoriques attendus..........:", ravel((2,-1,2)))
54 print("Coefficients résultants de la calibration.:", ravel(case.get('Analysis')[-1]))