def find_regions(self): """Find reflected regions.""" curr_angle = self._angle + self._min_ang + self.min_distance_input reflected_regions = [] while curr_angle < self._max_angle: test_pos = self._compute_xy(self._pix_center, self._offset, curr_angle) test_reg = CirclePixelRegion(test_pos, self._pix_region.radius) if not self._is_inside_exclusion(test_reg, self._distance_image): refl_region = test_reg.to_sky(self.exclusion_mask.wcs) log.debug('Placing reflected region\n{}'.format(refl_region)) reflected_regions.append(refl_region) curr_angle = curr_angle + self._min_ang else: curr_angle = curr_angle + self.angle_increment log.info('Found {} reflected regions'.format(len(reflected_regions))) self.reflected_regions = reflected_regions
def find_regions(self): """Find reflected regions.""" curr_angle = self._angle + self._min_ang + self.min_distance_input reflected_regions = [] while curr_angle < self._max_angle: test_pos = self._compute_xy(self._pix_center, self._offset, curr_angle) test_reg = CirclePixelRegion(test_pos, self._pix_region.radius) if not self._is_inside_exclusion(test_reg, self._distance_image): refl_region = test_reg.to_sky(self.reference_map.geom.wcs) log.debug("Placing reflected region\n{}".format(refl_region)) reflected_regions.append(refl_region) curr_angle = curr_angle + self._min_ang if self.max_region_number <= len(reflected_regions): break else: curr_angle = curr_angle + self.angle_increment log.debug("Found {} reflected regions".format(len(reflected_regions))) self.reflected_regions = reflected_regions
def test_region_mask(): mask = SkyImage.empty(nxpix=5, nypix=4) # Test with a pixel region region = CirclePixelRegion(center=PixCoord(x=2, y=1), radius=1.1) actual = mask.region_mask(region) expected = [ [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], ] assert_equal(actual.data, expected) # Test with a sky region # Output is the same in this case, because the sky region # represents roughly the same region as the pixel region sky_region = region.to_sky(wcs=mask.wcs) actual = mask.region_mask(sky_region) assert_equal(actual.data, expected)