#! /usr/bin/env python import openturns as ot import openturns.testing import persalys import os myStudy = persalys.Study('myStudy') # Model 1 filename = 'data.csv' ot.RandomGenerator.SetSeed(0) ot.Normal(3).getSample(10).exportToCSVFile(filename) inColumns = [0, 2] model = persalys.DataModel('myDataModel', filename, inColumns) myStudy.add(model) print(model) print("inputNames=", model.getInputNames()) print("outputNames=", model.getOutputNames()) # Data analysis ## analysis = persalys.DataAnalysis("aDataAnalysis", model) myStudy.add(analysis) analysis.run() result = analysis.getResult() print("result=", result) print("PDF=", result.getPDF())
from __future__ import print_function import openturns as ot import openturns.testing import persalys import os myStudy = persalys.Study('myStudy') # data filename = 'données.csv' ot.RandomGenerator_SetSeed(0) ot.Normal(3).getSample(10).exportToCSVFile(filename) inColumns = [0, 2] # Model 1 model = persalys.DataModel('myDataModel', filename, inColumns) myStudy.add(model) print(model) # Model 2 model2 = persalys.SymbolicPhysicalModel( 'SM', [persalys.Input('A'), persalys.Input('B')], [persalys.Output('S')], ['A+B+2']) myStudy.add(model2) importedDOE = persalys.ImportedDesignOfExperiment('doeI', model2, filename, inColumns) myStudy.add(importedDOE) # script script = myStudy.getPythonScript() print(script)
# importDesign ## importDesign = persalys.ImportedDesignOfExperiment('importDesign', symbolicModel, 'data.csv', [0, 2, 3]) importDesign.run() myStudy.add(importDesign) # onePointDesign ## onePointDesign = persalys.GridDesignOfExperiment('onePointDesign', pythonModel) myStudy.add(onePointDesign) # twoPointsDesign ## twoPointsDesign = persalys.GridDesignOfExperiment('twoPointsDesign', pythonModel, [[0.2], [1.2], [-0.2, 1.]]) myStudy.add(twoPointsDesign) # fixed DataModel ## fixedDataModel = persalys.DataModel('fixedDataModel', fixedDesign.getOriginalInputSample(), fixedDesign.getResult().getDesignOfExperiment().getOutputSample()) myStudy.add(fixedDataModel) # imported DataModel ## importDataModel = persalys.DataModel('importDataModel', 'data.csv', [0, 2, 3], [1], ['x_0', 'x_2', 'x_3'], ['x_1']) myStudy.add(importDataModel) # model evaluation evaluation1 = persalys.ModelEvaluation('evaluation1', symbolicModel) myStudy.add(evaluation1) # morris ## try: morris = persalys.MorrisAnalysis('aMorris', symbolicModel) morris.setInterestVariables(['y0']) morris.setLevel(4)
import openturns.testing import persalys import os myStudy = persalys.Study('myStudy') # Model filename = 'data1.csv' ot.RandomGenerator.SetSeed(0) sample = ot.Normal(3).getSample(300) sample.stack(ot.Gumbel().getSample(300)) sample.setDescription(['X0', 'X1', 'X2', 'X3']) sample.exportToCSVFile(filename, ',') columns = [0, 2, 3] model = persalys.DataModel('myDataModel', "data1.csv", columns) myStudy.add(model) print(model) # Inference analysis ## analysis = persalys.InferenceAnalysis('analysis', model) variables = ["X0", "X3"] analysis.setInterestVariables(variables) factories = [ot.NormalFactory(), ot.GumbelFactory()] analysis.setDistributionsFactories("X3", factories) analysis.setLevel(0.1) myStudy.add(analysis) print(analysis) analysis.run()
model1 = persalys.SymbolicPhysicalModel( 'model1', [x1, x2, x3], [fake_var, y0, fake_y0, y1], [formula_fake_var, formula_y0, formula_y0, formula_y1]) myStudy.add(model1) # model 3 ## filename = 'data.csv' cDist = ot.ComposedDistribution( [ot.Normal(), ot.Gumbel(), ot.Normal(), ot.Uniform()], ot.ComposedCopula([ot.IndependentCopula(2), ot.GumbelCopula()])) sample = cDist.getSample(20) sample.exportToCSVFile(filename, ' ') model3 = persalys.DataModel('model3', 'data.csv', [0, 2, 3], [1], ['x_0', 'x_2', 'x_3'], ['x_1']) myStudy.add(model3) # Design of Experiment ## probaDesign = persalys.ProbabilisticDesignOfExperiment('probaDesign', model1, 20, "MONTE_CARLO") probaDesign.run() myStudy.add(probaDesign) # 1- meta model1 ## # 1-a Kriging ## kriging = persalys.KrigingAnalysis('kriging', probaDesign) kriging.setBasis(ot.LinearBasisFactory(2).build()) kriging.setCovarianceModel(ot.MaternModel(2))