def get_gaussian_seeing_weighted_spec(self, x_c, y_c, radius, seeing=4):
"""
Function to extract the spectrum of a circular aperture defined by x_c, y_c and radius in spaxel space.
The spectrum is weighted by a 2d gaussian centered at the center of the aperture, with a std = seeing in spaxels
:param x_c: x coordinate of the center of the aperture (spaxel)
:param y_c: y coordiante of the center of the aperture (spaxel)
:param radius: radius of the circular aperture
:param seeing: standard deviation of the gaussian in spaxels
:return: XSpectrum1D object
"""
import scipy.ndimage.filters as fi
new_3dmask = self.get_mini_cube_mask_from_ellipse_params(x_c, y_c, radius)
w = self.wavelength
n = len(w)
fl = np.zeros(n)
sig = np.zeros(n)
self.cube.mask = new_3dmask
for wv_ii in range(n):
mask = new_3dmask[wv_ii]
center = np.zeros(mask.shape) ###Por alguna razon no funciona si cambio la asignacion a np.zeros_like(mask)
center[y_c][x_c] = 1
weigths = ma.MaskedArray(fi.gaussian_filter(center, seeing))
weigths.mask = mask
weigths = weigths / np.sum(weigths)
fl[wv_ii] = np.sum(self.cube[wv_ii] * weigths)
sig[wv_ii] = np.sqrt(np.sum(self.stat[wv_ii] * (weigths ** 2)))
self.cube.mask = self.mask_init
return XSpectrum1D.from_tuple((w, fl, sig))
评论列表
文章目录