Skip to content
Snippets Groups Projects
Commit 88cbbf10 authored by JupyterHub User's avatar JupyterHub User
Browse files

added innen radious plot diagramms and lists with all the values

parent e784860c
No related branches found
No related tags found
No related merge requests found
......@@ -237,7 +237,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.9.7"
}
},
"nbformat": 4,
......
......@@ -62,7 +62,8 @@ def I_V_Measurement(start,stop,step):
#exporting the data frame in an excel file
file_name ="results.csv"
path = r"C:\Users\user\Desktop"
path = r"\\fileserver.cst.rwth-aachen.de\public\Datentransfer\Asonitis, Alexandros"
#r"C:\Users\user\Desktop"
directory = os.path.join(path,file_name)
df.to_csv(directory)
......@@ -141,7 +142,7 @@ def stress_sampling(V2_stress=10,V3_stress=3,stress_time=30,V2_sampling=10,V3_sa
#prepare full measurement
def ctlm(field_name ='M00',start=-50*10**(-3),stop=50*10**(-3),step=10**(-3),comp=10,distances=(5,10,15,25,45),time='MED'):
def ctlm(field_name ='M00',start=-50*10**(-3),stop=50*10**(-3),step=10**(-3),comp=10,distances=(5,10,15,25,45),time='MED',innen=0):
#connect to the device
device = module.HP4155a('GPIB0::17::INSTR')
......@@ -153,6 +154,10 @@ def ctlm(field_name ='M00',start=-50*10**(-3),stop=50*10**(-3),step=10**(-3),com
plt.ylabel('Current(A)')
plt.title("CTLM plot")
#lists for appending all data values
ctlm_voltage = []
ctlm_current = []
ctlm_resistance = []
#execute five measurements
for j in range(len(distances)):
......@@ -203,6 +208,9 @@ def ctlm(field_name ='M00',start=-50*10**(-3),stop=50*10**(-3),step=10**(-3),com
voltage_values = device.return_data('V3')
current_values = device.return_data('I3')
ctlm_voltage.append(voltage_values)
ctlm_current.append(current_values)
resistance_values=[]
for i in range(len(voltage_values)):
......@@ -221,7 +229,7 @@ def ctlm(field_name ='M00',start=-50*10**(-3),stop=50*10**(-3),step=10**(-3),com
print(df)
file_name = field_name+"_CTLM_"+str(j+1)+".txt"
path =r"C:\Users\user\Desktop"
path =r"\\fileserver.cst.rwth-aachen.de\public\Datentransfer\Asonitis, Alexandros"
directory = os.path.join(path,file_name)
#export DataFrame to text file (keep header row and index column)
f=open(directory, 'a')
......@@ -229,6 +237,10 @@ def ctlm(field_name ='M00',start=-50*10**(-3),stop=50*10**(-3),step=10**(-3),com
df_string = df.to_string()
f.write(df_string)
#plot diagramm
plt.legend()
plt.show()
#wait for confirmation from user after a measurement is done
while True:
answer = input('please press enter to continue with the next measurement or finish after the last measurement!')
......@@ -236,7 +248,5 @@ def ctlm(field_name ='M00',start=-50*10**(-3),stop=50*10**(-3),step=10**(-3),com
break
#close the connection and plot all the diagramms
plt.legend()
plt.show()
del device
......@@ -182,6 +182,7 @@ class HP4155a(object):
#set normal compliance for VAR1 and VAR2
def comp(self,variable,value):
""" """
command = f":PAGE:MEAS:{variable}:COMP {value}"
self.inst.write(command)
......
%% Cell type:code id:f3bb2a53-f571-4da3-b09f-4c8ee8c75a83 tags:
``` python
import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime
import numpy as np
from sklearn.linear_model import LinearRegression
```
%% Output
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
/tmp/ipykernel_6709/1825645653.py in <module>
----> 1 import pandas as pd
2 import matplotlib.pyplot as plt
3 from datetime import datetime
4 import numpy as np
5 from sklearn.linear_model import LinearRegression
ModuleNotFoundError: No module named 'pandas'
%% Cell type:code id:a9461575-0bd1-4e25-8403-ed4eb12ccce2 tags:
``` python
voltage_values = [0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45, 1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95, 2.0, 2.05, 2.1, 2.15, 2.2, 2.25, 2.3, 2.35, 2.4, 2.45, 2.5, 2.55, 2.6, 2.65, 2.7, 2.75, 2.8, 2.85, 2.9, 2.95, 3.0, 3.05, 3.1, 3.15, 3.2, 3.25, 3.3, 3.35, 3.4, 3.45, 3.5, 3.55, 3.6, 3.65, 3.7, 3.75, 3.8, 3.85, 3.9, 3.95, 4.0, 4.05, 4.1, 4.15, 4.2, 4.25, 4.3, 4.35, 4.4, 4.45, 4.5, 4.55, 4.6, 4.65, 4.7, 4.75, 4.8, 4.85, 4.9, 4.95, 5.0, 5.05, 5.1, 5.15, 5.2, 5.25, 5.3, 5.35, 5.4, 5.45, 5.5, 5.55, 5.6, 5.65, 5.7, 5.75, 5.8, 5.85, 5.9, 5.95, 6.0, 6.05, 6.1, 6.15, 6.2, 6.25, 6.3, 6.35, 6.4, 6.45, 6.5, 6.55, 6.6, 6.65, 6.7, 6.75, 6.8, 6.85, 6.9, 6.95, 7.0, 7.05, 7.1, 7.15, 7.2, 7.25, 7.3, 7.35, 7.4, 7.45, 7.5, 7.55, 7.6, 7.65, 7.7, 7.75, 7.8, 7.85, 7.9, 7.95, 8.0, 8.05, 8.1, 8.15, 8.2, 8.25, 8.3, 8.35, 8.4, 8.45, 8.5, 8.55, 8.6, 8.65, 8.7, 8.75, 8.8, 8.85, 8.9, 8.95, 9.0, 9.05, 9.1, 9.15, 9.2, 9.25, 9.3, 9.35, 9.4, 9.45, 9.5, 9.55, 9.6, 9.65, 9.7, 9.75, 9.8, 9.85, 9.9, 9.95, 10.0]
print(len(voltage_values))
```
%% Output
201
%% Cell type:code id:b12e1696-12d9-4b94-9028-2610ec7e73c6 tags:
``` python
current_values = [-2.0172e-07, 1.7837e-05, 3.7577e-05, 6.0445e-05, 8.5833e-05, 0.000113797, 0.00014604, 0.0001823, 0.00022479, 0.00027261, 0.00032461, 0.00038161, 0.00044615, 0.00051651, 0.00059047, 0.00066731, 0.00075451, 0.0008448, 0.00093602, 0.00102376, 0.0011258, 0.0012281, 0.0013295, 0.0014353, 0.0015563, 0.0016701, 0.0017803, 0.0018951, 0.002029, 0.0021518, 0.0022691, 0.0023878, 0.0025273, 0.0026616, 0.0027876, 0.002916, 0.0030592, 0.0032063, 0.0033439, 0.003475, 0.0036308, 0.0037965, 0.0039297, 0.0040698, 0.0042341, 0.004404, 0.0045565, 0.0046994, 0.0048693, 0.0050476, 0.0052095, 0.0053543, 0.0055203, 0.0057068, 0.0058664, 0.0060137, 0.0061811, 0.0063717, 0.0065344, 0.0066796, 0.0068391, 0.0070318, 0.0072005, 0.0073433, 0.0074938, 0.0076875, 0.0078528, 0.0079939, 0.0081331, 0.008324, 0.0084877, 0.0086322, 0.0087642, 0.0089491, 0.0091169, 0.0092587, 0.0094001, 0.0095756, 0.0097471, 0.0098836, 0.0100007, 0.0101695, 0.0103403, 0.0104739, 0.0105835, 0.010747, 0.0109165, 0.0110492, 0.0111549, 0.0113035, 0.011437, 0.011582, 0.011752, 0.011885, 0.01199, 0.012118, 0.012294, 0.012424, 0.012515, 0.012631, 0.012812, 0.012943, 0.013039, 0.013146, 0.013317, 0.01345, 0.013551, 0.013645, 0.013811, 0.01394, 0.014039, 0.014122, 0.014289, 0.014246, 0.014127, 0.014193, 0.014335, 0.014895, 0.014997, 0.015063, 0.01521, 0.01535, 0.015448, 0.015513, 0.015641, 0.015792, 0.015895, 0.015949, 0.016056, 0.016203, 0.016302, 0.016362, 0.016492, 0.016636, 0.016745, 0.016774, 0.016874, 0.017036, 0.017124, 0.017172, 0.017251, 0.01741, 0.017513, 0.017609, 0.017646, 0.017794, 0.017869, 0.017955, 0.01802, 0.018137, 0.018244, 0.018323, 0.018396, 0.018502, 0.018611, 0.018682, 0.018713, 0.018826, 0.018934, 0.019005, 0.019042, 0.019156, 0.019268, 0.019344, 0.019375, 0.019478, 0.019604, 0.019675, 0.019701, 0.019793, 0.019926, 0.019996, 0.020026, 0.020103, 0.020242, 0.020314, 0.020345, 0.020408, 0.020549, 0.020624, 0.021077, 0.020751, 0.020862, 0.02093, 0.020973, 0.021014, 0.021131, 0.021219, 0.021269, 0.021204, 0.02139, 0.02151, 0.021572, 0.02159, 0.021701, 0.021798, 0.021869, 0.021896, 0.021991, 0.022039, 0.022167]
print(len(current_values))
```
%% Output
201
%% Cell type:code id:c7f1a914-cca3-4de7-8cbc-ccdb94197658 tags:
``` python
#add title to the results
header = ['Voltage(V)', 'Current(A)']
data = {header[0]:voltage_values,header[1]:current_values}
df = pd.DataFrame(data)
date = str(datetime.today().replace(microsecond=0))
print(date)
```
%% Output
2023-09-08 09:46:45
%% Cell type:code id:30ac24c1-d6ed-4e41-8d7c-fa0fe44e072f tags:
``` python
#export table in pdf file
fig = plt.figure(figsize = (8,2))
fig.suptitle('I-V measurement results at:'+ date, y=9)
ax = fig.add_subplot(111)
ax.table(cellText = df.values,
rowLabels = df.index,
colLabels = df.columns,
loc = "center")
plt.axis('off')
plt.savefig('results.pdf',format="pdf",bbox_inches="tight")
```
%% Output
%% Cell type:code id:09d63039-ef49-4c65-be9d-9c7326428cdc tags:
``` python
#exporting the data frame in an excel file
#file_name = 'results '+date+'.xlsx'
#df.to_excel(file_name)
file_name = '\ results '+date+'.txt'
path = "\\FILESERVER\public\Datentransfer\Asonitis, Alexandros" + file_name
#export DataFrame to text file (keep header row and index column)
with open(path, 'a') as f:
f.write('title.\n\n')
df_string = df.to_string()
f.write(df_string)
```
%% Cell type:code id:1f89f490-e901-43cb-b1f4-cda5b4cf6ae8 tags:
``` python
x=np.array(voltage_values).reshape((-1,1)) #column matrix
y = np.array(current_values)
#create a model
model = LinearRegression()
model.fit(x, y)
r_sq = model.score(x, y)
print(f"coefficient of determination: {r_sq}")
print(f"intercept: {model.intercept_}")
print(f"slope: {model.coef_}")
plt.figure()
plt.plot(voltage_values,current_values,label='real curve')
plt.plot(x,model.coef_*x+model.intercept_,label='linear')
plt.xlabel('Voltage(V)')
plt.ylabel('Current(A)')
plt.title("I-V plot")
plt.legend()
plt.show()
plt.plot(x,model.coef_*x+model.intercept_,label='linear')
plt.legend()
plt.show()
```
%% Output
coefficient of determination: 0.9873880135298887
intercept: -0.00043234755330870747
slope: [0.00243783]
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
/tmp/ipykernel_6709/2398863689.py in <module>
----> 1 x=np.array(voltage_values).reshape((-1,1)) #column matrix
2 y = np.array(current_values)
3
4 #create a model
5 model = LinearRegression()
NameError: name 'np' is not defined
%% Cell type:code id:49c0c86e-bc82-42c6-b6fa-a3b8fa926f6d tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment