def test_known_results(self): known_results = [ ((0,0,0), numpy.zeros([0,0])), ((0,0,100), numpy.zeros([0,0])), ((1,1,0), numpy.array([[True]])), ((1,1,1), numpy.array([[False]])), ((5,1,0), numpy.array([[True],[True],[True],[True],[True]])), ((5,1,2), numpy.array([[True],[False],[False],[False],[True]])), ((1,4,0), numpy.array([[True,True,True,True]])), ((1,4,1), numpy.array([[True,False,False,True]])) ] for parameters, result in known_results: assert_array_equal(circular_mask(*parameters), result)
def test_known_results(self): known_results = [ ((0, 0, 0), numpy.zeros([0, 0])), ((0, 0, 100), numpy.zeros([0, 0])), ((1, 1, 0), numpy.array([[True]])), ((1, 1, 1), numpy.array([[False]])), ((5, 1, 0), numpy.array([[True], [True], [True], [True], [True]])), ((5, 1, 2), numpy.array([[True], [False], [False], [False], [True]])), ((1, 4, 0), numpy.array([[True, True, True, True]])), ((1, 4, 1), numpy.array([[True, False, False, True]])) ] for parameters, result in known_results: assert_array_equal(circular_mask(*parameters), result)
def _get_data(self): """Masked image data""" # We will ignore all the data which is masked for the rest of the # sourcefinding process. We build up the mask by stacking ("or-ing # together") a number of different effects: # # * A margin from the edge of the image; # * Any data outside a given radius from the centre of the image; # * Data which is "obviously" bad (equal to 0 or NaN). mask = numpy.zeros((self.xdim, self.ydim)) if self.margin: margin_mask = numpy.ones((self.xdim, self.ydim)) margin_mask[self.margin:-self.margin, self.margin:-self.margin] = 0 mask = numpy.logical_or(mask, margin_mask) if self.radius: radius_mask = utils.circular_mask(self.xdim, self.ydim, self.radius) mask = numpy.logical_or(mask, radius_mask) mask = numpy.logical_or(mask, numpy.isnan(self.rawdata)) return numpy.ma.array(self.rawdata, mask=mask)