show_simulation_curves.py 1.5 KB

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