3 from daCore.AssimilationStudy import AssimilationStudy
5 class daError(Exception):
6 def __init__(self, value):
9 return repr(self.value)
13 def __init__(self, name, algorithm):
15 self.ADD = AssimilationStudy(name)
16 self.ADD.setControls()
17 self.algorithm = algorithm
18 self.algorithm_dict = None
19 self.Background = None
21 # Observation Management
22 self.ObservationOperatorType = {}
23 self.FunctionObservationOperator = {}
25 def setAlgorithmParameters(self, parameters):
26 self.algorithm_dict = parameters
28 def initAlgorithm(self):
30 self.ADD.setAlgorithm(choice=self.algorithm)
31 if self.algorithm_dict != None:
32 self.ADD.setAlgorithmParameters(asDico=self.algorithm_dict)
34 def getAssimilationStudy(self):
38 # Methods to initialize AssimilationStudy
40 def setBackgroundType(self, Type):
43 self.BackgroundType = Type
45 raise daError("[daStudy::setBackgroundType] Type is unkown : " + Type + " Types are : Vector")
47 def setBackground(self, Background):
51 except AttributeError:
52 raise daError("[daStudy::setBackground] Type is not defined !")
54 self.Background = Background
56 if self.BackgroundType == "Vector":
57 self.ADD.setBackground(asVector = Background)
59 def getBackground(self):
60 return self.Background
62 def setBackgroundError(self, BackgroundError):
64 self.ADD.setBackgroundError(asCovariance = BackgroundError)
66 def setObservationType(self, Type):
69 self.ObservationType = Type
71 raise daError("[daStudy::setObservationType] Type is unkown : " + Type + " Types are : Vector")
73 def setObservation(self, Observation):
77 except AttributeError:
78 raise daError("[daStudy::setObservation] Type is not defined !")
80 if self.ObservationType == "Vector":
81 self.ADD.setObservation(asVector = Observation)
83 def setObservationError(self, ObservationError):
84 self.ADD.setObservationError(asCovariance = ObservationError)
87 def getObservationOperatorType(self, Name):
90 rtn = self.ObservationOperatorType[Name]
95 def setObservationOperatorType(self, Name, Type):
97 self.ObservationOperatorType[Name] = Type
98 elif Type == "Function":
99 self.ObservationOperatorType[Name] = Type
101 raise daError("[daStudy::setObservationOperatorType] Type is unkown : " + Type + " Types are : Matrix")
103 def setObservationOperator(self, Name, ObservationOperator):
105 self.ObservationOperatorType[Name]
106 except AttributeError:
107 raise daError("[daStudy::setObservationOperator] Type is not defined !")
109 if self.ObservationOperatorType[Name] == "Matrix":
110 self.ADD.setObservationOperator(asMatrix = ObservationOperator)
111 elif self.ObservationOperatorType[Name] == "Function":
112 self.FunctionObservationOperator[Name] = ObservationOperator