Skip to content

Commit e2f3e9a

Browse files
author
LAKESIDE\LindaT18
committed
add interpolation to psf data
1 parent e41bf1e commit e2f3e9a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

PythonGUI_apps/Spectrum_analysis/Spectra_plot_fit.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import pickle
1818
import time
1919
from lmfit.models import GaussianModel
20+
from scipy import interpolate
2021
import customplotting.mscope as cpm
2122
# local modules
2223
try:
@@ -260,8 +261,18 @@ def check_loaded_files(self):
260261
def plot(self):
261262
try:
262263
if self.opened_from_flim:
263-
self.x, self.y = self.sum_data_from_flim
264-
elif self.file is None:
264+
flim_data = self.sum_data_from_flim.T
265+
interp = interpolate.interp1d(flim_data[:,0], flim_data[:,1])
266+
x_range = [flim_data[:,0][0], flim_data[:,0][-1]]
267+
xnew = np.linspace(x_range[0], x_range[1], 100 )
268+
ynew = interp(xnew)
269+
self.file = np.zeros((xnew.shape[0], 2))
270+
self.file[:,0] = xnew
271+
self.file[:,1] = ynew
272+
self.x = xnew
273+
self.y = ynew
274+
275+
elif self.file is None: #elif
265276
self.ui.result_textBrowser.setText("You need to load a data file.")
266277
else:
267278
self.x = self.file[:,0]
@@ -310,7 +321,10 @@ def fit_and_plot(self):
310321
try:
311322
self.plot()
312323
if self.opened_from_flim:
313-
self.file = self.sum_data_from_flim.T
324+
self.file = np.zeros((self.x.shape[0], 2))
325+
self.file[:,0] = self.x
326+
self.file[:,1] = self.y
327+
314328
if self.ui.plot_without_bck_radioButton.isChecked(): #if plot w/o bck, create dummy bck_file
315329
self.bck_file = np.zeros(shape=(self.file.shape[0], 2))
316330
self.bck_file[:,0] = self.file[:,0]

0 commit comments

Comments
 (0)