SCRIPT_DATA = BLOC ( condition = " FROM in ( 'Script', ) ",
SCRIPT_FILE = SIMP(statut = "o", typ = ("FichierNoAbs",'Python Files (*.py)',), validators=[OnlyStr(), FileExtVal('py'), FunctionVal(fv)], fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant si nécessaire la définition d'une variable interne de même nom que le concept parent", ang="Waiting for a script file name, with or without the full path to find it, containing if necessary the definition of an internal variable of the same name as the parent concept"),
),
+ DATA_DATA = BLOC ( condition = " FROM in ( 'DataFile', ) ",
+ DATA_FILE = SIMP(statut = "o", typ = ("FichierNoAbs",'CSV Text Files (*.csv);;TSV Text Files (*.tsv);;TXT Text Files (*.txt);;NPY Binary Numpy Files (*.npy);;NPZ Binary Numpy Files (*.npz);;All Files (*)", ',), validators=[OnlyStr(), FunctionVal(ColDataFileExtVal)], fr="En attente d'un nom de fichier de données, avec ou sans le chemin complet pour le trouver, contenant ou plusieurs colonnes pour définir un unique vecteur continu", ang="Waiting for a data file name, with or without the full path to find it, containing one or more columns to define a unique continuous vector"),
+ ),
STRING_DATA = BLOC ( condition = " FROM in ( 'String', ) ",
STRING = SIMP(statut = "o", typ = "TXM",{ms_default} fr="En attente d'une chaine de caractères entre guillements. Pour construire un vecteur ou une matrice, ce doit être une suite de nombres, utilisant un espace ou une virgule pour séparer deux éléments et un point-virgule pour séparer deux lignes", ang="Waiting for a string in quotes. To build a vector or a matrix, it has to be a float serie, using a space or comma to separate two elements in a line, a semi-colon to separate rows"),
),
<outport name="stored" type="bool"/>
</inline>
+ <inline name="CreateNumpyVectorFromDataFile">
+ <script><code><![CDATA[
+import logging, sys, os
+logging.debug("CREATE YI Entering in CreateNumpyVectorFromDataFile")
+type = "Vector"
+
+if sys.version_info.major > 2: import adao
+from daCore.Interfaces import ImportFromFile as aif
+vector = aif(script).getvalue(columns)[1]
+]]></code></script>
+ <inport name="script" type="string"/>
+ <inport name="columns" type="stringvec"/>
+ <outport name="vector" type="pyobj"/>
+ <outport name="type" type="string"/>
+ <outport name="stored" type="bool"/>
+ </inline>
+
<inline name="CreateNumpyVectorSerieFromString">
<script><code><![CDATA[
import numpy, logging
if __ifrom == 'Script':
__argumentsList.append([__itype,True])
__argumentsList.append(['Script',__idata['SCRIPT_FILE']])
+ if __ifrom == 'DataFile':
+ __argumentsList.append([__itype,True])
+ __argumentsList.append(['DataFile',__idata['DATA_FILE']])
if __ifrom == 'ScriptWithOneFunction':
__argumentsList.append(['OneFunction',True])
__argumentsList.append(['Script',__idata.pop('SCRIPTWITHONEFUNCTION_FILE')])
self._delimiter = ","
elif self.__filestring.count(";") > 1:
self._delimiter = ";"
+ else:
+ self._delimiter = None
elif self._format == "text/tab-separated-values" or Format.upper() == "TSV":
self._format = "text/tab-separated-values"
self._delimiter = "\t"
AssimType["ControlInput"] = ["Vector", "VectorSerie"]
FromNumpyList = {}
-FromNumpyList["Vector"] = ["String", "Script"]
+FromNumpyList["Vector"] = ["String", "Script", "DataFile"]
FromNumpyList["VectorSerie"] = ["String", "Script"]
FromNumpyList["Matrix"] = ["String", "Script"]
FromNumpyList["ScalarSparseMatrix"] = ["String", "Script"]
# Data input dict
DataTypeDict = {}
-DataTypeDict["Vector"] = ["String", "Script"]
+DataTypeDict["Vector"] = ["String", "Script", "DataFile"]
DataTypeDict["VectorSerie"] = ["String", "Script"]
DataTypeDict["Matrix"] = ["String", "Script"]
DataTypeDict["ScalarSparseMatrix"] = ["String", "Script"]
ADAO_Case.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
ADAO_Case.edAddDFLink(back_node.getOutputPort("stored"), CAS_node.getInputPort(key_stored))
+ if data_config["Type"] == "Vector" and data_config["From"] == "DataFile":
+ # Create node
+ factory_back_node = catalogAd.getNodeFromNodeMap("CreateNumpyVectorFromDataFile")
+ back_node = factory_back_node.cloneNode("Get" + key)
+ back_node.getInputPort("script").edInitPy(data_config["Data"])
+ back_node.getInputPort("columns").edInitPy((key,))
+ ADAO_Case.edAddChild(back_node)
+ # Set content of the node
+ back_node_script = back_node.getScript()
+ if "Stored" in data_config:
+ back_node_script += "stored = " + str(data_config["Stored"]) + "\n"
+ else:
+ back_node_script += "stored = 0\n"
+ if key in init_config["Target"]:
+ # Connect node with InitUserData
+ back_node_script += "__builtins__[\"init_data\"] = init_data\n"
+ back_node.edAddInputPort("init_data", t_pyobj)
+ ADAO_Case.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
+ back_node.setScript(back_node_script)
+ # Connect node with CreateAssimilationStudy
+ CAS_node.edAddInputPort(key, t_pyobj)
+ CAS_node.edAddInputPort(key_type, t_string)
+ CAS_node.edAddInputPort(key_stored, t_bool)
+ ADAO_Case.edAddDFLink(back_node.getOutputPort("vector"), CAS_node.getInputPort(key))
+ ADAO_Case.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
+ ADAO_Case.edAddDFLink(back_node.getOutputPort("stored"), CAS_node.getInputPort(key_stored))
+
if data_config["Type"] == "VectorSerie" and data_config["From"] == "String":
# Create node
factory_back_node = catalogAd.getNodeFromNodeMap("CreateNumpyVectorSerieFromString")