numba加速

This commit is contained in:
andrew 2023-09-23 16:15:31 +08:00
parent bdd71ac6e2
commit 9829f4b771
2 changed files with 15 additions and 17 deletions

View File

@ -19,7 +19,7 @@ from PySide6.QtGui import QPixmap, QImage
from PySide6.QtWidgets import QApplication, QMainWindow, QFileDialog, QMessageBox, QWidget, QPushButton
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
# from numba import njit
from numba import njit
from scipy import signal
from ui.Mian import Ui_mainWindow as Ui_respCoarseAlign
@ -509,7 +509,7 @@ class Data:
return canvas.buffer_rgba(), width, height
# @njit("int64[:](int64[:],int64[:])", nogil=True, parallel=True)
@njit("int64[:](int64[:],int64[:])", nogil=True, parallel=True)
def get_Correlate(a, v):
result = np.empty(len(a) - len(v) * 1 - 1, dtype=np.int64)
for i in range(len(a) - len(v) - 1):
@ -762,13 +762,12 @@ class MainWindow(QMainWindow):
v = self.data.processed_XX[
self.data.Config["XXConfig"]["PreCut"]:len(self.data.processed_XX) - self.data.Config["XXConfig"][
"PostCut"]].copy()
# a *= 100
# v *= 100
# a = a.astype(np.int64)
# v = v.astype(np.int64)
# a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant')
# tho_relate = get_Correlate(a, v) / 10000
tho_relate = np.correlate(a, v, mode='full')
a *= 100
v *= 100
a = a.astype(np.int64)
v = v.astype(np.int64)
a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant')
tho_relate = get_Correlate(a, v) / 10000
tho_relate2 = - tho_relate
self.ui.progressBar.setValue(40)
@ -780,13 +779,12 @@ class MainWindow(QMainWindow):
v = self.data.processed_XX[
self.data.Config["XXConfig"]["PreCut"]:len(self.data.processed_XX) - self.data.Config["XXConfig"][
"PostCut"]].copy()
# a *= 100
# v *= 100
# a = a.astype(np.int64)
# v = v.astype(np.int64)
# a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant')
# abd_relate = get_Correlate(a, v) / 10000
abd_relate = np.correlate(a, v, mode='full')
a *= 100
v *= 100
a = a.astype(np.int64)
v = v.astype(np.int64)
a = np.pad(a, (len(v) - 1, len(v) - 1), mode='constant')
abd_relate = get_Correlate(a, v) / 10000
abd_relate2 = - abd_relate
self.ui.progressBar.setValue(80)

View File

@ -5,4 +5,4 @@ pyedflib
matplotlib
pySide6
pyyaml
# numba
numba