121 KiB
Executable File
121 KiB
Executable File
In [1]:
import plotly.express as px
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import linregress
import scipy.optimize as opt
import scipy.special as spc
import scipy.constants as const
import sympy as sp
from sympy import symbols, Eq, solve, diff, lambdifyIn [2]:
DP = pd.DataFrame(
{
'U': [300, 325, 350, 375, 400, 425, 450, 475, 500, 525, 550, 575, 600, 625, 650, 675, 700, 725, 750, 775, 800, 825, 850, 875],
'N': [0, 0, 0, 0, 0, 0, 0, 0, 944, 967, 1002, 1066, 1027, 993, 1064, 1031, 1102, 1074, 1112, 1099, 1181, 1185, 1235, 1293],
'N_err': [np.nan]*24
}
)
DP['N_err'] = np.sqrt(DP['N'])
DPOut [2]:
| U | N | N_err | |
|---|---|---|---|
| 0 | 300 | 0 | 0.000000 |
| 1 | 325 | 0 | 0.000000 |
| 2 | 350 | 0 | 0.000000 |
| 3 | 375 | 0 | 0.000000 |
| 4 | 400 | 0 | 0.000000 |
| 5 | 425 | 0 | 0.000000 |
| 6 | 450 | 0 | 0.000000 |
| 7 | 475 | 0 | 0.000000 |
| 8 | 500 | 944 | 30.724583 |
| 9 | 525 | 967 | 31.096624 |
| 10 | 550 | 1002 | 31.654384 |
| 11 | 575 | 1066 | 32.649655 |
| 12 | 600 | 1027 | 32.046841 |
| 13 | 625 | 993 | 31.511903 |
| 14 | 650 | 1064 | 32.619013 |
| 15 | 675 | 1031 | 32.109189 |
| 16 | 700 | 1102 | 33.196385 |
| 17 | 725 | 1074 | 32.771939 |
| 18 | 750 | 1112 | 33.346664 |
| 19 | 775 | 1099 | 33.151169 |
| 20 | 800 | 1181 | 34.365681 |
| 21 | 825 | 1185 | 34.423829 |
| 22 | 850 | 1235 | 35.142567 |
| 23 | 875 | 1293 | 35.958309 |
In [3]:
#plot of N vs U with error bars
px.scatter(DP, x='U', y='N', error_y='N_err', title='Taux de comptage N en fonction de la tension U', labels={'U': 'Tension U (V)', 'N': 'Taux de comptage N (cps)'})[Data output - unsupported data type map[string]interface {} for mime type application/vnd.plotly.v1+json]
In [4]:
# Drop rows where column 'N' equals 0
DP_filtered = DP[DP['N'] != 0]
# Alternative methods:
# DP_filtered = DP.drop(DP[DP['N'] == 0].index) # Using drop() method
# DP_filtered = DP.query('N != 0') # Using query() method
print(f"Original DataFrame shape: {DP.shape}")
print(f"Filtered DataFrame shape: {DP_filtered.shape}")
print(f"Removed {DP.shape[0] - DP_filtered.shape[0]} rows with N = 0")
DP_filteredOut [4]:
Original DataFrame shape: (24, 3) Filtered DataFrame shape: (16, 3) Removed 8 rows with N = 0
| U | N | N_err | |
|---|---|---|---|
| 8 | 500 | 944 | 30.724583 |
| 9 | 525 | 967 | 31.096624 |
| 10 | 550 | 1002 | 31.654384 |
| 11 | 575 | 1066 | 32.649655 |
| 12 | 600 | 1027 | 32.046841 |
| 13 | 625 | 993 | 31.511903 |
| 14 | 650 | 1064 | 32.619013 |
| 15 | 675 | 1031 | 32.109189 |
| 16 | 700 | 1102 | 33.196385 |
| 17 | 725 | 1074 | 32.771939 |
| 18 | 750 | 1112 | 33.346664 |
| 19 | 775 | 1099 | 33.151169 |
| 20 | 800 | 1181 | 34.365681 |
| 21 | 825 | 1185 | 34.423829 |
| 22 | 850 | 1235 | 35.142567 |
| 23 | 875 | 1293 | 35.958309 |
In [5]:
# we find U_{w}
Uw = (875 + 500 )/2
UwOut [5]:
687.5
In [6]:
# we find N_{av}
Nav = DP_filtered['N'].mean()
print(f'{DP_filtered['N'].mean()} +- {np.sqrt(1/(len(DP_filtered['N'])-1) * np.sum((DP_filtered['N'] - DP_filtered['N'].mean())**2))}')1085.9375 +- 97.48194277232408
In [7]:
#linear regression on the plateau region (from U=500 to U=875)
plateau = DP[(DP['U'] >= 550) & (DP['U'] <= 800)]
slope, intercept, r_value, p_value, std_err = linregress(plateau['U'], plateau['N'])
#we calculate the drift = 1/Nav * dN/dU
drift = 1/Nav * slope
print(f'{drift}')0.0004962616088947025
In [8]:
#plot linear regression on the plateau region
px.scatter(plateau, x='U', y='N', error_y='N_err', title='Taux de comptage N en fonction de la tension U avec régression linéaire', labels={'U': 'Tension U (V)', 'N': 'Taux de comptage N (cps)'}).add_scatter(x=plateau['U'], y=slope*plateau['U'] + intercept, mode='lines', name='Régression linéaire')[Data output - unsupported data type map[string]interface {} for mime type application/vnd.plotly.v1+json]
In [9]:
BM = pd.DataFrame({
't': [256, 256, 256],
'N': [157, 174, 171],
'N_err': [0, 0, 0]
})
BM['N_err'] = np.sqrt(BM['N'])
BMOut [9]:
| t | N | N_err | |
|---|---|---|---|
| 0 | 256 | 157 | 12.529964 |
| 1 | 256 | 174 | 13.190906 |
| 2 | 256 | 171 | 13.076697 |
In [10]:
eta_b = ((BM['N'])/(256 - BM['N'] * 0.0002)).mean()
deta_b = eta_b * np.sqrt(1/(len(BM['N'])-1) * np.sum((BM['N'] - BM['N'].mean())**2))
print(f'{eta_b} +- {deta_b}')0.6537314626534677 +- 5.9318100621415555
In [11]:
CE = pd.DataFrame({
'N': [2883, 1149, 1082],
'eta^{*}': [np.nan]*3,
'deta^{*}': [np.nan]*3
})
CE['eta^{*}'] = (CE['N'])/(256 - CE['N'] * 0.0002) - eta_b
CE['deta^{*}'] = CE['eta^{*}'] * np.sqrt(CE['N'] + deta_b**2)
CEOut [11]:
| N | eta^{*} | deta^{*} | |
|---|---|---|---|
| 0 | 2883 | 10.633410 | 574.419354 |
| 1 | 1149 | 3.838582 | 132.093330 |
| 2 | 1082 | 3.576407 | 119.539031 |
In [ ]:
SA = pd.DataFrame({
'd': [100, 120, 140, 160, 180, 195, 205, 220, 240, 260, 280, 300],
't': [22.67, 29.81, 39.02, 43.56, 54.72, 64.21, 67.92, 76.8, 86.95, 100.59, 116.96, 127.92],
'N': [1003, 1009, 1007, 1002, 1003, 1002, 1002, 1006, 1005, 1003, 1005, 1003],
'd^{-2}': [np.nan]*12,
'Ω': [np.nan]*12,
'δΩ': [np.nan]*12,
'η∗': [np.nan]*12,
'δη∗': [np.nan]*12
})
rd = 15
drd = 0.2
SA['d^{-2}'] = 1 / SA['d']**2
SA['Ω'] = 1/2 * (1 - (1 / np.sqrt(1 + (rd)**2 * SA['d^{-2}'])))
SA['δΩ'] = SA['Ω'] * np.sqrt(((rd/(2*SA['d']))*drd)**2 + (-(rd**2/(2*SA['d']**3))*1)**2)
SA['η∗'] = (SA['N'])/(SA['t'] - SA['N'] * 0.0002) - eta_b
SA['δη∗'] = SA['η∗'] * np.sqrt(SA['η∗'] + deta_b**2)
SA| d | t | N | d^{-2} | Ω | δΩ | η∗ | δη∗ | |
|---|---|---|---|---|---|---|---|---|
| 0 | 100 | 22.67 | 1003 | 0.000100 | 0.005532 | 0.000083 | 43.984755 | 391.368243 |
| 1 | 120 | 29.81 | 1009 | 0.000069 | 0.003861 | 0.000048 | 33.424666 | 276.862453 |
| 2 | 140 | 39.02 | 1007 | 0.000051 | 0.002845 | 0.000030 | 25.287441 | 196.647557 |
| 3 | 160 | 43.56 | 1002 | 0.000039 | 0.002183 | 0.000020 | 22.455338 | 170.485723 |
| 4 | 180 | 54.72 | 1003 | 0.000031 | 0.001727 | 0.000014 | 17.743390 | 129.088202 |
| 5 | 195 | 64.21 | 1002 | 0.000026 | 0.001473 | 0.000011 | 15.000170 | 106.264897 |
| 6 | 205 | 67.92 | 1002 | 0.000024 | 0.001333 | 0.000010 | 14.142576 | 99.329770 |
| 7 | 220 | 76.80 | 1006 | 0.000021 | 0.001158 | 0.000008 | 12.479634 | 86.160102 |
| 8 | 240 | 86.95 | 1005 | 0.000017 | 0.000974 | 0.000006 | 10.931416 | 74.235335 |
| 9 | 260 | 100.59 | 1003 | 0.000015 | 0.000830 | 0.000005 | 9.337363 | 62.304590 |
| 10 | 280 | 116.96 | 1005 | 0.000013 | 0.000716 | 0.000004 | 7.953742 | 52.241079 |
| 11 | 300 | 127.92 | 1003 | 0.000011 | 0.000624 | 0.000003 | 7.199422 | 46.871382 |
In [13]:
# slope, intercept, r_value, p_value, std_err = linregress(SA['d'], SA['Ω'])
# dOmega = slope
px.scatter(SA, x='d', y='Ω', error_y='δΩ', title='Angle Ω en stéradian en fonction de d', labels={'d': 'Distance d [mm]', 'Ω': 'Angle solide Ω [sr]'})#.add_scatter(x=SA['d'], y=slope*SA['d'] + intercept, mode='lines', name='Régression linéaire')
[Data output - unsupported data type map[string]interface {} for mime type application/vnd.plotly.v1+json]
In [14]:
slope, intercept, r_value, p_value, std_err = linregress(SA['Ω'], SA['η∗'])
deta = slope
px.scatter(SA, x='Ω', y='η∗', error_y='δη∗', title='Taux de comptage η∗ en fonction de l\'angle solide Ω', labels={r'η∗': 'Taux de comptage η∗ [s^-1]', 'Ω': 'Angle solide Ω [sr]'}).add_scatter(x=SA['Ω'], y=slope*SA['Ω'] + intercept, mode='lines', name='Régression linéaire')
[Data output - unsupported data type map[string]interface {} for mime type application/vnd.plotly.v1+json]
In [135]:
detaOut [135]:
np.float64(7537.295764589329)
In [136]:
eps = 0.009
A = deta/(eps)
AOut [136]:
np.float64(837477.3071765922)
In [ ]: