def determinate_seeing_from_white(self, xc, yc, halfsize):
"""
Function used to estimate the observation seeing of an exposure, fitting a gaussian to a brigth source of the image
:param xc: x coordinate in pixels of a bright source
:param yc: y coordinate in pixels of a bright source
:param halfsize: the radius of the area to fit the gaussian
:return: seeing: float
the observational seeing of the image defined as the FWHM of the gaussian
"""
hdulist = self.hdulist_white
data = hdulist[1].data
matrix_data = np.array(self.get_mini_image([xc, yc], halfsize=halfsize))
x = np.arange(0, matrix_data.shape[0], 1)
y = np.arange(0, matrix_data.shape[1], 1)
matrix_x, matrix_y = np.meshgrid(x, y)
amp_init = np.matrix(matrix_data).max()
stdev_init = 0.33 * halfsize
def tie_stddev(model): # we need this for tying x_std and y_std
xstddev = model.x_stddev
return xstddev
g_init = models.Gaussian2D(x_mean=halfsize + 0.5, y_mean=halfsize + 0.5, x_stddev=stdev_init,
y_stddev=stdev_init, amplitude=amp_init, tied={'y_stddev': tie_stddev})
fit_g = fitting.LevMarLSQFitter()
g = fit_g(g_init, matrix_x, matrix_y, matrix_data)
if (g.y_stddev < 0) or (g.y_stddev > halfsize):
raise ValueError('Cannot trust the model, please try other imput parameters.')
seeing = 2.355 * g.y_stddev * self.pixelsize.to('arcsec') # in arcsecs
print('FWHM={:.2f}'.format(seeing))
print('stddev from the 2D gaussian = {:.3f}'.format(g.y_stddev * self.pixelsize.to('arcsec')))
return seeing
评论列表
文章目录