Queen4

Work Program 2 for Topcon

Dec 13th, 2020 (edited)
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2.  
  3. SNR = {}
  4. file = open('SNR.txt', 'r')
  5. for line in file:
  6.     s = line.split()
  7.     if len(s) > 1 and s[8] != "0.0":
  8.         num = s[4]
  9.         dot_time = s[8]
  10.         time = float(dot_time)
  11.         if num not in SNR.keys():
  12.             SNR[num] = [time]
  13.         elif num in SNR.keys():
  14.             SNR[num].append(time)
  15. sorted_SNR = {key: SNR[key] for key in sorted(SNR)}
  16.  
  17. print('Введите SNR для демонстрации: ' + ', '.join(sorted_SNR.keys()) + '\n')
  18. num_of_snr = input()
  19. times = sorted_SNR[num_of_snr]
  20. dict_of_times = {key: 0 for key in set(times)}
  21. counts = []
  22. for key in dict_of_times:
  23.     dict_of_times[key] = times.count(key)
  24.     counts.append(dict_of_times[key])
  25.  
  26. plt.bar(dict_of_times.keys(), counts, width=0.6)
  27. plt.xlabel('Время')
  28. plt.ylabel('Кол-во повторений')
  29. #plt.show()
  30. plt.title('SNR%s' % num_of_snr)
  31. plt.savefig('SNR%s.png' % num_of_snr)
  32. plt.show()
  33.  
Add Comment
Please, Sign In to add comment