Exemple #1
0
    def loadDict(self, sd):
        self.model = Model()
        try:
            self.model.loadDict(sd['model'])
        except:
            pass

        self.setID(sd.get('ID', ''))
        self.setNumSamples(sd.get('numSamples', 0))
        self.origNumSamples = sd.get('origNumSamples', self.getNumSamples())
        self.setNumSamplesAdded(sd.get('numSamplesAdded', 0))
        self.setFromFile(sd.get('fromFile', False))
        self.setSampleMethod(sd.get('sampleMethod', None))
        self.setInputData(sd.get('inputData', None))
        self.setOutputData(sd.get('outputData', None))
        self.setRunState(sd.get('runState', None))
        self.legendreOrder = sd.get('legendreOrder', None)
        self.fromFile = sd.get('fromFile', False)
        self.sampleRSType = ResponseSurfaces.getEnumValue(
            sd.get('sampleRSType'))
        self.turbineJobIds = sd.get("turbineJobIds", [])
        self.turbineSession = sd.get("turbineSession", None)
        self.turbineResub = sd.get("turbineResub", [])
        inputDists = []
        if 'inputDists' in sd:
            for distDict in sd['inputDists']:
                distr = Distribution(Distribution.UNIFORM)
                distr.loadDict(distDict)
                inputDists.append(distr)
        self.setInputDistributions(inputDists)
        self.analyses = []
        if 'analyses' in sd:
            for analDict in sd['analyses']:
                type = UQAnalysis.getTypeEnumValue(analDict['type'])
                if type == UQAnalysis.PARAM_SCREEN:
                    from ParameterScreening import ParameterScreening
                    anal = ParameterScreening(self, analDict['outputs'],
                                              analDict['subType'])
                elif type == UQAnalysis.UNCERTAINTY:
                    from UncertaintyAnalysis import UncertaintyAnalysis
                    anal = UncertaintyAnalysis(self, analDict['outputs'])
                elif type == UQAnalysis.CORRELATION:
                    from CorrelationAnalysis import CorrelationAnalysis
                    anal = CorrelationAnalysis(self, analDict['outputs'])
                elif type == UQAnalysis.SENSITIVITY:
                    from SensitivityAnalysis import SensitivityAnalysis
                    anal = SensitivityAnalysis(self, analDict['outputs'],
                                               analDict['subType'])
                elif type == UQAnalysis.VISUALIZATION:
                    from Visualization import Visualization
                    anal = Visualization(self, analDict['outputs'],
                                         analDict['inputs'])
                else:  #RS Analyses
                    userRegressionFile = analDict[
                        'userRegressionFile'] if 'userRegressionFile' in analDict else None
                    if type == UQAnalysis.RS_VALIDATION:
                        from RSValidation import RSValidation
                        testFile = analDict[
                            'testFile'] if 'testFile' in analDict else None
                        anal = RSValidation(self, analDict['outputs'],
                                            analDict['rs'],
                                            analDict['rsOptions'],
                                            analDict['genCodeFile'],
                                            analDict['nCV'],
                                            userRegressionFile, testFile)
                    elif type == UQAnalysis.RS_UNCERTAINTY:
                        from RSUncertaintyAnalysis import RSUncertaintyAnalysis
                        anal = RSUncertaintyAnalysis(self, analDict['outputs'],
                                                     analDict['subType'],
                                                     analDict['rs'],
                                                     analDict['rsOptions'],
                                                     userRegressionFile,
                                                     analDict['xprior'])
                    elif type == UQAnalysis.RS_SENSITIVITY:
                        from RSSensitivityAnalysis import RSSensitivityAnalysis
                        anal = RSSensitivityAnalysis(self, analDict['outputs'],
                                                     analDict['subType'],
                                                     analDict['rs'],
                                                     analDict['rsOptions'],
                                                     userRegressionFile,
                                                     analDict['xprior'])
                    elif type == UQAnalysis.INFERENCE:
                        from RSInference import RSInference
                        anal = RSInference(
                            self,
                            analDict['ytable'],
                            analDict['xtable'],
                            analDict['obsTable'],
                            analDict['genPostSample'],
                            analDict['addDisc'],
                            analDict['showList'],
                            userRegressionFile=userRegressionFile)
                    elif type == UQAnalysis.RS_VISUALIZATION:
                        from RSVisualization import RSVisualization
                        anal = RSVisualization(
                            self, analDict['outputs'], analDict['inputs'],
                            analDict['rs'], analDict['minVal'],
                            analDict['maxVal'], analDict['rsOptions'],
                            userRegressionFile)

                anal.loadDict(analDict)
                self.analyses.append(anal)