def main(): """MAIN FUNCTION.""" cf, psa_mtd = get_psa_config() print('### START TO PARAMETERS SENSITIVITY ANALYSIS ###') start_t = time.time() cfg = PSAConfig(cf, method=psa_mtd) saobj = Sensitivity(cfg) saobj.run() print('### END OF PARAMETERS SENSITIVITY ANALYSIS ###') print('Running time: %.2fs' % (time.time() - start_t)) # Plot figures saobj.plot()
def write_sensitivity_config_file(mpaths, org_file_name): org_cfg_file = mpaths.cfg_dir + os.path.sep + org_file_name psa_cfg_file = mpaths.workspace + os.path.sep + org_file_name cfg_items = list() with open(org_cfg_file, 'r', encoding='utf-8') as f: for line in f.readlines(): cfg_items.append(line.strip()) cfg_items.append('MODEL_DIR = %s' % mpaths.model_dir) cfg_items.append('BIN_DIR = %s' % mpaths.bin_dir) with open(psa_cfg_file, 'w', encoding='utf-8') as f: for item in cfg_items: f.write('%s\n' % item) cf = ConfigParser() cf.read(psa_cfg_file) return PSAConfig(cf)
if 'NSE' in objn: # NSE series, i.e., NSE, lnNSE, NSE1, and NSE3 empirical_cdf(values, [0], self.param_values, param_names, self.cfg.morris.num_levels, self.cfg.psa_outpath, 'cdf_%s' % self.objnames[i], {'histtype': 'step'}) elif 'R-square' in objn: # R-square, equally divided as two classes empirical_cdf(values, 2, self.param_values, param_names, self.cfg.morris.num_levels, self.cfg.psa_outpath, 'cdf_%s' % self.objnames[i], {'histtype': 'step'}) elif 'RSR' in objn: # RSR empirical_cdf(values, [1], self.param_values, param_names, self.cfg.morris.num_levels, self.cfg.psa_outpath, 'cdf_%s' % self.objnames[i], {'histtype': 'step'}) if __name__ == '__main__': from config import get_psa_config cf, method = get_psa_config() cfg = PSAConfig(cf, method=method) print(cfg.param_range_def) saobj = Sensitivity(cfg) saobj.write_param_values_to_mongodb() # saobj.calculate_sensitivity() # saobj.plot_samples_histogram() # saobj.plot_morris()