1 #-*-coding:iso-8859-1-*-
3 # Copyright (C) 2008-2013 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
24 from daCore import BasicObjects, PlatformInfo
25 m = PlatformInfo.SystemUsage()
29 # ==============================================================================
30 class ElementaryAlgorithm(BasicObjects.Algorithm):
32 BasicObjects.Algorithm.__init__(self, "FUNCTIONTEST")
33 self.defineRequiredParameter(
37 message = "Titre du tableau et de la figure",
39 self.defineRequiredParameter(
43 message = "Activation du mode debug lors de l'exécution",
46 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
47 logging.debug("%s Lancement"%self._name)
48 logging.debug("%s Taille mémoire utilisée de %.1f Mo"%(self._name, m.getUsedMemory("M")))
50 self.setParameters(Parameters)
52 Hm = HO["Direct"].appliedTo
54 Xn = numpy.asmatrix(numpy.ravel( Xb )).T
57 if len(self._parameters["ResultTitle"]) > 0:
58 msg = " ====" + "="*len(self._parameters["ResultTitle"]) + "====\n"
59 msg += " " + self._parameters["ResultTitle"] + "\n"
60 msg += " ====" + "="*len(self._parameters["ResultTitle"]) + "====\n"
63 msg = "===> Information before launching:\n"
64 msg += " -----------------------------\n"
65 msg += " Characteristics of input vector X, internally converted:\n"
66 msg += " Type...............: %s\n"%type( Xn )
67 msg += " Lenght of vector...: %i\n"%max(numpy.matrix( Xn ).shape)
68 msg += " Minimum value......: %.5e\n"%numpy.min( Xn )
69 msg += " Maximum value......: %.5e\n"%numpy.max( Xn )
70 msg += " Mean of vector.....: %.5e\n"%numpy.mean( Xn )
71 msg += " Standard error.....: %.5e\n"%numpy.std( Xn )
72 msg += " L2 norm of vector..: %.5e\n"%numpy.linalg.norm( Xn )
75 if self._parameters["SetDebug"]:
76 CUR_LEVEL = logging.getLogger().getEffectiveLevel()
77 logging.getLogger().setLevel(logging.DEBUG)
78 print("===> Beginning of evaluation, activating debug\n")
80 print("===> Beginning of evaluation, without activating debug\n")
81 print(" %s\n"%("-"*75,))
83 print("===> Launching direct operator evaluation\n")
85 print("\n===> End of direct operator evaluation\n")
87 msg = "===> Information after launching:\n"
88 msg += " ----------------------------\n"
89 msg += " Characteristics of output vector Y, to compare to observation:\n"
90 msg += " Type...............: %s\n"%type( Y )
91 msg += " Lenght of vector...: %i\n"%max(numpy.matrix( Y ).shape)
92 msg += " Minimum value......: %.5e\n"%numpy.min( Y )
93 msg += " Maximum value......: %.5e\n"%numpy.max( Y )
94 msg += " Mean of vector.....: %.5e\n"%numpy.mean( Y )
95 msg += " Standard error.....: %.5e\n"%numpy.std( Y )
96 msg += " L2 norm of vector..: %.5e\n"%numpy.linalg.norm( Y )
99 print(" %s\n"%("-"*75,))
100 if self._parameters["SetDebug"]:
101 print("===> End evaluation, deactivating debug if necessary\n")
102 logging.getLogger().setLevel(CUR_LEVEL)
104 logging.debug("%s Taille mémoire utilisée de %.1f Mo"%(self._name, m.getUsedMemory("M")))
105 logging.debug("%s Terminé"%self._name)
109 # ==============================================================================
110 if __name__ == "__main__":
111 print '\n AUTODIAGNOSTIC \n'