show_simulation_curves.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import numpy as np
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4. import os, sys
  5. label_freq = 6
  6. folder_path = "Curve_simulations"
  7. data_files = os.listdir(folder_path)
  8. scene_names = [f.split('_')[3] for f in data_files]
  9. for id, f in enumerate(data_files):
  10. print(scene_names[id])
  11. path_file = os.path.join(folder_path, f)
  12. df = pd.read_csv(path_file, header=None, sep=";")
  13. fig=plt.figure(figsize=(8, 8))
  14. fig.suptitle("Detection simulation for " + scene_names[id] + " scene", fontsize=20)
  15. for index, row in df.iterrows():
  16. row = np.asarray(row)
  17. threshold = row[2]
  18. start_index = row[3]
  19. step_value = row[4]
  20. counter_index = 0
  21. current_value = start_index
  22. while(current_value < threshold):
  23. counter_index += 1
  24. current_value += step_value
  25. fig.add_subplot(4, 4, (index + 1))
  26. plt.plot(row[5:])
  27. # draw vertical line from (70,100) to (70, 250)
  28. plt.plot([counter_index, counter_index], [-2, 2], 'k-', lw=2, color='red')
  29. plt.ylabel('Not noisy / Noisy', fontsize=18)
  30. plt.xlabel('Time in minutes / Samples per pixel', fontsize=16)
  31. x_labels = [id * step_value + start_index for id, val in enumerate(row[5:]) if id % label_freq == 0]
  32. x = [v for v in np.arange(0, len(row[5:])+1) if v % label_freq == 0]
  33. plt.xticks(x, x_labels, rotation=45)
  34. plt.ylim(-1, 2)
  35. plt.show()