Загрузил(а) файлы в 'Project/program_files'

This commit is contained in:
Дмитрий Пунов 2022-12-10 17:05:06 +03:00
parent 9777b815ca
commit febe43f08a
2 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,56 @@
from scipy.optimize import curve_fit
from numpy import linspace
import numpy as np
from numpy import tanh
from scipy.constants import e, k
from numpy import sqrt
from numpy import array
import pandas as pd
# Global variables
new_U = linspace(-22, 22, 1000)
# Function for approximation
def function_IU(U, I_n, T_e, A, B):
return I_n * tanh(e*U/2/k/T_e) + A*U + B
# Find the best fit params of In and Te
def find_FitParams(data_I, data_U):
popt, pcov = curve_fit(function_IU, data_U, data_I, p0=[0, 50000, 0, 0])
return popt, pcov
# Returns disperancy of given value
def discrepancy(data, popt):
I = data[0]
U = data[1]
tmp = []
for i in range(len(U)):
temp = sqrt((function_IU(
U[i], *popt)-I[i])**2/len(U)/(len(U)-1))
tmp.append(temp)
return tmp
# Returns pandas.DataFrame with approximated Current and Voltage values
def getApproxValues(data):
data = data.sort_values(by=['U'])
popt, pcov = find_FitParams(data['I'], data['U'])
df = pd.DataFrame()
df['U'] = new_U
df['I'] = function_IU(df['U'], *popt)
error = np.sqrt(np.diag(pcov))
return [df, popt, error]

View File

@ -0,0 +1,40 @@
class AKIP():
def __init__(self, folder):
self.folder = folder
def getVoltageDC(self):
self.instr = open(self.folder, 'w')
self.instr.write('MEAS:VOLT:DC?\n')
self.instr.flush()
self.instr = open(self.folder, 'r')
data = self.instr.readline()
self.instr.close()
return float(data)
def getCurrentDC(self):
self.instr = open(self.folder, 'w')
self.instr.write('MEAS:AMP:DC?\n')
self.instr.flush()
self.instr = open(self.folder, 'r')
data = self.instr.readline()
self.instr.close()
return float(data)
def getVoltageAC(self):
self.instr = open(self.folder, 'w')
self.instr.write('MEAS:VOLT:AC?\n')
self.instr.flush()
self.instr = open(self.folder, 'r')
data = self.instr.readline()
self.instr.close()
return float(data)
def getCurrentAC(self):
self.instr = open(self.folder, 'w')
self.instr.write('MEAS:AMP:AC?\n')
self.instr.flush()
self.instr = open(self.folder, 'r')
data = self.instr.readline()
self.instr.close()
return float(data)