def test_simu(): import siddon.simu as simu im = simu.fa.infoarrays2infoarray([simu.Image((1, 1)),]) obj = simu.Object((1, 1, 1)) im[:] = 0. obj[:] = 1. im2 = siddon.projector(im.copy(), obj) assert_almost_equal(im2[0], 0.39369162) im[:] = 1. obj[:] = 0. obj2 = siddon.backprojector(im, obj.copy()) assert_almost_equal(obj2[0], 0.39369162)
# object header = {'SIMPLE':True,'BITPIX':-64, 'NAXIS1':128, 'NAXIS2':128, 'NAXIS3':128, 'CRPIX1':64., 'CRPIX2':64., 'CRPIX3':64., 'CDELT1':0.02, 'CDELT2':0.02, 'CDELT3':0.02, 'CRVAL1':0., 'CRVAL2':0., 'CRVAL3':0.,} obj = siddon.simu.object_from_header(header) obj[:] = siddon.phantom.shepp_logan(obj.shape) #obj[:] = 1. # data image_header = {'n_images':10, 'SIMPLE':True, 'BITPIX':-64, 'NAXIS1':128, 'NAXIS2':128, 'CRPIX1':64, 'CRPIX2':64, 'CDELT1':6e-5, 'CDELT2':6e-5, 'CRVAL1':0., 'CRVAL2':0., } image_header['radius'] = 200. data = siddon.simu.circular_trajectory_data(**image_header) data[:] = np.zeros(data.shape) # projection t = time.time() data = siddon.projector(data, obj) print("projection time : " + str(time.time() - t)) # backprojection t = time.time() x0 = obj.copy() x0[:] = 0. x0 = siddon.backprojector(data, x0.copy()) print("backprojection time : " + str(time.time() - t))
#!/usr/bin/env python import numpy as np import os import copy import time import siddon import fitsarray as fa # data path = os.path.join(os.getenv('HOME'), 'data', '171dec08') obsrvtry = 'STEREO_A' time_window = ['2008-12-01T00:00:00.000', '2008-12-15T00:00:00.000'] time_step = 8 * 3600. # one image every time_step seconds data = siddon.secchi.read_data(path, bin_factor=8, obsrvtry=obsrvtry, time_window=time_window, time_step=time_step) # cube shape = 3 * (128,) header = {'CRPIX1':64., 'CRPIX2':64., 'CRPIX3':64., 'CDELT1':0.0234375, 'CDELT2':0.0234375, 'CDELT3':0.0234375, 'CRVAL1':0., 'CRVAL2':0., 'CRVAL3':0.,} cube = fa.zeros(shape, header=header) t = time.time() cube = siddon.backprojector(data, cube, obstacle="sun") print("backprojection time : " + str(time.time() - t))
def rmatvec(x): y = fa.fitsarray_from_header(cube_header) y[:] = 0 backprojector(x, y, obstacle=obstacle) return y
'CRPIX1':n / 2., 'CRPIX2':n / 2., 'CRPIX3':n / 2., 'CDELT1':1.5 / n, 'CDELT2':1.5 / n, 'CDELT3':1.5 / n, 'CRVAL1':0., 'CRVAL2':0., 'CRVAL3':0.,} obj = siddon.simu.object_from_header(header) #obj[:] = siddon.phantom.shepp_logan(obj.shape) obj[:] = 1. # data image_header = {'n_images':60, 'SIMPLE':True, 'BITPIX':-64, 'NAXIS1':128, 'NAXIS2':128, 'CRPIX1':64, 'CRPIX2':64, 'CDELT1':6e-5, 'CDELT2':6e-5, 'CRVAL1':0., 'CRVAL2':0., } image_header['radius'] = 200. for n_images in [10, 30, 60, 120]: print n_images image_header['n_images'] = n_images data = siddon.simu.circular_trajectory_data(**image_header) data[:] = np.zeros(data.shape) # projection t = time.time() data = siddon.projector(data, obj) print("projection time : " + str(time.time() - t)) # backprojection x0 = siddon.fa.zeros(obj.shape, header=header) t = time.time() x0 = siddon.backprojector(data, x0) print("backprojection time : " + str(time.time() - t))
def rmatvec(x): x = fa.InfoArray(data=x, header=data_header) y = xin y[:] = 0. backprojector(x, y, **kwargs) return y