3 from daCore.AssimilationStudy import AssimilationStudy
4 from daCore import Logging
6 class daError(Exception):
7 def __init__(self, value):
10 return repr(self.value)
14 def __init__(self, name, algorithm, debug):
16 self.ADD = AssimilationStudy(name)
17 self.ADD.setControls()
18 self.algorithm = algorithm
19 self.algorithm_dict = None
20 self.Background = None
25 logging.getLogger().setLevel(logging.DEBUG)
27 logging.getLogger().setLevel(logging.INFO)
30 # Observation Management
31 self.ObservationOperatorType = {}
32 self.FunctionObservationOperator = {}
34 def setAlgorithmParameters(self, parameters):
35 self.algorithm_dict = parameters
37 def initAlgorithm(self):
39 self.ADD.setAlgorithm(choice=self.algorithm)
40 if self.algorithm_dict != None:
41 self.ADD.setAlgorithmParameters(asDico=self.algorithm_dict)
43 def getAssimilationStudy(self):
47 # Methods to initialize AssimilationStudy
49 def setBackgroundType(self, Type):
52 self.BackgroundType = Type
54 raise daError("[daStudy::setBackgroundType] Type is unkown : " + Type + " Types are : Vector")
56 def setBackground(self, Background):
60 except AttributeError:
61 raise daError("[daStudy::setBackground] Type is not defined !")
63 self.Background = Background
65 if self.BackgroundType == "Vector":
66 self.ADD.setBackground(asVector = Background)
68 def getBackground(self):
69 return self.Background
71 def setBackgroundError(self, BackgroundError):
73 self.ADD.setBackgroundError(asCovariance = BackgroundError)
75 def setObservationType(self, Type):
78 self.ObservationType = Type
80 raise daError("[daStudy::setObservationType] Type is unkown : " + Type + " Types are : Vector")
82 def setObservation(self, Observation):
86 except AttributeError:
87 raise daError("[daStudy::setObservation] Type is not defined !")
89 if self.ObservationType == "Vector":
90 self.ADD.setObservation(asVector = Observation)
92 def setObservationError(self, ObservationError):
93 self.ADD.setObservationError(asCovariance = ObservationError)
96 def getObservationOperatorType(self, Name):
99 rtn = self.ObservationOperatorType[Name]
104 def setObservationOperatorType(self, Name, Type):
106 self.ObservationOperatorType[Name] = Type
107 elif Type == "Function":
108 self.ObservationOperatorType[Name] = Type
110 raise daError("[daStudy::setObservationOperatorType] Type is unkown : " + Type + " Types are : Matrix")
112 def setObservationOperator(self, Name, ObservationOperator):
114 self.ObservationOperatorType[Name]
115 except AttributeError:
116 raise daError("[daStudy::setObservationOperator] Type is not defined !")
118 if self.ObservationOperatorType[Name] == "Matrix":
119 self.ADD.setObservationOperator(asMatrix = ObservationOperator)
120 elif self.ObservationOperatorType[Name] == "Function":
121 self.FunctionObservationOperator[Name] = ObservationOperator