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