]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Fin de l'init de l'etude de l'assimilation
authorAndré <andre.ribes@edf.fr>
Thu, 22 Apr 2010 12:32:23 +0000 (14:32 +0200)
committerAndré <andre.ribes@edf.fr>
Thu, 22 Apr 2010 12:32:23 +0000 (14:32 +0200)
resources/DATASSIMSchemaCatalog.xml
src/daSalome/daYacsIntegration/daStudy.py
src/tests/daSalome/test000_Blue.py

index eee86ad6bd5d3b14429a4008c37546056373b7cb..1b3c79c83bb8cfedcace5f1d811f28c46039a4c9 100644 (file)
@@ -14,6 +14,9 @@ print "Entering in CreateAssimilationStudy"
 print "Name is", Name
 print "Algorithm is", Algorithm
 
+# Create Assimilation study
+from daYacsIntegration.daStudy import *
+assim_study = daStudy(Name, Algorithm)
 
 # Data
 print "Data entered are:"
@@ -25,6 +28,8 @@ except NameError:
 else:
   print "Background is", Background
   print "BackgroundType is", BackgroundType
+  assim_study.setBackgroundType(BackgroundType)
+  assim_study.setBackground(Background)
 
 # BackgroundError
 try:
@@ -34,6 +39,7 @@ except NameError:
 else:
   print "BackgroundError is", BackgroundError
   print "BackgroundErrorType is", BackgroundErrorType
+  assim_study.setBackgroundError(BackgroundError)
 
 # Observation
 try:
@@ -43,6 +49,8 @@ except NameError:
 else:
   print "Observation is", Observation
   print "ObservationType is", ObservationType
+  assim_study.setObservationType(ObservationType)
+  assim_study.setObservation(Observation)
 
 # ObservationError
 try:
@@ -52,6 +60,7 @@ except NameError:
 else:
   print "ObservationError is", ObservationError
   print "ObservationErrorType is", ObservationErrorType
+  assim_study.setObservationError(ObservationError)
 
 # ObservationOperator
 try:
@@ -61,9 +70,9 @@ except NameError:
 else:
   print "ObservationOperator is", ObservationOperator
   print "ObservationOperatorType is", ObservationOperatorType
+  assim_study.setObservationOperatorType(ObservationOperatorType)
+  assim_study.setObservationOperator(ObservationOperator)
 
-from daYacsIntegration.daStudy import *
-assim_study = daStudy(Name, Algorithm)
 ]]>
 
 </code></script>
index 6b8beb182c62a93ff0b9d2190662c1277671f69f..ad2cb8e2bf89338cbb6fd299f956670d13d43073 100644 (file)
@@ -2,6 +2,12 @@
 
 from daCore.AssimilationStudy import AssimilationStudy
 
+class daError(Exception):
+  def __init__(self, value):
+    self.value = value
+  def __str__(self):
+    return repr(self.value)
+
 class daStudy:
 
   def __init__(self, name, algorithm):
@@ -10,5 +16,68 @@ class daStudy:
     self.ADD.setControls()
     self.ADD.setAlgorithm(choice="Blue")
 
-  def getAssimilationStudy():
+  def getAssimilationStudy(self):
+
     return self.ADD
+
+  # Methods to initialize AssimilationStudy
+
+  def setBackgroundType(self, Type):
+
+    if Type == "Vector":
+      self.BackgroundType = Type
+    else:
+      raise daError("[daStudy::setBackgroundType] Type is unkown : " + Type + " Types are : Vector")
+
+  def setBackground(self, Background):
+
+    try:
+      self.BackgroundType
+    except AttributeError:
+      raise daError("[daStudy::setBackground] Type is not defined !")
+
+    if self.BackgroundType == "Vector":
+      self.ADD.setBackground(asVector = Background)
+
+  def setBackgroundError(self, BackgroundError):
+
+    self.ADD.setBackgroundError(asCovariance = BackgroundError)
+
+  def setObservationType(self, Type):
+
+    if Type == "Vector":
+      self.ObservationType = Type
+    else:
+      raise daError("[daStudy::setObservationType] Type is unkown : " + Type + " Types are : Vector")
+
+  def setObservation(self, Observation):
+
+    try:
+      self.ObservationType
+    except AttributeError:
+      raise daError("[daStudy::setObservation] Type is not defined !")
+
+    if self.ObservationType == "Vector":
+      self.ADD.setObservation(asVector = Observation)
+
+  def setObservationError(self, ObservationError):
+
+    self.ADD.setObservationError(asCovariance = ObservationError)
+
+  def setObservationOperatorType(self, Type):
+
+    if Type == "Matrix":
+      self.ObservationOperatorType = Type
+    else:
+      raise daError("[daStudy::setObservationOperatorType] Type is unkown : " + Type + " Types are : Matrix")
+
+  def setObservationOperator(self, ObservationOperator):
+
+    try:
+      self.ObservationOperatorType
+    except AttributeError:
+      raise daError("[daStudy::setObservationOperator] Type is not defined !")
+
+    if self.ObservationOperatorType == "Matrix":
+      self.ADD.setObservationOperator(asMatrix = ObservationOperator)
+
index c0ed37db02fc6a23e99ba5368f2413f284e26d52..1ad17216dace42671f5791d1e5bfd0a211fe6934 100644 (file)
@@ -2,7 +2,6 @@ study_config = {}
 study_config["Name"] = "test000_Blue"
 study_config["Algorithm"] = "Blue"
 
-
 Background_config = {}
 Background_config["Data"] = "0,1,2"
 Background_config["Type"] = "Vector"
@@ -15,14 +14,12 @@ BackgroundError_config["Type"] = "Matrix"
 BackgroundError_config["From"] = "string"
 study_config["BackgroundError"] = BackgroundError_config
 
-
 Observation_config = {}
 Observation_config["Data"] = "0.5,1.5,2.5"
 Observation_config["Type"] = "Vector"
 Observation_config["From"] = "string"
 study_config["Observation"] = Observation_config
 
-
 ObservationError_config = {}
 ObservationError_config["Data"] = "1 0 0;0 1 0;0 0 1"
 ObservationError_config["Type"] = "Matrix"