Skip to content

Commit

Permalink
add interpolation to psf data
Browse files Browse the repository at this point in the history
  • Loading branch information
LAKESIDE\LindaT18 committed Aug 22, 2019
1 parent e41bf1e commit e2f3e9a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions PythonGUI_apps/Spectrum_analysis/Spectra_plot_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import pickle
import time
from lmfit.models import GaussianModel
from scipy import interpolate
import customplotting.mscope as cpm
# local modules
try:
Expand Down Expand Up @@ -260,8 +261,18 @@ def check_loaded_files(self):
def plot(self):
try:
if self.opened_from_flim:
self.x, self.y = self.sum_data_from_flim
elif self.file is None:
flim_data = self.sum_data_from_flim.T
interp = interpolate.interp1d(flim_data[:,0], flim_data[:,1])
x_range = [flim_data[:,0][0], flim_data[:,0][-1]]
xnew = np.linspace(x_range[0], x_range[1], 100 )
ynew = interp(xnew)
self.file = np.zeros((xnew.shape[0], 2))
self.file[:,0] = xnew
self.file[:,1] = ynew
self.x = xnew
self.y = ynew

elif self.file is None: #elif
self.ui.result_textBrowser.setText("You need to load a data file.")
else:
self.x = self.file[:,0]
Expand Down Expand Up @@ -310,7 +321,10 @@ def fit_and_plot(self):
try:
self.plot()
if self.opened_from_flim:
self.file = self.sum_data_from_flim.T
self.file = np.zeros((self.x.shape[0], 2))
self.file[:,0] = self.x
self.file[:,1] = self.y

if self.ui.plot_without_bck_radioButton.isChecked(): #if plot w/o bck, create dummy bck_file
self.bck_file = np.zeros(shape=(self.file.shape[0], 2))
self.bck_file[:,0] = self.file[:,0]
Expand Down

0 comments on commit e2f3e9a

Please sign in to comment.