if sys.version_info.major > 2:
def unicode(text, encoding='utf-8'): return text
+print("-- Starting AdaoCalatogGenerator.py --")
+
+try:
+ import adao
+ import daEficas
+ import daYacsSchemaCreator
+ import daCore.AssimilationStudy
+ import daYacsSchemaCreator.infos_daComposant as infos
+except:
+ logging.fatal("Import of ADAO python modules failed !" +
+ "\n add ADAO python installation directory in your PYTHONPATH")
+ traceback.print_exc()
+ sys.exit(1)
+
#----------- Templates Part ---------------#
begin_catalog_file = """# -*- coding: utf-8 -*-
#
TEMPLATE_DATA = BLOC (condition = " FROM in ( 'Template', ) ",
Template = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "AnalysisPrinter", into=("AnalysisPrinter", "AnalysisSaver", "AnalysisPrinterAndSaver")),
AnalysisPrinter = BLOC (condition = " Template == 'AnalysisPrinter' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nprint 'Analysis:',xa" ),
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nprint('Analysis:',xa)" ),
),
AnalysisSaver = BLOC (condition = " Template == 'AnalysisSaver' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nf='/tmp/analysis.txt'\\nprint 'Analysis saved in \\"%s\\"'%f\\nnumpy.savetxt(f,xa)" ),
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nf='/tmp/analysis.txt'\\nprint('Analysis saved in \\"%s\\"'%f)\\nnumpy.savetxt(f,xa)" ),
),
AnalysisPrinterAndSaver = BLOC (condition = " Template == 'AnalysisPrinterAndSaver' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nprint 'Analysis:',xa\\nf='/tmp/analysis.txt'\\nprint 'Analysis saved in \\"%s\\"'%f\\nnumpy.savetxt(f,xa)" ),
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nprint 'Analysis:',xa\\nf='/tmp/analysis.txt'\\nprint('Analysis saved in \\"%s\\"'%f)\\nnumpy.savetxt(f,xa)" ),
),
),
)
#----------- Begin generation script -----------#
-print("-- Starting AdaoCalatogGenerator.py --")
-
-try:
- import daEficas
- import daYacsSchemaCreator
- import daCore.AssimilationStudy
- import daYacsSchemaCreator.infos_daComposant as infos
-except:
- logging.fatal("Import of ADAO python modules failed !" +
- "\n add ADAO python installation directory in your PYTHONPATH")
- traceback.print_exc()
- sys.exit(1)
# Parse arguments
from argparse import ArgumentParser
import SALOMERuntime
import pilot
-import cPickle
+try:
+ import cPickle as pickle
+except:
+ import pickle
import numpy
import threading
#print "[Debug] Input is ", input
str_da_study = input.getStringValue()
try:
- self.da_study = cPickle.loads(str_da_study)
+ self.da_study = pickle.loads(str_da_study)
except ValueError as e:
raise ValueError("\n\n Handling internal error in study exchange (message: \"%s\").\n The case is probably too big (bigger than the physical plus the virtual memory available).\n Try if possible to store the covariance matrices in sparse format.\n"%(str(e),))
#print "[Debug] da_study is ", self.da_study
# Remove Data Observer, so you can ...
var.removeDataObserver(self.obs)
# Pickle then ...
- var_str = cPickle.dumps(var)
+ var_str = pickle.dumps(var)
# Add Again Data Observer
if self.da_study.observers_dict[info]["scheduler"] != "":
self.ADD.setObserver(Variable = info, ObjectFunction = self.obs, Scheduler = self.da_study.observers_dict[info]["scheduler"], Info = info)
# for observer_name in list(self.da_study.observers_dict.keys()):
# self.ADD.removeDataObserver(observer_name, self.obs)
self.da_study.YI_prepare_to_pickle()
- result = cPickle.dumps(self.da_study)
+ result = pickle.dumps(self.da_study)
return result
# Obligatoire ???