.. index:: single: Dict
.. index:: single: Function
.. index:: single: Matrix
+.. index:: single: ScalarSparseMatrix
+.. index:: single: DiagonalSparseMatrix
.. index:: single: String
.. index:: single: Script
.. index:: single: Vector
This indicates a variable that has to be filled by a matrix, usually given
either as a string or as a script.
-**String**
- This indicates a string giving a literal representation of a matrix, a
- vector or a vector serie, such as "1 2 ; 3 4" for a square 2x2 matrix.
+**ScalarSparseMatrix**
+ This indicates a variable that has to be filled by a unique number, which
+ will be used to multiply an identity matrix, usually given either as a
+ string or as a script.
+
+**DiagonalSparseMatrix**
+ This indicates a variable that has to be filled by a vector, which will be
+ over the diagonal of an identity matrix, usually given either as a string or
+ as a script.
**Script**
This indicates a script given as an external file. It can be described by a
full absolute path name or only by the file name without path.
+**String**
+ This indicates a string giving a literal representation of a matrix, a
+ vector or a vector serie, such as "1 2 ; 3 4" for a square 2x2 matrix.
+
**Vector**
This indicates a variable that has to be filled by a vector, usually given
either as a string or as a script.
**BackgroundError**
*Required command*. This indicates the background error covariance matrix,
previously noted as :math:`\mathbf{B}`. It is defined as a "*Matrix*" type
- object, that is, given either as a string or as a script.
+ object, a "*ScalarSparseMatrix*" type object, or a "*DiagonalSparseMatrix*"
+ type object, that is, given either as a string or as a script.
**ControlInput**
*Optional command*. This indicates the control vector used to force the
**EvolutionError**
*Optional command*. This indicates the evolution error covariance matrix,
usually noted as :math:`\mathbf{Q}`. It is defined as a "*Matrix*" type
- object, that is, given either as a string or as a script.
+ object, a "*ScalarSparseMatrix*" type object, or a "*DiagonalSparseMatrix*"
+ type object, that is, given either as a string or as a script.
**EvolutionModel**
*Optional command*. This indicates the evolution model operator, usually
**ObservationError**
*Required command*. This indicates the observation error covariance matrix,
previously noted as :math:`\mathbf{R}`. It is defined as a "*Matrix*" type
- object, that is, given either as a string or as a script.
+ object, a "*ScalarSparseMatrix*" type object, or a "*DiagonalSparseMatrix*"
+ type object, that is, given either as a string or as a script.
**ObservationOperator**
*Required command*. This indicates the observation operator, previously
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)
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)
<outport name="stored" type="bool"/>
</inline>
+ <inline name="CreateNumpyScalarSparseMatrixFromString">
+ <script><code><![CDATA[
+import numpy, logging
+logging.debug("CREATE Entering in CreateNumpyScalarSparseMatrixFromString")
+matrix = numpy.matrix(matrix_in_string)
+type = "ScalarSparseMatrix"
+logging.debug("CREATE ScalarSparseMatrix is %s"%matrix)
+]]></code></script>
+ <inport name="matrix_in_string" type="string"/>
+ <outport name="matrix" type="pyobj"/>
+ <outport name="type" type="string"/>
+ <outport name="stored" type="bool"/>
+ </inline>
+
+ <inline name="CreateNumpyDiagonalSparseMatrixFromString">
+ <script><code><![CDATA[
+import numpy, logging
+logging.debug("CREATE Entering in CreateNumpyDiagonalSparseMatrixFromString")
+matrix = numpy.matrix(matrix_in_string)
+type = "DiagonalSparseMatrix"
+logging.debug("CREATE DiagonalSparseMatrix is %s"%matrix)
+]]></code></script>
+ <inport name="matrix_in_string" type="string"/>
+ <outport name="matrix" type="pyobj"/>
+ <outport name="type" type="string"/>
+ <outport name="stored" type="bool"/>
+ </inline>
+
<inline name="CreateNumpyMatrixFromScript">
<script><code><![CDATA[
import logging
__import__(module_name)
user_script_module = sys.modules[module_name]
+# Get Data from script
+]]></code></script>
+ <inport name="script" type="string"/>
+ <outport name="type" type="string"/>
+ <outport name="stored" type="bool"/>
+ </inline>
+
+ <inline name="CreateNumpyScalarSparseMatrixFromScript">
+ <script><code><![CDATA[
+import logging
+logging.debug("CREATE Entering in CreateNumpyScalarSparseMatrixFromScript")
+type = "ScalarSparseMatrix"
+
+# Get file path and filename
+import sys
+import os
+filepath = os.path.dirname(script)
+filename = os.path.basename(script)
+module_name = os.path.splitext(filename)[0]
+if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
+ sys.path.insert(0,filepath)
+
+# Import script
+__import__(module_name)
+user_script_module = sys.modules[module_name]
+
+# Get Data from script
+]]></code></script>
+ <inport name="script" type="string"/>
+ <outport name="type" type="string"/>
+ <outport name="stored" type="bool"/>
+ </inline>
+
+ <inline name="CreateNumpyDiagonalSparseMatrixFromScript">
+ <script><code><![CDATA[
+import logging
+logging.debug("CREATE Entering in CreateNumpyDiagonalSparseMatrixFromScript")
+type = "DiagonalSparseMatrix"
+
+# Get file path and filename
+import sys
+import os
+filepath = os.path.dirname(script)
+filename = os.path.basename(script)
+module_name = os.path.splitext(filename)[0]
+if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
+ sys.path.insert(0,filepath)
+
+# Import script
+__import__(module_name)
+user_script_module = sys.modules[module_name]
+
# Get Data from script
]]></code></script>
<inport name="script" type="string"/>
if Type == "Vector":
self.BackgroundType = Type
else:
- raise daError("[daStudy::setBackgroundType] Type is unkown : " + Type + ". Types are : Vector")
+ raise daError("[daStudy::setBackgroundType] The following type is unkown : %s. Authorized types are : Vector"%(Type,))
def setBackgroundStored(self, Stored):
if Stored:
if Type == "Vector":
self.CheckingPointType = Type
else:
- raise daError("[daStudy::setCheckingPointType] Type is unkown : " + Type + ". Types are : Vector")
+ raise daError("[daStudy::setCheckingPointType] The following type is unkown : %s. Authorized types are : Vector"%(Type,))
def setCheckingPointStored(self, Stored):
if Stored:
#--------------------------------------
+ def setBackgroundErrorType(self, Type):
+ if Type in ("Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix"):
+ self.BackgroundErrorType = Type
+ else:
+ raise daError("[daStudy::setBackgroundErrorType] The following type is unkown : %s. Authorized types are : Matrix, ScalarSparseMatrix, DiagonalSparseMatrix"%(Type,))
+
def setBackgroundErrorStored(self, Stored):
if Stored:
self.BackgroundErrorStored = True
def setBackgroundError(self, BackgroundError):
try:
+ self.BackgroundErrorType
self.BackgroundErrorStored
except AttributeError:
- raise daError("[daStudy::setBackgroundError] Storage is not defined !")
- self.ADD.setBackgroundError(asCovariance = BackgroundError, toBeStored = self.BackgroundErrorStored)
+ raise daError("[daStudy::setBackgroundError] Type or Storage is not defined !")
+ if self.BackgroundErrorType == "Matrix":
+ self.ADD.setBackgroundError(asCovariance = BackgroundError, toBeStored = self.BackgroundErrorStored)
+ if self.BackgroundErrorType == "ScalarSparseMatrix":
+ self.ADD.setBackgroundError(asEyeByScalar = BackgroundError, toBeStored = self.BackgroundErrorStored)
+ if self.BackgroundErrorType == "DiagonalSparseMatrix":
+ self.ADD.setBackgroundError(asEyeByVector = BackgroundError, toBeStored = self.BackgroundErrorStored)
#--------------------------------------
def setControlInputType(self, Type):
- if Type == "Vector" or Type == "VectorSerie":
+ if Type in ("Vector", "VectorSerie"):
self.ControlInputType = Type
else:
- raise daError("[daStudy::setControlInputType] Type is unkown : " + Type + ". Types are : Vector, VectorSerie")
+ raise daError("[daStudy::setControlInputType] The following type is unkown : %s. Authorized types are : Vector, VectorSerie"%(Type,))
def setControlInputStored(self, Stored):
if Stored:
#--------------------------------------
def setObservationType(self, Type):
- if Type == "Vector" or Type == "VectorSerie":
+ if Type in ("Vector", "VectorSerie"):
self.ObservationType = Type
else:
- raise daError("[daStudy::setObservationType] Type is unkown : " + Type + ". Types are : Vector, VectorSerie")
+ raise daError("[daStudy::setObservationType] The following type is unkown : %s. Authorized types are : Vector, VectorSerie"%(Type,))
def setObservationStored(self, Stored):
if Stored:
#--------------------------------------
+ def setObservationErrorType(self, Type):
+ if Type in ("Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix"):
+ self.ObservationErrorType = Type
+ else:
+ raise daError("[daStudy::setObservationErrorType] The following type is unkown : %s. Authorized types are : Matrix, ScalarSparseMatrix, DiagonalSparseMatrix"%(Type,))
+
def setObservationErrorStored(self, Stored):
if Stored:
self.ObservationErrorStored = True
def setObservationError(self, ObservationError):
try:
+ self.ObservationErrorType
self.ObservationErrorStored
except AttributeError:
- raise daError("[daStudy::setObservationError] Storage is not defined !")
- self.ADD.setObservationError(asCovariance = ObservationError, toBeStored = self.ObservationErrorStored)
+ raise daError("[daStudy::setObservationError] Type or Storage is not defined !")
+ if self.ObservationErrorType == "Matrix":
+ self.ADD.setObservationError(asCovariance = ObservationError, toBeStored = self.ObservationErrorStored)
+ if self.ObservationErrorType == "ScalarSparseMatrix":
+ self.ADD.setObservationError(asEyeByScalar = ObservationError, toBeStored = self.ObservationErrorStored)
+ if self.ObservationErrorType == "DiagonalSparseMatrix":
+ self.ADD.setObservationError(asEyeByVector = ObservationError, toBeStored = self.ObservationErrorStored)
#--------------------------------------
return rtn
def setObservationOperatorType(self, Name, Type):
- if Type == "Matrix":
- self.ObservationOperatorType[Name] = Type
- elif Type == "Function":
+ if Type in ("Matrix", "Function"):
self.ObservationOperatorType[Name] = Type
else:
- raise daError("[daStudy::setObservationOperatorType] Type is unkown : " + Type + ". Types are : Matrix, Function")
+ raise daError("[daStudy::setObservationOperatorType] The following type is unkown : %s. Authorized types are : Matrix, Function"%(Type,))
def setObservationOperator(self, Name, ObservationOperator):
try:
#--------------------------------------
+ def setEvolutionErrorType(self, Type):
+ if Type in ("Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix"):
+ self.EvolutionErrorType = Type
+ else:
+ raise daError("[daStudy::setEvolutionErrorType] The following type is unkown : %s. Authorized types are : Matrix, ScalarSparseMatrix, DiagonalSparseMatrix"%(Type,))
+
def setEvolutionErrorStored(self, Stored):
if Stored:
self.EvolutionErrorStored = True
def setEvolutionError(self, EvolutionError):
try:
+ self.EvolutionErrorType
self.EvolutionErrorStored
except AttributeError:
- raise daError("[daStudy::setEvolutionError] Storage is not defined !")
- self.ADD.setEvolutionError(asCovariance = EvolutionError, toBeStored = self.EvolutionErrorStored)
+ raise daError("[daStudy::setEvolutionError] Type or Storage is not defined !")
+ if self.EvolutionErrorType == "Matrix":
+ self.ADD.setEvolutionError(asCovariance = EvolutionError, toBeStored = self.EvolutionErrorStored)
+ if self.EvolutionErrorType == "ScalarSparseMatrix":
+ self.ADD.setEvolutionError(asEyeByScalar = EvolutionError, toBeStored = self.EvolutionErrorStored)
+ if self.EvolutionErrorType == "DiagonalSparseMatrix":
+ self.ADD.setEvolutionError(asEyeByVector = EvolutionError, toBeStored = self.EvolutionErrorStored)
#--------------------------------------
return rtn
def setEvolutionModelType(self, Name, Type):
- if Type == "Matrix":
- self.EvolutionModelType[Name] = Type
- elif Type == "Function":
+ if Type in ("Matrix", "Function"):
self.EvolutionModelType[Name] = Type
else:
- raise daError("[daStudy::setEvolutionModelType] Type is unkown : " + Type + ". Types are : Matrix, Function")
+ raise daError("[daStudy::setEvolutionModelType] The following type is unkown : %s. Authorized types are : Matrix, Function"%(Type,))
def setEvolutionModel(self, Name, EvolutionModel):
try:
AssimType = {}
AssimType["Background"] = ["Vector"]
-AssimType["BackgroundError"] = ["Matrix"]
+AssimType["BackgroundError"] = ["Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix"]
AssimType["Observation"] = ["Vector", "VectorSerie"]
-AssimType["ObservationError"] = ["Matrix"]
+AssimType["ObservationError"] = ["Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix"]
AssimType["ObservationOperator"] = ["Matrix", "Function"]
AssimType["EvolutionModel"] = ["Matrix", "Function"]
-AssimType["EvolutionError"] = ["Matrix"]
+AssimType["EvolutionError"] = ["Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix"]
AssimType["AlgorithmParameters"] = ["Dict"]
AssimType["UserDataInit"] = ["Dict"]
AssimType["CheckingPoint"] = ["Vector"]
AssimType["ControlInput"] = ["Vector", "VectorSerie"]
FromNumpyList = {}
-FromNumpyList["Vector"] = ["String", "Script"]
-FromNumpyList["VectorSerie"] = ["String", "Script"]
-FromNumpyList["Matrix"] = ["String", "Script"]
-FromNumpyList["Function"] = ["ScriptWithOneFunction", "ScriptWithFunctions", "ScriptWithSwitch", "FunctionDict"]
-FromNumpyList["Dict"] = ["Script"]
+FromNumpyList["Vector"] = ["String", "Script"]
+FromNumpyList["VectorSerie"] = ["String", "Script"]
+FromNumpyList["Matrix"] = ["String", "Script"]
+FromNumpyList["ScalarSparseMatrix"] = ["String", "Script"]
+FromNumpyList["DiagonalSparseMatrix"] = ["String", "Script"]
+FromNumpyList["Function"] = ["ScriptWithOneFunction", "ScriptWithFunctions", "ScriptWithSwitch", "FunctionDict"]
+FromNumpyList["Dict"] = ["Script"]
# -- Infos from daAlgorithms --
AssimAlgos = [
# Data input dict
DataTypeDict = {}
-DataTypeDict["Vector"] = ["String", "Script"]
-DataTypeDict["VectorSerie"] = ["String", "Script"]
-DataTypeDict["Matrix"] = ["String", "Script"]
-DataTypeDict["Function"] = ["ScriptWithOneFunction", "ScriptWithFunctions", "ScriptWithSwitch", "FunctionDict"]
-DataTypeDict["Dict"] = ["Script"]
+DataTypeDict["Vector"] = ["String", "Script"]
+DataTypeDict["VectorSerie"] = ["String", "Script"]
+DataTypeDict["Matrix"] = ["String", "Script"]
+DataTypeDict["ScalarSparseMatrix"] = ["String", "Script"]
+DataTypeDict["DiagonalSparseMatrix"] = ["String", "Script"]
+DataTypeDict["Function"] = ["ScriptWithOneFunction", "ScriptWithFunctions", "ScriptWithSwitch", "FunctionDict"]
+DataTypeDict["Dict"] = ["Script"]
DataTypeDefaultDict = {}
-DataTypeDefaultDict["Vector"] = "Script"
-DataTypeDefaultDict["VectorSerie"] = "Script"
-DataTypeDefaultDict["Matrix"] = "Script"
-DataTypeDefaultDict["Function"] = "ScriptWithOneFunction"
-DataTypeDefaultDict["Dict"] = "Script"
+DataTypeDefaultDict["Vector"] = "Script"
+DataTypeDefaultDict["VectorSerie"] = "Script"
+DataTypeDefaultDict["Matrix"] = "Script"
+DataTypeDefaultDict["ScalarSparseMatrix"] = "String"
+DataTypeDefaultDict["DiagonalSparseMatrix"] = "String"
+DataTypeDefaultDict["Function"] = "ScriptWithOneFunction"
+DataTypeDefaultDict["Dict"] = "Script"
# Assimilation data input
AssimDataDict = {}
AssimDataDict["Background"] = ["Vector"]
-AssimDataDict["BackgroundError"] = ["Matrix"]
+AssimDataDict["BackgroundError"] = ["Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix"]
AssimDataDict["Observation"] = ["Vector", "VectorSerie"]
-AssimDataDict["ObservationError"] = ["Matrix"]
+AssimDataDict["ObservationError"] = ["Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix"]
AssimDataDict["ObservationOperator"] = ["Matrix", "Function"]
AssimDataDict["EvolutionModel"] = ["Matrix", "Function"]
-AssimDataDict["EvolutionError"] = ["Matrix"]
+AssimDataDict["EvolutionError"] = ["Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix"]
AssimDataDict["AlgorithmParameters"] = ["Dict"]
AssimDataDict["UserDataInit"] = ["Dict"]
AssimDataDict["CheckingPoint"] = ["Vector"]
AssimDataDefaultDict["CheckingPoint"] = "Vector"
AssimDataDefaultDict["ControlInput"] = "Vector"
-StoredAssimData = ["Vector", "VectorSerie", "Matrix"]
+StoredAssimData = ["Vector", "VectorSerie", "Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix"]
# Assimilation optional nodes
OptDict = {}
ADAO_Case.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
back_node.setScript(back_node_script)
- if data_config["Type"] == "Matrix" and data_config["From"] == "String":
+ if data_config["Type"] in ("Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix") and data_config["From"] == "String":
# Create node
- factory_back_node = catalogAd.getNodeFromNodeMap("CreateNumpyMatrixFromString")
+ factory_back_node = catalogAd.getNodeFromNodeMap("CreateNumpy%sFromString"%(data_config["Type"],))
back_node = factory_back_node.cloneNode("Get" + key)
back_node.getInputPort("matrix_in_string").edInitPy(data_config["Data"])
ADAO_Case.edAddChild(back_node)
ADAO_Case.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
back_node.setScript(back_node_script)
- if data_config["Type"] == "Matrix" and data_config["From"] == "Script":
+ if data_config["Type"] in ("Matrix", "ScalarSparseMatrix", "DiagonalSparseMatrix") and data_config["From"] == "Script":
# Create node
- factory_back_node = catalogAd.getNodeFromNodeMap("CreateNumpyMatrixFromScript")
+ factory_back_node = catalogAd.getNodeFromNodeMap("CreateNumpy%sFromScript"%(data_config["Type"],))
back_node = factory_back_node.cloneNode("Get" + key)
if repertory:
back_node.getInputPort("script").edInitPy(os.path.join(base_repertory, os.path.basename(data_config["Data"])))