]> SALOME platform Git repositories - modules/adao.git/blob - src/daSalome/daYacsIntegration/daStudy.py
Salome HOME
- Patch pour les changements sur EficasV1
[modules/adao.git] / src / daSalome / daYacsIntegration / daStudy.py
1 #-*- coding: utf-8 -*-
2
3 from daCore.AssimilationStudy import AssimilationStudy
4
5 class daError(Exception):
6   def __init__(self, value):
7     self.value = value
8   def __str__(self):
9     return repr(self.value)
10
11 class daStudy:
12
13   def __init__(self, name, algorithm):
14
15     self.ADD = AssimilationStudy(name)
16     self.ADD.setControls()
17     self.algorithm = algorithm
18     self.algorithm_dict = None
19     self.Background = None
20
21     # Observation Management
22     self.ObservationOperatorType = {}
23     self.FunctionObservationOperator = {}
24
25   def setAlgorithmParameters(self, parameters):
26     self.algorithm_dict = parameters
27
28   def initAlgorithm(self):
29
30     self.ADD.setAlgorithm(choice=self.algorithm)
31     if self.algorithm_dict != None:
32       self.ADD.setAlgorithmParameters(asDico=self.algorithm_dict)
33
34   def getAssimilationStudy(self):
35
36     return self.ADD
37
38   # Methods to initialize AssimilationStudy
39
40   def setBackgroundType(self, Type):
41
42     if Type == "Vector":
43       self.BackgroundType = Type
44     else:
45       raise daError("[daStudy::setBackgroundType] Type is unkown : " + Type + " Types are : Vector")
46
47   def setBackground(self, Background):
48
49     try:
50       self.BackgroundType
51     except AttributeError:
52       raise daError("[daStudy::setBackground] Type is not defined !")
53
54     self.Background = Background
55
56     if self.BackgroundType == "Vector":
57       self.ADD.setBackground(asVector = Background)
58
59   def getBackground(self):
60     return self.Background
61
62   def setBackgroundError(self, BackgroundError):
63
64     self.ADD.setBackgroundError(asCovariance = BackgroundError)
65
66   def setObservationType(self, Type):
67
68     if Type == "Vector":
69       self.ObservationType = Type
70     else:
71       raise daError("[daStudy::setObservationType] Type is unkown : " + Type + " Types are : Vector")
72
73   def setObservation(self, Observation):
74
75     try:
76       self.ObservationType
77     except AttributeError:
78       raise daError("[daStudy::setObservation] Type is not defined !")
79
80     if self.ObservationType == "Vector":
81       self.ADD.setObservation(asVector = Observation)
82
83   def setObservationError(self, ObservationError):
84     self.ADD.setObservationError(asCovariance = ObservationError)
85
86
87   def getObservationOperatorType(self, Name):
88     rtn = None
89     try:
90       rtn = self.ObservationOperatorType[Name]
91     except:
92       pass
93     return rtn
94
95   def setObservationOperatorType(self, Name, Type):
96     if Type == "Matrix":
97       self.ObservationOperatorType[Name] = Type
98     elif Type == "Function":
99       self.ObservationOperatorType[Name] = Type
100     else:
101       raise daError("[daStudy::setObservationOperatorType] Type is unkown : " + Type + " Types are : Matrix")
102
103   def setObservationOperator(self, Name, ObservationOperator):
104     try:
105       self.ObservationOperatorType[Name]
106     except AttributeError:
107       raise daError("[daStudy::setObservationOperator] Type is not defined !")
108
109     if self.ObservationOperatorType[Name] == "Matrix":
110       self.ADD.setObservationOperator(asMatrix = ObservationOperator)
111     elif self.ObservationOperatorType[Name] == "Function":
112       self.FunctionObservationOperator[Name] = ObservationOperator
113