Image analysis¶
example + adding fitting methods
In [1]:
Copied!
from pyemittance.image import Image
import numpy as np
import matplotlib.pyplot as plt
from pyemittance.image import Image
import numpy as np
import matplotlib.pyplot as plt
In [2]:
Copied!
# get example data
image = np.load("./saved_images/1618446887_img.npy", allow_pickle = True)
ncol = np.load("./saved_images/1618446887_ncol.npy", allow_pickle = True)
nrow = np.load("./saved_images/1618446887_nrow.npy", allow_pickle = True)
# get example data
image = np.load("./saved_images/1618446887_img.npy", allow_pickle = True)
ncol = np.load("./saved_images/1618446887_ncol.npy", allow_pickle = True)
nrow = np.load("./saved_images/1618446887_nrow.npy", allow_pickle = True)
In [3]:
Copied!
# standard way to reshape the image array
im = Image(image, ncol, nrow)
im.reshape_im()
profx, profy = im.get_im_projection()
# standard way to reshape the image array
im = Image(image, ncol, nrow)
im.reshape_im()
profx, profy = im.get_im_projection()
In [4]:
Copied!
plt.imshow(im.proc_image)
plt.imshow(im.proc_image)
Out[4]:
<matplotlib.image.AxesImage at 0x7f6777f07970>
In [5]:
Copied!
plt.plot(profx, label="x-profile")
plt.plot(profy, label="y-profile")
plt.legend()
plt.plot(profx, label="x-profile")
plt.plot(profy, label="y-profile")
plt.legend()
Out[5]:
<matplotlib.legend.Legend at 0x7f676fd6c820>
Example of how this is called in pyemittance¶
In [6]:
Copied!
# returns: xsize, ysize, xsize_error, ysize_error, x_amplitude, y_amplitude
fit_res = im.get_sizes(method = "gaussian", show_plots = True)
xsize, ysize, xsize_error, ysize_error, x_amplitude, y_amplitude = fit_res
# returns: xsize, ysize, xsize_error, ysize_error, x_amplitude, y_amplitude
fit_res = im.get_sizes(method = "gaussian", show_plots = True)
xsize, ysize, xsize_error, ysize_error, x_amplitude, y_amplitude = fit_res
Gaussian + linear bg function example¶
In [7]:
Copied!
from pyemittance.bs_fitting_methods import fit_gaussian_linear_background
from pyemittance.bs_fitting_methods import fit_gaussian_linear_background
In [8]:
Copied!
fit_gaussian_linear_background(profx)
fit_gaussian_linear_background(profx)
Out[8]:
(array([3217.84266293, 185.43343034, 7.45136335]), array([104.61474965, 0.27784605, 0.28365575]))
In [9]:
Copied!
fit_gaussian_linear_background(profy)
fit_gaussian_linear_background(profy)
Out[9]:
(array([1991.90020444, 146.34583081, 11.56409759]), array([44.40883484, 0.29357206, 0.30790032]))
In [ ]:
Copied!