Commit 1f617266 authored by Dumoulin Nicolas's avatar Dumoulin Nicolas
Browse files

bugfix in indicators labels + better input data copying

parent 72de1a7f
......@@ -64,7 +64,7 @@ class Indicators:
self.indicators_names.append(cultgeopat)
def compute_indicators(self, patches):
return [ind.compute_indicator(patches) for ind in self._indicators.values()]
return [self._indicators[ind].compute_indicator(patches) for ind in self.indicators_names]
def compute_indicators_pool(self, scenarios):
rows=[]
......@@ -79,6 +79,13 @@ class MCMC:
print('Please copy the template file "MCMC_config.sample.yml" and adjust to your settings and run again this program')
sys.exit(1)
self.mcmc_config = yaml.load(open(mcmc_config_filename,'r'))
self.patches_md5sum = md5sum(self.mcmc_config['patches'])
if 'rng_seed' in self.mcmc_config:
self.rng = np.random.RandomState(self.mcmc_config['rng_seed'])
else:
self.rng = np.random.RandomState(42)
print('MCMC initialized with default seed') # self.rng.get_state()
# Copying input data in output dir
self.outputdir = self.mcmc_config['output_dir'] + '/' + time.strftime('%Y%m%d-%H%M%S') + '/'
if not os.path.exists(self.outputdir):
os.makedirs(self.outputdir)
......@@ -87,19 +94,18 @@ class MCMC:
print('Output directory already exists! ({})'.format(self.outputdir))
sys.exit(1)
shutil.copy(mcmc_config_filename, self.outputdir)
for f in [ self.mcmc_config['patches'], self.mcmc_config['target'],
for f in [ self.mcmc_config['target'],
self.mcmc_config['indicators_config']['resilience'],
self.mcmc_config['indicators_config']['biodiversity']['matrixfilename'],
self.mcmc_config['indicators_config']['social']['cost_matrix_filename'],
self.mcmc_config['indicators_config']['social']['patches_costs_filename']
]:
shutil.copy(f, self.outputdir)
if 'rng_seed' in self.mcmc_config:
self.rng = np.random.RandomState(self.mcmc_config['rng_seed'])
else:
self.rng = np.random.RandomState(42)
print('MCMC initialized with default seed') # self.rng.get_state()
self.patches_md5sum = md5sum(self.mcmc_config['patches'])
with open(self.outputdir+'/seed.txt', 'w') as outfile:
outfile.write('{}\n'.format(self.rng.get_state()))
with open(self.outputdir+'/config.yml', 'w') as outfile:
yaml.dump({'patches_md5sum':self.patches_md5sum}, outfile, default_flow_style=False)
# finishing init
self.patches = load_pat_patches(self.mcmc_config['patches'])
self.target = pd.read_csv(self.mcmc_config['target'], sep=';',index_col=0)
targetRatio = (self.target['2050']-self.target['2016'])/self.target['2016']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment