From ed3e5c44caa42791503342db929034f2a7043eea Mon Sep 17 00:00:00 2001
From: faridm69 <faridmohammadi69@gmail.com>
Date: Sat, 25 Jul 2020 12:48:18 +0200
Subject: [PATCH] [surrogate] added name argument for calib or valid strings.

---
 BayesValidRox/BayesInference/BayesInference.py     | 8 ++++----
 BayesValidRox/PostProcessing/PostProcessing.py     | 2 +-
 BayesValidRox/surrogate_models/surrogate_models.py | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/BayesValidRox/BayesInference/BayesInference.py b/BayesValidRox/BayesInference/BayesInference.py
index f48f67a5e..ebbdd80f9 100644
--- a/BayesValidRox/BayesInference/BayesInference.py
+++ b/BayesValidRox/BayesInference/BayesInference.py
@@ -258,7 +258,7 @@ class BayesInference:
         NrofBayesSamples = self.NrofSamples
         # Evaluate PCEModel on the experimental design
         Samples = PCEModel.ExpDesign.X
-        OutputRS, stdOutputRS = PCEModel.eval_metamodel(samples=Samples)
+        OutputRS, stdOutputRS = PCEModel.eval_metamodel(samples=Samples,name=self.Name)
         
         # Reset the NrofSamples to NrofBayesSamples
         self.NrofSamples = NrofBayesSamples
@@ -415,7 +415,7 @@ class BayesInference:
         # Prior predictive
         if self.emulator:
             PriorPred = self.meanPCEPriorPred
-            PosteriorPred, _ = PCEModel.eval_metamodel(samples=Posterior_df.to_numpy())
+            PosteriorPred, _ = PCEModel.eval_metamodel(samples=Posterior_df.to_numpy(),name=self.Name)
         else:
             PriorPred = self.ModelPriorPred
             PosteriorPred = self.eval_Model(Samples=Posterior_df.to_numpy())
@@ -559,7 +559,7 @@ class BayesInference:
                 # ---------------- Likelihood calculation ---------------- 
                 if self.emulator:
                     # Evaluate the PCEModel
-                    self.meanPCEPriorPred, self.stdPCEPriorPred = PCEModel.eval_metamodel(samples=self.Samples)
+                    self.meanPCEPriorPred, self.stdPCEPriorPred = PCEModel.eval_metamodel(samples=self.Samples,name=self.Name)
                     
                     # unknown sigma2
                     if optSigma == 'C':
@@ -622,7 +622,7 @@ class BayesInference:
         if self.PlotPostPred:
             # Run the models for MAP
             # PCEModel
-            MAP_PCEModel, MAP_PCEModelstd = PCEModel.eval_metamodel(samples=MAP_theta)
+            MAP_PCEModel, MAP_PCEModelstd = PCEModel.eval_metamodel(samples=MAP_theta,name=self.Name)
             self.MAPpceModelMean = MAP_PCEModel
             self.MAPpceModelStd = MAP_PCEModelstd
             
diff --git a/BayesValidRox/PostProcessing/PostProcessing.py b/BayesValidRox/PostProcessing/PostProcessing.py
index 3fa0d9ac4..109c1ff93 100644
--- a/BayesValidRox/PostProcessing/PostProcessing.py
+++ b/BayesValidRox/PostProcessing/PostProcessing.py
@@ -272,7 +272,7 @@ class PostProcessing:
         Samples = self.get_Sample()
         
         self.eval_Model(Samples)
-        self.PCEOutputs, self.PCEOutputs_std = metaModel.eval_metamodel(samples=Samples)
+        self.PCEOutputs, self.PCEOutputs_std = metaModel.eval_metamodel(samples=Samples,name=self.Name)
         
         if self.plotFlag == True:
             try:
diff --git a/BayesValidRox/surrogate_models/surrogate_models.py b/BayesValidRox/surrogate_models/surrogate_models.py
index 56b7ff91d..d13ec4b67 100644
--- a/BayesValidRox/surrogate_models/surrogate_models.py
+++ b/BayesValidRox/surrogate_models/surrogate_models.py
@@ -2003,7 +2003,7 @@ class Metamodel:
         return Xnew
     
     #--------------------------------------------------------------------------------------------------------
-    def eval_metamodel(self,samples=None, nsamples=None, samplingMethod='random', return_samples=False):
+    def eval_metamodel(self,samples=None, nsamples=None, samplingMethod='random', name='Calib', return_samples=False):
         
         ModelDict = self.gp_poly if self.metaModel.lower() == 'gpe' else self.CoeffsDict 
         
@@ -2071,7 +2071,7 @@ class Metamodel:
                     stdPCEOutputs[Outkey] = PCEOutputs_std
             else:
                 index = self.index
-                if self.Name.lower() == 'calib':
+                if name.lower() == 'calib':
                     if self.DimRedMethod.lower() == 'pca':
                         PCA = self.pca[Outkey]
                         meanPCEOutputs[Outkey] = PCA.mean_[:index] + np.dot(PCEOutputs_mean,PCA.components_)[:,:index]
-- 
GitLab