def test_noise_map(self): noise_map = np.ones((self.numPix, self.numPix)) kwargs_noise = { 'image_data': np.zeros((self.numPix, self.numPix)), 'exposure_time': 1, 'background_rms': 1, 'noise_map': noise_map, 'verbose': True } noise = ImageNoise(**kwargs_noise) noise_map_out = noise.C_D npt.assert_almost_equal(noise_map_out, noise_map, decimal=8) noise_map_out = noise.C_D_model(model=np.ones((self.numPix, self.numPix))) npt.assert_almost_equal(noise_map_out, noise_map, decimal=8) kwargs_noise = { 'image_data': np.zeros((self.numPix, self.numPix)), 'exposure_time': 1, 'noise_map': noise_map, 'verbose': True } noise = ImageNoise(**kwargs_noise) bkg = noise.background_rms npt.assert_almost_equal(bkg, np.median(noise_map))
def __init__(self, image_data, exposure_time=None, background_rms=None, noise_map=None, ra_at_xy_0=0, dec_at_xy_0=0, transform_pix2angle=None, ra_shift=0, dec_shift=0): """ :param image_data: 2d numpy array of the image data :param exposure_time: int or array of size the data; exposure time (common for all pixels or individually for each individual pixel) :param background_rms: root-mean-square value of Gaussian background noise :param noise_map: int or array of size the data; joint noise sqrt(variance) of each individual pixel. :param transform_pix2angle: 2x2 matrix, mapping of pixel to coordinate :param ra_at_xy_0: ra coordinate at pixel (0,0) :param dec_at_xy_0: dec coordinate at pixel (0,0) :param ra_shift: RA shift of pixel grid :param dec_shift: DEC shift of pixel grid """ nx, ny = np.shape(image_data) self._data = image_data if transform_pix2angle is None: transform_pix2angle = np.array([[1, 0], [0, 1]]) PixelGrid.__init__(self, nx, ny, transform_pix2angle, ra_at_xy_0 + ra_shift, dec_at_xy_0 + dec_shift) ImageNoise.__init__(self, image_data, exposure_time=exposure_time, background_rms=background_rms, noise_map=noise_map, verbose=False)
def setup(self): self.numPix = 10 kwargs_noise = {'image_data': np.zeros((self.numPix, self.numPix)), 'exposure_time': 1, 'background_rms': 1, 'noise_map': None, 'verbose': True} self.Noise = ImageNoise(**kwargs_noise) kwargs_noise = {'image_data': np.zeros((self.numPix, self.numPix)), 'exposure_time': np.ones((self.numPix, self.numPix)), 'background_rms': 1, 'noise_map': None, 'verbose': True} noise = ImageNoise(**kwargs_noise)
def test_gradient_boost(self): kwargs_noise = { 'image_data': np.zeros((self.numPix, self.numPix)), 'exposure_time': 1000000000000, 'background_rms': 1, 'noise_map': None, 'gradient_boost_factor': 1., 'verbose': True } noise = ImageNoise(**kwargs_noise) model = np.zeros((self.numPix, self.numPix)) CD_zero = noise.C_D_model(model) model = np.ones((self.numPix, self.numPix)) CD_one = noise.C_D_model(model) npt.assert_almost_equal(CD_zero, CD_one)
def test_raise(self): kwargs_noise = {'image_data': np.zeros((10, 10)), 'exposure_time': None, 'background_rms': None, 'noise_map': None, 'verbose': True} noise = ImageNoise(**kwargs_noise) with self.assertRaises(ValueError): out = noise.background_rms with self.assertRaises(ValueError): out = noise.exposure_map
def test_exposure_time(self): kwargs_noise = { 'image_data': np.zeros((self.numPix, self.numPix)), 'exposure_time': 0., 'background_rms': 1, 'noise_map': None, 'verbose': True } noise = ImageNoise(**kwargs_noise) exp_map = noise.exposure_map assert exp_map > 0