Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Return a new Mask object
#return Mask(data)
## OTHER WAY
rel_center = self.center
x_min = - rel_center.x
x_max = x_size - rel_center.x
y_min = - rel_center.y
y_max = y_size - rel_center.y
width = 2. * self.radius.x
height = 2. * self.radius.y
fraction = rectangular_overlap_grid(x_min, x_max, y_min, y_max, x_size, y_size, width, height, self.angle.to("radian").value, 0, 1)
return Mask(fraction)
if hasattr(self, 'w'):
w = self.w
h = self.h
elif hasattr(self, 'w_out'): # annulus
w = self.w_out
h = self.h_out
h_in = self.w_in * self.h_out / self.w_out
else:
raise ValueError('Cannot determine the aperture radius.')
masks = []
for bbox, edges in zip(np.atleast_1d(self.bbox),
self._centered_edges):
ny, nx = bbox.shape
mask = rectangular_overlap_grid(edges[0], edges[1], edges[2],
edges[3], nx, ny, w, h,
self.theta, 0, subpixels)
# subtract the inner circle for an annulus
if hasattr(self, 'w_in'):
mask -= rectangular_overlap_grid(edges[0], edges[1], edges[2],
edges[3], nx, ny, self.w_in,
h_in, self.theta, 0,
subpixels)
masks.append(ApertureMask(mask, bbox))
if self.isscalar:
return masks[0]
else:
return masks
# Return a new Mask object
#return Mask(data)
## OTHER WAY
rel_center = self.center
x_min = - rel_center.x
x_max = x_size - rel_center.x
y_min = - rel_center.y
y_max = y_size - rel_center.y
width = 2. * self.radius.x
height = 2. * self.radius.y
fraction = rectangular_overlap_grid(x_min, x_max, y_min, y_max, x_size, y_size, width, height, self.angle.to("radian").value, 0, 1)
return Mask(fraction)
# Return a new Mask object
#return Mask(data)
## OTHER WAY
rel_center = self.center
x_min = - rel_center.x
x_max = x_size - rel_center.x
y_min = - rel_center.y
y_max = y_size - rel_center.y
width = 2. * self.radius.x
height = 2. * self.radius.y
fraction = rectangular_overlap_grid(x_min, x_max, y_min, y_max, x_size, y_size, width, height, self.angle.to("radian").value, 0, 1)
return Mask(fraction)
h = self.h_out
h_in = self.w_in * self.h_out / self.w_out
else:
raise ValueError('Cannot determine the aperture radius.')
masks = []
for bbox, edges in zip(np.atleast_1d(self.bbox),
self._centered_edges):
ny, nx = bbox.shape
mask = rectangular_overlap_grid(edges[0], edges[1], edges[2],
edges[3], nx, ny, w, h,
self.theta, 0, subpixels)
# subtract the inner circle for an annulus
if hasattr(self, 'w_in'):
mask -= rectangular_overlap_grid(edges[0], edges[1], edges[2],
edges[3], nx, ny, self.w_in,
h_in, self.theta, 0,
subpixels)
masks.append(ApertureMask(mask, bbox))
if self.isscalar:
return masks[0]
else:
return masks
x_min, x_max, y_min, y_max = extent
x_pmin, x_pmax, y_pmin, y_pmax = phot_extent
if method in ('center', 'subpixel'):
if method == 'center':
method = 'subpixel'
subpixels = 1
from ..geometry import rectangular_overlap_grid
for i in range(len(positions)):
if ood_filter[i] is not True:
fractions[y_min[i]: y_max[i], x_min[i]: x_max[i], i] = \
rectangular_overlap_grid(x_pmin[i], x_pmax[i],
y_pmin[i], y_pmax[i],
x_max[i] - x_min[i],
y_max[i] - y_min[i],
w, h, theta, 0, subpixels)
if w_in is not None:
h_in = w_in * h / w
fractions[y_min[i]: y_max[i], x_min[i]: x_max[i], i] -= \
rectangular_overlap_grid(x_pmin[i], x_pmax[i],
y_pmin[i], y_pmax[i],
x_max[i] - x_min[i],
y_max[i] - y_min[i],
w_in, h_in, theta,
0, subpixels)
return np.squeeze(fractions)
method = 'subpixel'
subpixels = 1
from ..geometry import rectangular_overlap_grid
for i in range(len(flux)):
if not np.isnan(flux[i]):
fraction = rectangular_overlap_grid(x_pmin[i], x_pmax[i],
y_pmin[i], y_pmax[i],
x_max[i] - x_min[i],
y_max[i] - y_min[i],
w, h, theta, 0, subpixels)
if w_in is not None:
h_in = w_in * h / w
fraction -= rectangular_overlap_grid(x_pmin[i], x_pmax[i],
y_pmin[i], y_pmax[i],
x_max[i] - x_min[i],
y_max[i] - y_min[i],
w_in, h_in, theta,
0, subpixels)
flux[i] = np.sum(data[y_min[i]:y_max[i],
x_min[i]:x_max[i]] * fraction)
if error is not None:
fluxvar[i] = find_fluxvar(data, fraction, error,
flux[i], x_min[i], x_max[i],
y_min[i], y_max[i],
pixelwise_error)
if error is None:
return (flux, )
return (flux, )
x_min, x_max, y_min, y_max = extent
x_pmin, x_pmax, y_pmin, y_pmax = phot_extent
if method in ('center', 'subpixel'):
if method == 'center':
method = 'subpixel'
subpixels = 1
from ..geometry import rectangular_overlap_grid
for i in range(len(flux)):
if not np.isnan(flux[i]):
fraction = rectangular_overlap_grid(x_pmin[i], x_pmax[i],
y_pmin[i], y_pmax[i],
x_max[i] - x_min[i],
y_max[i] - y_min[i],
w, h, theta, 0, subpixels)
if w_in is not None:
h_in = w_in * h / w
fraction -= rectangular_overlap_grid(x_pmin[i], x_pmax[i],
y_pmin[i], y_pmax[i],
x_max[i] - x_min[i],
y_max[i] - y_min[i],
w_in, h_in, theta,
0, subpixels)
flux[i] = np.sum(data[y_min[i]:y_max[i],
x_min[i]:x_max[i]] * fraction)
if error is not None:
from ..geometry import rectangular_overlap_grid
for i in range(len(positions)):
if ood_filter[i] is not True:
fractions[y_min[i]: y_max[i], x_min[i]: x_max[i], i] = \
rectangular_overlap_grid(x_pmin[i], x_pmax[i],
y_pmin[i], y_pmax[i],
x_max[i] - x_min[i],
y_max[i] - y_min[i],
w, h, theta, 0, subpixels)
if w_in is not None:
h_in = w_in * h / w
fractions[y_min[i]: y_max[i], x_min[i]: x_max[i], i] -= \
rectangular_overlap_grid(x_pmin[i], x_pmax[i],
y_pmin[i], y_pmax[i],
x_max[i] - x_min[i],
y_max[i] - y_min[i],
w_in, h_in, theta,
0, subpixels)
return np.squeeze(fractions)