Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Jupyter notebook LED_Analysis/PlanckAnalysis.ipynb

9 views
Kernel: Python 3 (Anaconda)
# Load Python Modules from numpy import * from matplotlib.pyplot import * from scipy.stats import linregress
# Enter Data here, between [ ] brackets separated by comma ',' Lambda = [ 420e-9, 576e-9, 615e-9, 700e-9] Va = [ 2.6, 1.85, 1.9, 1.7 ] # Error on Va #error = 0.0003 e = 1.60217662e-19 # [C] c = 299792458 # [m/s]
# Define x and y values x = c/array(Lambda) y = e*array(Va) # Fit x/y Data using a linear regression slope, intercept, r_value, p_value, err = linregress(x,y) # Print the fit coeffs print('Slope, Error, Intercept, Correlation Coefficient:') print(slope, err, intercept, r_value**2)
Slope, Error, Intercept, Correlation Coefficient: 4.1884594531e-34 1.20123921012e-34 1.0413727488e-19 0.858733616142
# Calculate Plancks Constant print("Plancks Constant h:", slope, "+/-", err, "Js")
Plancks Constant h: 4.1884594531e-34 +/- 1.20123921012e-34 Js
# Calculate Plancks Constant print("Plancks Constant h: %1.0e +/- %1.0e Js" %(slope,err))
Plancks Constant h: 4e-34 +/- 1e-34 Js
# Create the fit data xfit = linspace(1e13, 8e14) # define the x-data using a start and end point yfit = slope*xfit + intercept # Plot Fit results plot(x,y,'o', label='Measured') plot(xfit,yfit, 'r-', label='Linear Fit') # Label Axes # Put maths code between $ $ symbols xlabel('$c/ \lambda$ [s$^{-1}$]') ylabel('$eV_a$ [J]') # Add legend legend() # Save Figure savefig('PlanckResults.png', dpi=300, format='png', bbox_inches='tight')
Image in a Jupyter notebook