add analisis data
This commit is contained in:
parent
54d3f87c05
commit
90c2fdaf50
@ -12,8 +12,8 @@ from scipy.optimize import curve_fit
|
||||
|
||||
|
||||
class Data:
|
||||
def __init__(self, x=[], y=[], xlabel='', ylabel='', caption='', xerr=None,
|
||||
yerr=None, through_0=0, data_filename='', color=None,
|
||||
def __init__(self, x=[], y=[], xlabel='', ylabel='', caption='', xerr=[],
|
||||
yerr=[], through_0=0, data_filename='', color=None,
|
||||
centering=None, size=15, coefficient=[0.9, 1.1], saving=None):
|
||||
self.x = x
|
||||
self.y = y
|
||||
@ -36,20 +36,20 @@ class Data:
|
||||
self.data_filename = data_filename
|
||||
self.saving = saving
|
||||
|
||||
def make_errors(self, xerr=None, yerr=None):
|
||||
if not xerr:
|
||||
def make_errors(self, xerr=[], yerr=[]):
|
||||
if not len(xerr):
|
||||
xerr = self.xerr
|
||||
if not yerr:
|
||||
if not len(yerr):
|
||||
yerr = self.yerr
|
||||
if not xerr:
|
||||
if not len(xerr):
|
||||
xerr = 0
|
||||
if not yerr:
|
||||
if not len(yerr):
|
||||
yerr = 0
|
||||
if not yerr or type(yerr) == float or type(yerr) == int:
|
||||
if type(yerr) == float or type(yerr) == int:
|
||||
self.yerr = [yerr for _ in self.y]
|
||||
else:
|
||||
self.yerr = yerr
|
||||
if not xerr or type(xerr) == float or type(xerr) == int:
|
||||
if type(xerr) == float or type(xerr) == int:
|
||||
self.xerr = [xerr for _ in self.x]
|
||||
else:
|
||||
self.xerr = xerr
|
||||
|
@ -9,6 +9,8 @@ import os
|
||||
import csv
|
||||
import serial
|
||||
import numpy as np
|
||||
from scipy.optimize import curve_fit
|
||||
import matplotlib.pyplot as plt
|
||||
import time
|
||||
from PyQt6 import QtCore
|
||||
from PyQt6.QtGui import QPixmap
|
||||
@ -24,22 +26,16 @@ from PyQt6.QtWidgets import (QLabel,
|
||||
from Analisis_data import Data
|
||||
from Abstract_window import AbstractWindow
|
||||
|
||||
|
||||
class ChartWindow(AbstractWindow):
|
||||
def __init__(self, parent):
|
||||
super().__init__()
|
||||
|
||||
self.setWindowTitle('Обработка данных')
|
||||
self.parent = parent
|
||||
self.parent.chartname = 'Chart'
|
||||
self.parent.data = Data(data_filename=os.path.join(self.parent.folder, self.parent.dataname),
|
||||
saving=os.path.join(self.parent.folder, self.parent.chartname))
|
||||
self.parent.data.read_csv()
|
||||
# add B(I_M) #TODO
|
||||
self.parent.data.x = np.array(self.parent.data.data['I_0,mA'])*np.array(self.parent.data.data['I_M,mA'])
|
||||
self.parent.data.y = self.parent.data.data['U_34,mV']
|
||||
self.parent.data.ylabel = 'U_34,mV'
|
||||
self.parent.data.xlabel = 'I$_{обр} \cdot B$, мА$\cdot $ Tл'
|
||||
self.parent.data.make_grafic()
|
||||
|
||||
(a, eps) = self.make_grad()
|
||||
self.make_main(a, eps)
|
||||
|
||||
self.setWindowTitle('Основной эксперимент. Обработка данных')
|
||||
self.resize(1400, 800)
|
||||
@ -48,15 +44,126 @@ class ChartWindow(AbstractWindow):
|
||||
self.setCentralWidget(self.centralwidget)
|
||||
|
||||
pixmap = QPixmap(os.path.join(
|
||||
self.parent.folder, self.parent.chartname))
|
||||
self.parent.folder,
|
||||
self.parent.main_chartname))
|
||||
self.label = QLabel(self)
|
||||
self.label.setScaledContents(True)
|
||||
self.label.setFixedSize(0.7*self.width(), 0.9*self.height())
|
||||
self.label.setPixmap(pixmap)
|
||||
|
||||
self.text = QTextBrowser()
|
||||
self.text.setText('text')
|
||||
self.text.setText(self.make_text())
|
||||
|
||||
self.hbox_layout = QGridLayout(self.centralwidget)
|
||||
self.hbox_layout.addWidget(self.label, 0, 0)
|
||||
self.hbox_layout.addWidget(self.text, 0, 1)
|
||||
|
||||
def B(self, x, b, c, d):
|
||||
return x**2*b+x*c+d
|
||||
|
||||
def make_grad(self):
|
||||
|
||||
self.parent.grad_chartname = 'Graduation_chart.png'
|
||||
self.parent.data_grad = Data(data_filename=os.path.join(
|
||||
self.parent.folder, self.parent.flow_dataname))
|
||||
self.parent.data_grad.read_csv()
|
||||
self.parent.data_grad.x = np.array(
|
||||
self.parent.data_grad.data['I_M,mA'])
|
||||
self.parent.data_grad.y = np.array(self.parent.data_grad.data['B,mTl'])
|
||||
self.parent.data_grad.xlabel = 'I$_M$,mA'
|
||||
self.parent.data_grad.ylabel = 'B,mTl'
|
||||
self.parent.data_grad.xerr = 0.0035/100*self.parent.data_grad.x
|
||||
self.parent.data_grad.yerr = 0.02*self.parent.data_grad.y
|
||||
plt.figure(dpi=500, figsize=(8, 5))
|
||||
self.parent.data_grad.make_point_grafic()
|
||||
|
||||
a, sigma = curve_fit(
|
||||
self.B, self.parent.data_grad.x, self.parent.data_grad.y)
|
||||
sigma = abs(np.sqrt(np.diag(sigma))/a)
|
||||
eps = (np.min(sigma)**2+(0.0035/100)**2+0.02**2)**0.5
|
||||
x_range = np.arange(min(self.parent.data_grad.x),
|
||||
max(self.parent.data_grad.x), step=0.001)
|
||||
y_fit = self.B(x_range, a[0], a[1], a[2])
|
||||
plt.plot(x_range, y_fit)
|
||||
plt.savefig(os.path.join(
|
||||
self.parent.folder,
|
||||
self.parent.grad_chartname))
|
||||
return (a, eps)
|
||||
|
||||
def make_main(self, a, eps_b):
|
||||
self.parent.main_chartname = 'Chart'
|
||||
self.parent.data_main = Data(data_filename=os.path.join(self.parent.folder, self.parent.dataname),
|
||||
saving=os.path.join(self.parent.folder, self.parent.main_chartname))
|
||||
self.parent.data_main.read_csv()
|
||||
|
||||
h = self.parent.a
|
||||
e = np.array((self.parent.data_main.data['U_34,mV'] -
|
||||
self.parent.data_main.data['U_0,mV'])/10**3)
|
||||
b = np.array(
|
||||
self.B(self.parent.data_main.data['I_M,mA'], a[0], a[1], a[2]))
|
||||
eds = chr(949)
|
||||
self.parent.data_main.x = np.array(
|
||||
self.parent.data_main.data['I_0,mA']*b)
|
||||
self.parent.data_main.y = e
|
||||
self.parent.data_main.ylabel = eds+'$_x$, mV'
|
||||
self.parent.data_main.xlabel = 'I$_{обр} \cdot B$, мА$\cdot $ Tл'
|
||||
self.parent.data_main.make_grafic()
|
||||
self.parent.data_main.xerr = abs(
|
||||
self.parent.data_main.x*(eps_b**2+0.01**2)**0.5)
|
||||
self.parent.data_main.yerr = abs(5*10**-5*self.parent.data_main.y)
|
||||
self.parent.data_main.through_0 = 0
|
||||
k, b1, sigma = self.parent.data_main.make_grafic()
|
||||
self.parent.R_H = k*h
|
||||
self.parent.sigma_R_H = self.parent.R_H*sigma[0]/k
|
||||
|
||||
e_e = 1.6*10**-19
|
||||
self.parent.n = 1/(-self.parent.R_H*e_e)*10**-21
|
||||
self.parent.sigma_n = self.parent.n*abs(sigma[0]/k)
|
||||
|
||||
self.parent.b = -self.parent.sigma*self.parent.R_H
|
||||
|
||||
self.parent.sigma_b = self.parent.b*((self.parent.sigma_sigma/self.parent.sigma)**2 +
|
||||
(sigma[0]/k)**2)**0.5
|
||||
|
||||
def make_text(self):
|
||||
s0 = 'Вычисленные постоянные равны:'+'\n'+\
|
||||
'R_X - постоянная Холла, '+'\n'+' n - концентрация носителей заряда,'+'\n'+\
|
||||
'sigma - удельная проводимость, '+'\n'+' b - подвижность'+'\n'+'\n'
|
||||
|
||||
s1 = 'R_X = ' + str(round(self.parent.R_H*10**10)) + ' +- ' + \
|
||||
str(round(self.parent.sigma_R_H*10**10)) + \
|
||||
' , 10^-10 м^3/Кл'+'\n'+'\n'
|
||||
s2 = 'n = ' + str(round(self.parent.n)) + ' +- ' + \
|
||||
str(round(self.parent.sigma_n)) + ' , 1/м^3'+'\n'+'\n'
|
||||
s3 = 'sigma = ' + str(round(self.parent.sigma)) + ' +- ' + \
|
||||
str(round(self.parent.sigma_sigma)) + ', 1/(Ом*м)'+'\n'+'\n'
|
||||
|
||||
s4 = 'b = ' + str(round(self.parent.b*10**4)) + ' +- ' + \
|
||||
str(round(self.parent.sigma_b*10**4)) + ', см^3/(В*с)'+'\n'+'\n'
|
||||
return s0+s1+s2+s3+s4
|
||||
|
||||
# print('all ', -k/h, '+-', sigma[0]/h)
|
||||
# plt.show()
|
||||
# plt.figure(dpi=500, figsize=(8, 5))
|
||||
|
||||
# plt.figure(dpi=500, figsize=(8, 5))
|
||||
# x = np.array(data['I'])
|
||||
# y = np.array(data['k'])
|
||||
# xlabel = 'I, мА'
|
||||
# ylabel = 'K, мВ/Тл'
|
||||
# caption_point = ''
|
||||
# xerr = abs(x*1/100)
|
||||
# yerr = data['sig_k']
|
||||
# k, b, sigma = make_graffic(
|
||||
# x, y, xlabel, ylabel, caption_point, xerr, yerr, b=0, koef=[1.1, 1.1])
|
||||
# plt.savefig('K(I)')
|
||||
# print('R_x ', k*h*10**6, '+-', sigma[0]*10**6*h)
|
||||
# n = 1/(-k*h*e_e)*10**-21
|
||||
# sigma_n = n*abs(sigma[0]/k)
|
||||
# print('n = ', n, '+-', sigma_n)
|
||||
# sig = 1/4.097*5/4/10**-3
|
||||
# sig_sig = sig*((5*10**-5)**2+(1/100)**2)**0.5
|
||||
# print('sigma = ', sig, '+-', sig_sig)
|
||||
# b = -sig*k*h*10**4
|
||||
# sig_b = b*((sig_sig/sig)**2+(sigma[0]/k)**2)**0.5
|
||||
# print('b = ', b, '+-', sig_b)
|
||||
|
@ -26,7 +26,6 @@ from Abstract_window import AbstractWindow
|
||||
|
||||
|
||||
class ThreadData(QtCore.QThread):
|
||||
signal = QtCore.pyqtSignal(str)
|
||||
|
||||
def __init__(self, parent):
|
||||
QtCore.QThread.__init__(self)
|
||||
@ -102,7 +101,7 @@ class MainWindow(AbstractWindow):
|
||||
|
||||
def enter_a(self):
|
||||
# TODO
|
||||
self.parent.a = self.lineEdit.text()
|
||||
self.parent.a = float(self.lineEdit.text())/10**3
|
||||
self.start.setEnabled(True)
|
||||
self.lineEdit.setReadOnly(True)
|
||||
|
||||
|
@ -60,11 +60,11 @@ class ResistanceWindow(AbstractWindow):
|
||||
self.parent.change_number()
|
||||
|
||||
def enter_L(self):
|
||||
self.parent.L=self.line_L.text()
|
||||
self.parent.L=float(self.line_L.text())/1000
|
||||
self.line_L.setReadOnly(True)
|
||||
|
||||
def enter_l(self):
|
||||
self.parent.L=self.line_l.text()
|
||||
self.parent.l=float(self.line_l.text())/1000
|
||||
self.start.setEnabled(True)
|
||||
self.line_l.setReadOnly(True)
|
||||
|
||||
@ -73,6 +73,9 @@ class ResistanceWindow(AbstractWindow):
|
||||
current=10
|
||||
voltage=15
|
||||
# voltage, current = self.measure()
|
||||
|
||||
self.parent.sigma = current*self.parent.L/(voltage*self.parent.l*self.parent.a)
|
||||
self.parent.sigma_sigma = self.parent.sigma*((5*10**-5)**2+(0.0035/100)**2)**0.5
|
||||
self.current_value.setText(str(current)+', mA')
|
||||
self.voltage_value.setText(str(voltage)+', mV')
|
||||
self.menu.setEnabled(True)
|
||||
|
@ -31,7 +31,7 @@ class SignWindow(AbstractWindow):
|
||||
self.menu.clicked.connect(self.menu_clicked)
|
||||
|
||||
self.with_field = QLabel('С полем: ', self)
|
||||
self.without_field = QLabel('С полем: ', self)
|
||||
self.without_field = QLabel('Без поля: ', self)
|
||||
self.with_field_value = QLabel(self)
|
||||
self.without_field_value = QLabel(self)
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 155 KiB |
BIN
Automation/j/Graduation_chart.png
Normal file
BIN
Automation/j/Graduation_chart.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 122 KiB |
@ -1 +1,6 @@
|
||||
"B,mTl","E,mV","I_M,mA","t,ms"
|
||||
1,17.983333333333334,8.991666666666667,1079
|
||||
2,26.666666666666668,13.333333333333334,1600
|
||||
3,34.583333333333336,17.291666666666668,2075
|
||||
4,46.71666666666667,23.358333333333334,2803
|
||||
5,55.5,27.75,3330
|
||||
|
|
@ -1,6 +1,5 @@
|
||||
"U_34,mV","I_M,mA","U_0,mV","I_0,mA","E, mV",N,"t,ms"
|
||||
0.016666666666666666,0.016666666666666666,0.016666666666666666,0.00016666666666666666,0,1,1
|
||||
16.7,16.7,0.016666666666666666,0.16699999999999998,5.0,1,1002
|
||||
33.38333333333333,33.38333333333333,0.016666666666666666,0.3338333333333333,10.0,1,2003
|
||||
16.683333333333334,16.683333333333334,0.016666666666666666,0.16683333333333333,5.0,1,1001
|
||||
33.36666666666667,33.36666666666667,0.016666666666666666,0.33366666666666667,10.0,1,2002
|
||||
50.06666666666667,50.06666666666667,0.016666666666666666,0.5006666666666667,15.0,1,3004
|
||||
66.75,66.75,0.016666666666666666,0.6675,20.0,1,4005
|
||||
|
|
Loading…
Reference in New Issue
Block a user