<inport name="script" type="string"/>
</inline>
+ <inline name="InitUserDataFromScript">
+ <script><code><![CDATA[
+print "Entering in InitUserDataFromScript"
+execfile(script)
+]]></code></script>
+ <inport name="script" type="string"/>
+ <outport name="init_data" type="pyobj"/>
+ </inline>
+
</proc>
CAS_node.getInputPort("Algorithm").edInitPy(study_config["Algorithm"])
proc.edAddChild(CAS_node)
+ # Step 0.5: Find if there is a user init node
+ init_config = {}
+ init_config["Target"] = []
+ if "Init" in study_config.keys():
+ init_config = study_config["Init"]
+ factory_init_node = catalogAd._nodeMap["InitUserDataFromScript"]
+ init_node = factory_init_node.cloneNode("InitUserData")
+ init_node.getInputPort("script").edInitPy(init_config["Data"])
+ proc.edAddChild(init_node)
+
# Step 1: get input data from user configuration
for key in study_config.keys():
# Connect node with CreateAssimilationStudy
CAS_node.edAddInputPort(key, t_pyobj)
proc.edAddDFLink(back_node.getOutputPort(key), CAS_node.getInputPort(key))
+ # Connect node with InitUserData
+ if key in init_config["Target"]:
+ back_node.edAddInputPort("init_data", t_pyobj)
+ proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
if data_config["Type"] == "Vector" and data_config["From"] == "String":
# Create node
CAS_node.edAddInputPort(key_type, t_string)
proc.edAddDFLink(back_node.getOutputPort("vector"), CAS_node.getInputPort(key))
proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
+ # Connect node with InitUserData
+ if key in init_config["Target"]:
+ back_node.edAddInputPort("init_data", t_pyobj)
+ proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
if data_config["Type"] == "Vector" and data_config["From"] == "Script":
# Create node
CAS_node.edAddInputPort(key_type, t_string)
proc.edAddDFLink(back_node.getOutputPort(key), CAS_node.getInputPort(key))
proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
+ # Connect node with InitUserData
+ if key in init_config["Target"]:
+ back_node.edAddInputPort("init_data", t_pyobj)
+ proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
if data_config["Type"] == "Matrix" and data_config["From"] == "String":
# Create node
CAS_node.edAddInputPort(key_type, t_string)
proc.edAddDFLink(back_node.getOutputPort("matrix"), CAS_node.getInputPort(key))
proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
+ # Connect node with InitUserData
+ if key in init_config["Target"]:
+ back_node.edAddInputPort("init_data", t_pyobj)
+ proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
if data_config["Type"] == "Matrix" and data_config["From"] == "Script":
# Create node
CAS_node.edAddInputPort(key_type, t_string)
proc.edAddDFLink(back_node.getOutputPort(key), CAS_node.getInputPort(key))
proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
+ # Connect node with InitUserData
+ if key in init_config["Target"]:
+ back_node.edAddInputPort("init_data", t_pyobj)
+ proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
if data_config["Type"] == "Function" and data_config["From"] == "Dict" and key == "ObservationOperator":
FunctionDict = data_config["Data"]
proc.edAddDFLink(optimizer_node.edGetSamplePort(), opt_script_node.getInputPort("computation"))
proc.edAddDFLink(opt_script_node.getOutputPort("result"), optimizer_node.edGetPortForOutPool())
+ # Connect node with InitUserData
+ if "ObservationOperator" in init_config["Target"]:
+ opt_script_node.edAddInputPort("init_data", t_pyobj)
+ proc.edAddDFLink(init_node.getOutputPort("init_data"), opt_script_node.getInputPort("init_data"))
+
else:
factory_opt_script_node = catalogAd._nodeMap["FakeOptimizerLoopNode"]
opt_script_node = factory_opt_script_node.cloneNode("FakeFunctionNode")
Init_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_init_parameters.py"
Init_config["Type"] = "Dict"
Init_config["From"] = "Script"
-Init_config["Target"] = ["Algorithm"]
+Init_config["Target"] = ["AlgorithmParameters", "Background", "BackgroundError",
+ "Observation", "ObservationError", "ObservationOperator"]
study_config["Init"] = Init_config
Algorithm_config = {}
ObservationOperator_config["From"] = "Dict"
study_config["ObservationOperator"] = ObservationOperator_config
+Analysis_config = {}
+Analysis_config["Data"] = """
+import numpy
+
+Xa = ADD.get("Analysis").valueserie(0)
+print "Analyse = ",Xa
+"""
+Analysis_config["From"] = "String"
+study_config["Analysis"] = Analysis_config
def get_tables(tables_calc,tmp_repe_table,prof):
""" Recupere les resultats Aster (Table Aster -> Numeric Python)
"""
+ global debug
import Numeric
assert (tables_calc is not None)
assert (tmp_repe_table is not None)
message = "Erreur 3!\n" + str(err)
UTMESS('F', message)
resu_calc = Lrep
- from N_Parameters import debug
if debug: print 'resu_calc:', resu_calc
return resu_calc
#===============================================================================
def Calcul_Aster_Ponctuel( X0 = None ):
#
+ global ASTER_ROOT
+ global debug
+ global SOURCES_ROOT
+ global export
+ global calcul
+ global parametres
+ global python_version
+
import numpy
if type(X0) is type(numpy.matrix([])):
X0 = X0.A1.tolist()
X0 = list(X0)
# ----------------------------------------------------------------------------
# Parametres
- isFromYacs = globals().get('ASTER_ROOT', None) # execution via YACS ou en externe
- if not isFromYacs:
- from N_Parameters import ASTER_ROOT, debug, SOURCES_ROOT, DISPLAY
- from N_Study_Parameters import export
- from N_MR_Parameters import calcul, parametres
+ #isFromYacs = globals().get('ASTER_ROOT', None) # execution via YACS ou en externe
+ #isFromYacs = ASTER_ROOT
+ #print "isFromYacs:", isFromYacs
+ #if not isFromYacs:
+ # from N_Parameters import ASTER_ROOT, debug, SOURCES_ROOT, DISPLAY
+ # from N_Study_Parameters import export
+ # from N_MR_Parameters import calcul, parametres
os.environ['ASTER_ROOT'] = ASTER_ROOT
# ----------------------------------------------------------------------------
#===============================================================================
def Calcul_Aster_Jacobienne( X0 = None ):
+ global ASTER_ROOT
+ global debug
+ global SOURCES_ROOT
+ global export
+ global calcul
+ global parametres
+ global python_version
#
import numpy
if type(X0) is type(numpy.matrix([])):
# dX = globals().get('dX', [ 0.1, 0.1, 0.001]) # execution via YACS ou en externe
# ----------------------------------------------------------------------------
# Parametres
- isFromYacs = globals().get('ASTER_ROOT', None) # execution via YACS ou en externe
- if not isFromYacs:
- from N_Parameters import ASTER_ROOT, debug, SOURCES_ROOT, DISPLAY
- from N_Study_Parameters import export
- from N_MR_Parameters import calcul, parametres
+ #isFromYacs = globals().get('ASTER_ROOT', None) # execution via YACS ou en externe
+ #if not isFromYacs:
+ # from N_Parameters import ASTER_ROOT, debug, SOURCES_ROOT, DISPLAY
+ # from N_Study_Parameters import export
+ # from N_MR_Parameters import calcul, parametres
os.environ['ASTER_ROOT'] = ASTER_ROOT
# ----------------------------------------------------------------------------
+#-*-coding:iso-8859-1-*-
+import numpy
debug = init_data["debug"]
parametres = init_data["parametres"]
+#-*-coding:iso-8859-1-*-
+import numpy
parametres = init_data["parametres"]
xb = []
B[0,0] = alpha * 100
B[1,1] = alpha * 10
B[2,2] = alpha * 1
-dimensionXb = len( Xb )
+dimensionXb = len( xb )
B = numpy.matrix( B, numpy.float ).reshape((dimensionXb,dimensionXb))
BackgroundError = B
import numpy
import pickle
+import sys
+
+sys.path.insert(0, init_data['SOURCES_ROOT'])
import test_aster_zzzz159a_aster_functions as Code_Aster
# Configuration du module
init_data['ASTER_ROOT'] = os.environ['ASTER_ROOT']
init_data['debug'] = False
init_data['python_version'] = "python@PYTHON_VERSION@"
+init_data['SOURCES_ROOT'] = "@prefix@" + '/tests/daSalome'
# Partie contenant les parametres de l'étude
-export=os.environ["ADAO_ROOT_DIR"] + '/tests/daSalome/zzzz159a.export.esclave'
+init_data['export'] = "@prefix@" + '/tests/daSalome/zzzz159a.export.esclave'
import Numeric
parametres =[['YOUN__',100000.,50000.,500000.],['DSDE__',1000.,500.,10000.],['SIGY__',30.,5.,500.]]
+#-*-coding:iso-8859-1-*-
+import numpy
debug = init_data["debug"]
experience = init_data["experience"]
+#-*-coding:iso-8859-1-*-
+import numpy
experience = init_data["experience"]
nbmesures = 11 # De 0 à 1 par pas de 0.1
instants = numpy.array([0.1*i for i in range(nbmesures)])
yo.append(v)
R = numpy.matrix(numpy.core.identity(len(yo)))
-dimensionYo = len( Yo )
+dimensionYo = len( yo )
R = numpy.matrix( R, numpy.float ).reshape((dimensionYo,dimensionYo))
+
+ObservationError = R