import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from IPython.core.display import Image, display
display(Image('/work/ProjectTC.PNG', width=1900, unconfined=True))
from IPython.core.display import Image, display
display(Image('/work/Project0LT.PNG', width=1900, unconfined=True))
TC_df = pd.read_csv("Project0 TC.txt")
TC_df
Vps = TC_df.Vps
Vpr = TC_df.Vpr
R = 1000
I = (Vps - Vpr)/R
m, b = np.polyfit(I, Vpr, 1)
Vth = m*I + b
plt.title("I-V Relation of Photoresistor ")
plt.xlabel("Current Across Photoresistor (mA)")
plt.ylabel("Voltage Across Photoresistor(V)")
plt.plot(I*1000, Vpr, 'b.', label='data')
plt.plot(I*1000, Vth, 'r-', label='fit')
plt.grid()
plt.legend()
m
LT_df = pd.read_csv('Project 0_LTspice.txt',delimiter='\t')
LT_df
LT_df.columns
Vps = LT_df['V(n001)']
Vpr = LT_df['V(n002)']
Vps, Vpr
Vps = LT_df['V(n001)']
Vpr = LT_df['V(n002)']
R = 1000
I = (Vps-Vpr)/R
m, b = np.polyfit(I, Vps, 1)
Vth = m*I + b
m2, b2 = np.polyfit(I, Vpr, 1)
Vth2 = m2*I + b2
plt.grid()
plt.plot(I*1000, Vps, 'b.', label='data power supply')
plt.plot(I*1000, Vpr, 'g.', label='data after resistor')
plt.plot(I*1000, Vth, 'r-', label='fit')
plt.plot(I*1000, Vth2, 'r-', label='fit')
plt.title("I-V Relation Across a Resistor ")
plt.xlabel("Current Across Resistor (mA)")
plt.ylabel("Voltage Across Resistor(V)")
plt.legend()
m2