Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import os
- import glob
- import matplotlib.pyplot as plt
- path = '/Users/ammacpro1/simulation_results/self_energy_robot/test11/test11FiniteTroph/Bots25Boundary10Maxfood1000_2017-12-26000629243/plot_data/*Estored*txt'
- #path = '/Users/ammacpro1/AnacondaProjects/result_increase_initial_energy/Troph_UTLT_average/UT50LT20/InFiniteTroph/Bots25Boundary10Maxfood1000_2017-12-26000629243/plot_data/*Estored*txt'
- files = glob.glob(path)
- totalfrequency = np.zeros((28, 28), dtype=np.int8)
- totalenergy = np.zeros((28, 28), dtype=np.int8)
- for file in files:
- for line in open(file, 'r'):
- robot = line.rstrip('\n').split(' ')
- #robot = map(int, robot) #python2
- robot = list(map(int, robot)) #python3
- totalfrequency[robot[0], robot[1]] = totalfrequency[robot[0], robot[1]] + 1
- totalenergy[robot[0], robot[1]] = totalenergy[robot[0], robot[1]] + robot[2]
- plt.matshow(totalfrequency, cmap='terrain_r', vmin = 0)
- plt.title('Frequency')
- plt.colorbar()
- #plt.matshow(totalenergy, cmap='hot', vmin = 0)
- #plt.title('Energy')
- #plt.colorbar()
- plt.show()
- #Energy
- #total = np.zeros((100, 100), dtype=np.int8)
- #
- #for file in files:
- # for line in open(file, 'r'):
- # robot = line.rstrip('\n').split(' ')
- # #robot = map(int, robot) #python2
- # robot = list(map(int, robot)) #python3
- # total[robot[0], robot[1]] = total[robot[0], robot[1]] + robot[2]
- #
- #
- #plt.matshow(total)
- #plt.colorbar()
- #plt.show()
Add Comment
Please, Sign In to add comment