<jupyter_start><jupyter_text>Cloud Chamber__Observation of alpha decayUC Santa Barbara, Physics, <NAME><jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pylab as plt
import os<jupyter_output><empty_output><jupyter_text>Load data from text files<jupyter_code>data1=np.loadtxt("./data/data1.txt")
data2=pd.read_table("./data/data2.txt").values
data3=pd.read_table("./data/data3.txt").values
data_CF4=pd.read_table("./data/data4.txt").values[:,-1]
def get_trajectory_gray_value(n,directory="./data/"):
    gray_value=pd.read_csv(directory+"trj_gv{0}.csv".format(n))
    background=pd.read_csv(directory+"trj_bg{0}.csv".format(n))
    return pd.DataFrame([gray_value.X,gray_value.Y-background.Y]).transpose()
pixel_d=6/354.8#cm
precision=6*pixel_d # 640*480
print("systematic error: "+str(precision)[:7]+"cm") #estimate the error of video measurement
traj_lens=np.concatenate([data1[:,-1],data2[:,-1],data3[:,-1]])
pd.DataFrame(traj_lens).describe() # description of measurement data
plt.figure().dpi=100
plt.hist(traj_lens,bins=40)
plt.xlabel("Trajectory Length [cm]")
plt.ylabel("Counts [1]")
plt.show() # 
avg_l=np.mean(traj_lens)
std_l=np.std(traj_lens)
sdom_l=std_l/np.sqrt(len(traj_lens))
sigma_l=np.sqrt(sdom_l**2+precision**2)
print("Mean:",avg_l)
print("Uncertainty:",sigma_l)
print("Standard Deviation of Mean:",sdom_l)
pd.DataFrame(data_CF4).describe() # basic information of CF4 gas measurement
plt.figure().dpi=100
plt.hist(data_CF4,bins=40)
plt.xlabel("Trajectory Length [cm]")
plt.ylabel("Counts [1]")
plt.show()
avg_l_CF4=np.mean(data_CF4)
std_l_CF4=np.std(data_CF4)
sdom_l_CF4=std_l/np.sqrt(len(data_CF4))
sigma_l_CF4=np.sqrt(sdom_l_CF4**2+precision**2)
print("Mean:",avg_l_CF4)
print("Uncertainty:",sigma_l_CF4)
print("Standard Deviation of Mean:",sdom_l_CF4)
rho_ratio=avg_l_CF4/avg_l
sigma_rho_ratio=rho_ratio*np.sqrt((sigma_l_CF4/avg_l_CF4)**2+(sigma_l/avg_l)**2)
print("Ratio:",rho_ratio)
print("Uncertainty:",sigma_rho_ratio)
aggregate_Y=pd.DataFrame([])
bound=[210,220]
plt.figure().set_dpi(100)
for n in range(1,20):
    traj_gv=get_trajectory_gray_value(n)
#     print(len(traj_gv.X))
    if bound[0]<len(traj_gv)<bound[1]:
        aggregate_Y=pd.concat([aggregate_Y,traj_gv.Y],axis=1)
        plt.plot(traj_gv.X,traj_gv.Y,".")
plt.xlabel("Passage Distance [cm]")
plt.ylabel("Gray Value [1]")
plt.show()
# we choose some trajectories with similiar length to compare their droplet density with passage distance
sampling_d=traj_gv.X[2]-traj_gv.X[1]
# aggregate_Y=aggregate_Y.rolling(3).mean()
# aggregate all the trajectories, give the average and SDOM
plt.figure().dpi=130
plt.xlabel("Passage Distance [cm]")
plt.ylabel("Gray Value [1]")
Y_error=aggregate_Y.std(axis=1)/aggregate_Y.count(axis=1).apply(np.sqrt)
X=sampling_d*np.arange(len(aggregate_Y))
Y=aggregate_Y.mean(axis=1)
plt.errorbar(X,Y,yerr=Y_error)
#plt.plot(moving_average(traj_gv.X.values,bit),moving_average(traj_gv.Y.values,bit),".")
plt.title("Gray Scale of Trajectory")
plt.show()<jupyter_output><empty_output><jupyter_text>Import data from NIST ASTAR particle database *https://physics.nist.gov/PhysRefData/Star/Text/ASTAR.html*Use data of air as approximation of ethanol<jupyter_code>ASTAR_data=pd.read_csv("./data/ASTAR.tsv",sep="\t",index_col=False)
ASTAR_data.head()
ASTAR_data.describe()
plt.figure().set_dpi(100)
plt.plot(ASTAR_data.Kinetic_Energy,ASTAR_data.Projected_Range)
plt.xlabel(r"Kinetic Energy [$MeV$]")
plt.ylabel(r"Projcted Range[$g/cm^2$]")
plt.show()
fig,ax=plt.subplots()
fig.set_dpi(100)
plt.plot(np.log10(ASTAR_data.Kinetic_Energy),np.log10(ASTAR_data.Total_Stp_Pow))
plt.xlabel(r"Kinetic Energy [$MeV$]")
plt.ylabel(r"Projcted Range$[g/cm^2]$")
plt.xticks(np.arange(-3,4),np.vectorize(lambda x: r"$10^{"+str(x)+"}$")(np.arange(-3,4)))
plt.yticks(np.arange(1.5,3.3,0.5),np.vectorize(lambda x: r"$10^{"+str(x)+"}$")(np.arange(1.5,3.3,0.5)))
plt.show()
fig,ax=plt.subplots()
fig.set_dpi(100)
plt.plot(ASTAR_data.Kinetic_Energy,ASTAR_data.Total_Stp_Pow)
plt.xlabel(r"Kinetic Energy [$MeV$]")
plt.ylabel(r"Projcted Range$[g/cm^2]$")
plt.show()<jupyter_output><empty_output><jupyter_text>ethanol vapor density from internet sourcehttps://www.ncdoi.com/OSFM/RPD/PT/Documents/Coursework/Ethanol/Module2_InstructorGuide.pdf<jupyter_code>ethanol_vapor_density=1.59*10**(-3) #g/cm^3
projected_range=avg_l*ethanol_vapor_density #g/cm^2
print("projected range: ", str(projected_range)[:8],"g/cm^2")
ASTAR_data[ASTAR_data.CSDA_Range<projected_range].iloc[-1]<jupyter_output><empty_output><jupyter_text>Kinetic Energy is about 5.5 MeV, find more accurate estimation by curve fitting<jupyter_code>upper_bound=80
parameters=np.polyfit(ASTAR_data.CSDA_Range[:upper_bound],ASTAR_data.Kinetic_Energy[:upper_bound],8)
est_KE=np.polyval(parameters,projected_range)
print("estimated kinetic energy:",est_KE)
sigma_KE=(np.polyval(parameters,projected_range+sigma_l*ethanol_vapor_density)-est_KE,est_KE-np.polyval(parameters,projected_range-sigma_l*ethanol_vapor_density))
print("uncertainty:",sigma_KE)<jupyter_output>uncertainty: (0.10624324910943272, 0.10630765955770283)
{'fraction_non_alphanumeric': 0.17233916978162503, 'fraction_numerical': 0.03541215817430651, 'mean_word_length': 9.127490039840637, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '139547', 'license': 'MIT', 'n_tokens_mistral': 2288, 'n_tokens_neox': 2105, 'n_words': 244, 'path': 'Experiment4/.ipynb_checkpoints/Cloud Chamber-checkpoint.ipynb', 'repo_name': 'Neuromancer43/PHYS128AL', 'size': '5089'}