Ejemplo n.º 1
0
def loop(a, level, parass, results, vers='2.9'):
    """
    New in 2.6: Makes an arbitrary number of loops
    a: dictionnary, with keys as parameters to loop on and values as the values on which to loop.
    level: list of parameters on which to loop. The first one is the most outer loop, the last one is the most inner loop.
    """
    if level==[]:
        rep, name= build_path(parass, vers=vers)
        with open(rep + name, 'r') as f:
            results=pickle.load(f)

        return results
    else:
        assert level[0] in a.keys()
        for i in a[level[0]]:
            parass.update(level[0],i)
            results[i]=loop(a, level[1:], parass, {}, vers=vers)
            
    return results
Ejemplo n.º 2
0
    """
    if level==[]:
        rep, name= build_path(parass, vers=vers)
        with open(rep + name, 'r') as f:
            results=pickle.load(f)

        return results
    else:
        assert level[0] in a.keys()
        for i in a[level[0]]:
            parass.update(level[0],i)
            results[i]=loop(a, level[1:], parass, {}, vers=vers)
            
    return results

if __name__=='__main__':

	paras = read_paras()
	
	G = paras['G']
	results = get_results(paras, vers='2.9')

	rep, name=build_path(paras, Gname = G.name)
	rep += '/critical_sectors'
	os.system('mkdir -p ' + rep)

	satisfactions = {n:v['satisfaction'][(1., 0., 1000.)]['avg'] for n,v in results.items()}
	satisfactions_res = {n:v['satisfaction_res'][(1., 0., 1000.)]['avg'] for n,v in results.items()}

	draw_critical_sectors(G, satisfactions, rep = rep, flip_axes = True, name = 'critical_sectors', show = False)
	draw_critical_sectors(G, satisfactions_res, rep = rep, flip_axes = True, name = 'critical_sectors_res')