Commit fe8eea7e authored by whooie's avatar whooie
Browse files

adjust ROI for new Flir camera setup

parent 80145555
......@@ -11,11 +11,15 @@ import toml
import warnings
import PIL.Image
import lib.plotdefs as pd
from lib.plotdefs import S
import lib.dataio as io
H = 6.626070040e-34
C = 2.99792458e+8
ROI = [932, 729, 155, 125] # [x, y, w, h]
ROI_s = (S[ROI[1]:ROI[1] + ROI[3]], S[ROI[0]:ROI[0] + ROI[2]])
DEF_DX = 3.45 # pixel size for Flir Grasshopper [um]
class ImagingData:
......@@ -219,12 +223,13 @@ class FluorescenceData(ImagingData):
def compute_mot_number(image, QE, gain, exposure_time, solid_angle,
detuning, intensity_parameter, k=None):
H, W = image.shape
K_h = 3.0
slice_h = pd.S[int(H / K_h) : int((K_h - 1) * H / K_h)]
K_w = 3.0
slice_w = pd.S[int(W / K_w) : int((K_w - 1) * W / K_w)]
im = image[slice_h, slice_w]
# H, W = image.shape
# K_h = 3.0
# slice_h = S[int(H / K_h) : int((K_h - 1) * H / K_h)]
# K_w = 3.0
# slice_w = S[int(W / K_w) : int((K_w - 1) * W / K_w)]
# im = image[slice_h, slice_w]
im = image[ROI_s]
if k is not None:
pd.Plotter().imshow(image).savefig(f"image_{k}.png").close()
pd.Plotter().imshow(im).savefig(f"img_{k}.png").close()
......@@ -244,7 +249,7 @@ def compute_mot_number(image, QE, gain, exposure_time, solid_angle,
N = photon_rate / scatter_rate(detuning, intensity_parameter)
return N
def lls_fit_gaussian(A, dA, k=None):
def lls_fit_gaussian(A, dA, k=None): # deprecated
"""
Assumes uniform, square dA.
"""
......@@ -274,16 +279,17 @@ def lmfit_gaussian(data, dA, k=None):
"""
Assumes uniform, square dA.
"""
i0, j0 = [k // 2 for k in data.shape]
D = data[ROI_s]
i0, j0 = [k // 2 for k in D.shape]
x0 = np.sqrt(dA) * j0
x = np.sqrt(dA) * np.arange(data.shape[1])
x = np.sqrt(dA) * np.arange(D.shape[1])
y0 = np.sqrt(dA) * i0
y = np.sqrt(dA) * np.arange(data.shape[0])
y = np.sqrt(dA) * np.arange(D.shape[0])
X, Y = np.meshgrid(x, y)
downsample = 10
sampler = pd.S[::downsample]
_data = data[sampler, sampler]
downsample = 1
sampler = S[::downsample]
_D = D[sampler, sampler]
_X = X[sampler, sampler]
_Y = Y[sampler, sampler]
......@@ -298,7 +304,7 @@ def lmfit_gaussian(data, dA, k=None):
def residual(params: lmfit.Parameters):
m = model(params)
return ((_data - m)**2).flatten()
return ((_D - m)**2).flatten()
params = lmfit.Parameters()
params.add("A", value=data.max())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment