From 9e6a6c143cf1b3daa121b9954324910e273379d4 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Mon, 6 Mar 2017 09:29:12 +0100 Subject: [PATCH] Minor correction for raised error messages --- resources/ADAOSchemaCatalog.xml | 344 +++++++++++++------------------- 1 file changed, 143 insertions(+), 201 deletions(-) diff --git a/resources/ADAOSchemaCatalog.xml b/resources/ADAOSchemaCatalog.xml index dd4bb25..4505e6a 100644 --- a/resources/ADAOSchemaCatalog.xml +++ b/resources/ADAOSchemaCatalog.xml @@ -65,208 +65,151 @@ print "Entering in the assimilation study" print "Name is set to........:", Name print "Algorithm is set to...:", Algorithm -# Create Assimilation study -from daYacsIntegration.daStudy import * -assim_study = daStudy(Name, Algorithm, Debug) - -logging.debug("CREATE Data entered are:") - -# Algorithm parameters -try: - AlgorithmParameters -except NameError: - pass -else: - logging.debug("CREATE AlgorithmParameters is %s"%AlgorithmParameters) - assim_study.setAlgorithmParameters(AlgorithmParameters) - -# Background -try: - Background -except NameError: - pass -else: - logging.debug("CREATE Background is set") - logging.debug("CREATE BackgroundType is %s"%BackgroundType) - logging.debug("CREATE BackgroundStored is %s"%BackgroundStored) - assim_study.setBackgroundType(BackgroundType) - assim_study.setBackgroundStored(BackgroundStored) - assim_study.setBackground(Background) - -# CheckingPoint -try: - CheckingPoint -except NameError: - pass -else: - logging.debug("CREATE CheckingPoint is set") - logging.debug("CREATE CheckingPointType is %s"%CheckingPointType) - logging.debug("CREATE CheckingPointStored is %s"%CheckingPointStored) - assim_study.setCheckingPointType(CheckingPointType) - assim_study.setCheckingPointStored(CheckingPointStored) - assim_study.setCheckingPoint(CheckingPoint) - -# ControlInput -try: - ControlInput -except NameError: - pass -else: - logging.debug("CREATE ControlInput is set") - logging.debug("CREATE ControlInputType is %s"%ControlInputType) - logging.debug("CREATE ControlInputStored is %s"%ControlInputStored) - assim_study.setControlInputType(ControlInputType) - assim_study.setControlInputStored(ControlInputStored) - assim_study.setControlInput(ControlInput) - -# Observation -try: - Observation -except NameError: - pass -else: - logging.debug("CREATE Observation is set") - logging.debug("CREATE ObservationType is %s"%ObservationType) - logging.debug("CREATE ObservationStored is %s"%ObservationStored) - assim_study.setObservationType(ObservationType) - assim_study.setObservationStored(ObservationStored) - assim_study.setObservation(Observation) - -# BackgroundError -try: - BackgroundError -except NameError: - pass -else: - logging.debug("CREATE BackgroundError is set") - logging.debug("CREATE BackgroundErrorType is %s"%BackgroundErrorType) - logging.debug("CREATE BackgroundErrorStored is %s"%BackgroundErrorStored) - assim_study.setBackgroundErrorType(BackgroundErrorType) - assim_study.setBackgroundErrorStored(BackgroundErrorStored) - assim_study.setBackgroundError(BackgroundError) - -# ObservationError try: - ObservationError -except NameError: - pass -else: - logging.debug("CREATE ObservationError is set") - logging.debug("CREATE ObservationErrorType is %s"%ObservationErrorType) - logging.debug("CREATE ObservationErrorStored is %s"%ObservationErrorStored) - assim_study.setObservationErrorType(ObservationErrorType) - assim_study.setObservationErrorStored(ObservationErrorStored) - assim_study.setObservationError(ObservationError) - -# EvolutionError -try: - EvolutionError -except NameError: - pass -else: - logging.debug("CREATE EvolutionError is set") - logging.debug("CREATE EvolutionErrorType is %s"%EvolutionErrorType) - logging.debug("CREATE EvolutionErrorStored is %s"%EvolutionErrorStored) - assim_study.setEvolutionErrorType(EvolutionErrorType) - assim_study.setEvolutionErrorStored(EvolutionErrorStored) - assim_study.setEvolutionError(EvolutionError) - -# ObservationOperator -ObservationOperatorOk = 0 -try: - ObservationOperator -except NameError: - pass -else: - logging.debug("CREATE ObservationOperator is set") - logging.debug("CREATE ObservationOperatorType is %s"%ObservationOperatorType) - assim_study.setObservationOperatorType("Matrix", ObservationOperatorType) - assim_study.setObservationOperator("Matrix", ObservationOperator) - ObservationOperatorOk = 1 - -if ObservationOperatorOk == 0: - try: - ObservationOperatorDirect - except NameError: - pass - else: - logging.debug("CREATE ObservationOperatorDirect is %s"%ObservationOperatorDirect) - assim_study.setObservationOperatorType("Direct", "Function") - assim_study.setObservationOperator("Direct", ObservationOperatorDirect) - try: - ObservationOperatorTangent - except NameError: - pass - else: - logging.debug("CREATE ObservationOperatorTangent is %s"%ObservationOperatorTangent) - assim_study.setObservationOperatorType("Tangent", "Function") - assim_study.setObservationOperator("Tangent", ObservationOperatorTangent) - try: - ObservationOperatorAdjoint - except NameError: - pass - else: - logging.debug("CREATE ObservationOperatorAdjoint is %s"%ObservationOperatorAdjoint) - assim_study.setObservationOperatorType("Adjoint", "Function") - assim_study.setObservationOperator("Adjoint", ObservationOperatorAdjoint) + # Create Assimilation study + from daYacsIntegration.daStudy import * + assim_study = daStudy(Name, Algorithm, Debug) + + logging.debug("CREATE Data entered are:") + + # Algorithm parameters + if "AlgorithmParameters" in locals(): + logging.debug("CREATE AlgorithmParameters is %s"%AlgorithmParameters) + assim_study.setAlgorithmParameters(AlgorithmParameters) + + # Background + if "Background" in locals(): + logging.debug("CREATE Background is set") + logging.debug("CREATE BackgroundType is %s"%BackgroundType) + logging.debug("CREATE BackgroundStored is %s"%BackgroundStored) + assim_study.setBackgroundType(BackgroundType) + assim_study.setBackgroundStored(BackgroundStored) + assim_study.setBackground(Background) + + # CheckingPoint + if "CheckingPoint" in locals(): + logging.debug("CREATE CheckingPoint is set") + logging.debug("CREATE CheckingPointType is %s"%CheckingPointType) + logging.debug("CREATE CheckingPointStored is %s"%CheckingPointStored) + assim_study.setCheckingPointType(CheckingPointType) + assim_study.setCheckingPointStored(CheckingPointStored) + assim_study.setCheckingPoint(CheckingPoint) + + # ControlInput + if "ControlInput" in locals(): + logging.debug("CREATE ControlInput is set") + logging.debug("CREATE ControlInputType is %s"%ControlInputType) + logging.debug("CREATE ControlInputStored is %s"%ControlInputStored) + assim_study.setControlInputType(ControlInputType) + assim_study.setControlInputStored(ControlInputStored) + assim_study.setControlInput(ControlInput) + + # Observation + if "Observation" in locals(): + logging.debug("CREATE Observation is set") + logging.debug("CREATE ObservationType is %s"%ObservationType) + logging.debug("CREATE ObservationStored is %s"%ObservationStored) + assim_study.setObservationType(ObservationType) + assim_study.setObservationStored(ObservationStored) + assim_study.setObservation(Observation) + + # BackgroundError + if "BackgroundError" in locals(): + logging.debug("CREATE BackgroundError is set") + logging.debug("CREATE BackgroundErrorType is %s"%BackgroundErrorType) + logging.debug("CREATE BackgroundErrorStored is %s"%BackgroundErrorStored) + assim_study.setBackgroundErrorType(BackgroundErrorType) + assim_study.setBackgroundErrorStored(BackgroundErrorStored) + assim_study.setBackgroundError(BackgroundError) + + # ObservationError + if "ObservationError" in locals(): + logging.debug("CREATE ObservationError is set") + logging.debug("CREATE ObservationErrorType is %s"%ObservationErrorType) + logging.debug("CREATE ObservationErrorStored is %s"%ObservationErrorStored) + assim_study.setObservationErrorType(ObservationErrorType) + assim_study.setObservationErrorStored(ObservationErrorStored) + assim_study.setObservationError(ObservationError) + + # EvolutionError + if "EvolutionError" in locals(): + logging.debug("CREATE EvolutionError is set") + logging.debug("CREATE EvolutionErrorType is %s"%EvolutionErrorType) + logging.debug("CREATE EvolutionErrorStored is %s"%EvolutionErrorStored) + assim_study.setEvolutionErrorType(EvolutionErrorType) + assim_study.setEvolutionErrorStored(EvolutionErrorStored) + assim_study.setEvolutionError(EvolutionError) + + # ObservationOperator + ObservationOperatorOk = 0 + if "ObservationOperator" in locals(): + logging.debug("CREATE ObservationOperator is set") + logging.debug("CREATE ObservationOperatorType is %s"%ObservationOperatorType) + assim_study.setObservationOperatorType("Matrix", ObservationOperatorType) + assim_study.setObservationOperator("Matrix", ObservationOperator) + ObservationOperatorOk = 1 + + if ObservationOperatorOk == 0: + if "ObservationOperatorDirect" in locals(): + logging.debug("CREATE ObservationOperatorDirect is %s"%ObservationOperatorDirect) + assim_study.setObservationOperatorType("Direct", "Function") + assim_study.setObservationOperator("Direct", ObservationOperatorDirect) + if "ObservationOperatorTangent" in locals(): + logging.debug("CREATE ObservationOperatorTangent is %s"%ObservationOperatorTangent) + assim_study.setObservationOperatorType("Tangent", "Function") + assim_study.setObservationOperator("Tangent", ObservationOperatorTangent) + if "ObservationOperatorAdjoint" in locals(): + logging.debug("CREATE ObservationOperatorAdjoint is %s"%ObservationOperatorAdjoint) + assim_study.setObservationOperatorType("Adjoint", "Function") + assim_study.setObservationOperator("Adjoint", ObservationOperatorAdjoint) + + # EvolutionModel + EvolutionModelOk = 0 + if "EvolutionModel" in locals(): + logging.debug("CREATE EvolutionModel is set") + logging.debug("CREATE EvolutionModelType is %s"%EvolutionModelType) + assim_study.setEvolutionModelType("Matrix", EvolutionModelType) + assim_study.setEvolutionModel("Matrix", EvolutionModel) + EvolutionModelOk = 1 + + if EvolutionModelOk == 0: + if "EvolutionModelDirect" in locals(): + logging.debug("CREATE EvolutionModelDirect is %s"%EvolutionModelDirect) + assim_study.setEvolutionModelType("Direct", "Function") + assim_study.setEvolutionModel("Direct", EvolutionModelDirect) + if "EvolutionModelTangent" in locals(): + logging.debug("CREATE EvolutionModelTangent is %s"%EvolutionModelTangent) + assim_study.setEvolutionModelType("Tangent", "Function") + assim_study.setEvolutionModel("Tangent", EvolutionModelTangent) + if "EvolutionModelAdjoint" in locals(): + logging.debug("CREATE EvolutionModelAdjoint is %s"%EvolutionModelAdjoint) + assim_study.setEvolutionModelType("Adjoint", "Function") + assim_study.setEvolutionModel("Adjoint", EvolutionModelAdjoint) + + # Variables + for name, size in zip(InputVariablesNames, InputVariablesSizes): + assim_study.setInputVariable(name, size) + for name, size in zip(OutputVariablesNames, OutputVariablesSizes): + assim_study.setOutputVariable(name, size) + + if has_observers: + logging.debug("CREATE Observers keys are %s"%observers.keys()) + # Adding observers to the study + for observer_name in observers.keys(): + scheduler = "" + info = "" + number = str(observers[observer_name]["number"]) + if "scheduler" in observers[observer_name].keys(): + scheduler = observers[observer_name]["scheduler"] + if "info" in observers[observer_name].keys(): + info = observers[observer_name]["info"] + assim_study.addObserver(observer_name, scheduler, info, number) + +except Exception as e: + if isinstance(e, SyntaxError): msg = "at %s: %s"%(e.offset, e.text) + else: msg = "" + raise ValueError("during execution, the following error occurs:\n\n%s %s\n\nSee also the potential messages, which can show the origin of the above error, in the launching terminal."%(str(e),msg)) -# EvolutionModel -EvolutionModelOk = 0 -try: - EvolutionModel -except NameError: - pass -else: - logging.debug("CREATE EvolutionModel is set") - logging.debug("CREATE EvolutionModelType is %s"%EvolutionModelType) - assim_study.setEvolutionModelType("Matrix", EvolutionModelType) - assim_study.setEvolutionModel("Matrix", EvolutionModel) - EvolutionModelOk = 1 - -if EvolutionModelOk == 0: - try: - EvolutionModelDirect - except NameError: - pass - else: - logging.debug("CREATE EvolutionModelDirect is %s"%EvolutionModelDirect) - assim_study.setEvolutionModelType("Direct", "Function") - assim_study.setEvolutionModel("Direct", EvolutionModelDirect) - try: - EvolutionModelTangent - except NameError: - pass - else: - logging.debug("CREATE EvolutionModelTangent is %s"%EvolutionModelTangent) - assim_study.setEvolutionModelType("Tangent", "Function") - assim_study.setEvolutionModel("Tangent", EvolutionModelTangent) - try: - EvolutionModelAdjoint - except NameError: - pass - else: - logging.debug("CREATE EvolutionModelAdjoint is %s"%EvolutionModelAdjoint) - assim_study.setEvolutionModelType("Adjoint", "Function") - assim_study.setEvolutionModel("Adjoint", EvolutionModelAdjoint) - -# Variables -for name, size in zip(InputVariablesNames, InputVariablesSizes): - assim_study.setInputVariable(name, size) -for name, size in zip(OutputVariablesNames, OutputVariablesSizes): - assim_study.setOutputVariable(name, size) - -if has_observers: - logging.debug("CREATE Observers keys are %s"%observers.keys()) - # Adding observers to the study - for observer_name in observers.keys(): - scheduler = "" - info = "" - number = str(observers[observer_name]["number"]) - if "scheduler" in observers[observer_name].keys(): - scheduler = observers[observer_name]["scheduler"] - if "info" in observers[observer_name].keys(): - info = observers[observer_name]["info"] - assim_study.addObserver(observer_name, scheduler, info, number) Study = assim_study ]]> @@ -302,7 +245,6 @@ logging.debug("CREATE Matrix is %s"%matrix) import numpy, logging logging.debug("CREATE Entering in CreateNumpyScalarSparseMatrixFromString") matrix = numpy.matrix(matrix_in_string) -if matrix.size != 1: raise ValueError('\n\n The sparse matrix, declared as a "ScalarSparseMatrix" to be build using a scalar input,\n is not of the good size (its actual measured size is %i). Please correct your input and relaunch.'%matrix.size) type = "ScalarSparseMatrix" logging.debug("CREATE ScalarSparseMatrix is %s"%matrix) ]]> -- 2.39.2