-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_peak.py
More file actions
executable file
·62 lines (50 loc) · 2.23 KB
/
Copy pathplot_peak.py
File metadata and controls
executable file
·62 lines (50 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
# ==========================================
# CONFIGURATION ET CHARGEMENT
# ==========================================
FILE_NAME = "find_peak_results.csv"
try:
df = pd.read_csv(FILE_NAME)
except FileNotFoundError:
print(f"Erreur : Le fichier '{FILE_NAME}' est introuvable.")
exit()
# Nettoyage des données au cas où il y aurait des lignes vides
df = df.dropna()
# Identification du pic maximum
idx_max = df['bits_adc'].idxmax()
peak_pas = df.loc[idx_max, 'pas_relatif']
peak_bits = df.loc[idx_max, 'bits_adc']
peak_mv = df.loc[idx_max, 'tension_mv']
print(f"--- ANALYSE DU PIC ---")
print(f"Position (Pas relatif) : {peak_pas}")
print(f"Intensité brute : {peak_bits} bits")
print(f"Tension calculée : {peak_mv:.4f} mV")
# ==========================================
# VISUALISATION
# ==========================================
fig, ax1 = plt.subplots(figsize=(12, 7))
# --- Courbe 1 : Bits ADC (Axe de gauche) ---
color_bits = 'tab:purple'
ax1.set_xlabel('Pas Relatif (référentiel find_peak)')
ax1.set_ylabel('Intensité (Bits ADC)', color=color_bits, fontweight='bold')
ax1.plot(df['pas_relatif'], df['bits_adc'], color=color_bits, linewidth=1.5, label='Bits ADC')
ax1.tick_params(axis='y', labelcolor=color_bits)
ax1.grid(True, which='both', linestyle='--', alpha=0.5)
# --- Axe 2 : Tension mV (Axe de droite) ---
ax2 = ax1.twinx()
color_mv = 'tab:blue'
ax2.set_ylabel('Tension (mV)', color=color_mv, fontweight='bold')
ax2.plot(df['pas_relatif'], df['tension_mv'], color=color_mv, alpha=0.3, linestyle='--')
ax2.tick_params(axis='y', labelcolor=color_mv)
# --- Annotation du Pic ---
ax1.annotate(f'MAX\nPas: {peak_pas}\n{peak_bits} bits',
xy=(peak_pas, peak_bits),
xytext=(peak_pas + 2000, peak_bits * 0.9),
arrowprops=dict(facecolor='black', shrink=0.05, width=1, headwidth=8),
fontsize=10, fontweight='bold', bbox=dict(boxstyle="round,pad=0.3", fc="white", ec="black", alpha=0.8))
# --- Esthétique générale ---
plt.title(f"Analyse find_peak - Identification du Maximum Physique", fontsize=14, fontweight='bold', pad=20)
fig.tight_layout()
plt.show()