def psf_var_convolve2(image, psf): def get_convolve2(sub_image, psf): return np.sum(sub_image * np.rot90(psf, 2)) w = FetchWindows(image, psf.shape[-1] / 2, all=True) return w.scan(get_convolve2, psf, arg_type='list').reshape(image.shape)
def gen_data_cube(fits_image, fits_data, pixel_rad, n_obj=None, rand=False): if (not isinstance(n_obj, type(None)) and (n_obj < 1 or n_obj > len(fits_data))): raise ValueError('The number of galaxies must be within 1 and the size' 'of the fits_data [%d].' % len(fits_data)) if pixel_rad < 0 or pixel_rad > fits_data.size / 2: raise ValueError('The pixel radius must be wihin 0 and half the size' 'of the fits_data [%d].' % int(fits_data.size / 2)) if rand: np.random.shuffle(fits_data) windows = FetchWindows(fits_image, pixel_rad) windows.get_pixels(fits_data[:n_obj]) return windows.scan()