From: André Date: Thu, 22 Apr 2010 12:32:23 +0000 (+0200) Subject: Fin de l'init de l'etude de l'assimilation X-Git-Tag: V6_4_0rc3~168 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c7e5adbc4de32749b8a0a74ae4f6df40ef5da96f;p=modules%2Fadao.git Fin de l'init de l'etude de l'assimilation --- diff --git a/resources/DATASSIMSchemaCatalog.xml b/resources/DATASSIMSchemaCatalog.xml index eee86ad..1b3c79c 100644 --- a/resources/DATASSIMSchemaCatalog.xml +++ b/resources/DATASSIMSchemaCatalog.xml @@ -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) ]]> diff --git a/src/daSalome/daYacsIntegration/daStudy.py b/src/daSalome/daYacsIntegration/daStudy.py index 6b8beb1..ad2cb8e 100644 --- a/src/daSalome/daYacsIntegration/daStudy.py +++ b/src/daSalome/daYacsIntegration/daStudy.py @@ -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) + diff --git a/src/tests/daSalome/test000_Blue.py b/src/tests/daSalome/test000_Blue.py index c0ed37d..1ad1721 100644 --- a/src/tests/daSalome/test000_Blue.py +++ b/src/tests/daSalome/test000_Blue.py @@ -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"