Exemplo n.º 1
0
from slimscat import run_slimscat, generate_screen
import os
from scipy import misc
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image

# generate scattering file
if not os.path.isfile('gargantua_screen.bin'):
  generate_screen(wavelength=0.87e-6,dx=0.2,ips=4,screenfile='gargantua_screen.bin')

# load RGB image with rough scale appropriate for Sgr A*
model = misc.imread('gargantua.jpg'); dx = 50./350
nx,ny,nchan = model.shape

# scatter each rgb channel separately (using same screen)
r = run_slimscat(model[:,:,0],dx,screenfile='gargantua_screen.bin')
g = run_slimscat(model[:,:,1],dx,screenfile='gargantua_screen.bin')
b = run_slimscat(model[:,:,1],dx,screenfile='gargantua_screen.bin')

# construct rgb image
rgb = np.dstack((r,g,b))
rgb[rgb < 0] = 0
rgb = (255 / rgb.max()* rgb).astype(np.uint8)
img = Image.fromarray(rgb)
img.save('scattered_gargantua.jpg')
def initialize(m, dx, screenfile='gaussian_screen.bin'):
    # generate screen
    slimscat.generate_screen(screenfile=screenfile, dx=dx)
    return slimscat.run_slimscat(m, dx, screenfile=screenfile)
def initialize(m,dx,screenfile='gaussian_screen.bin'):
    # generate screen
    slimscat.generate_screen(screenfile=screenfile,dx=dx)
    return slimscat.run_slimscat(m,dx,screenfile=screenfile)
Exemplo n.º 4
0
from slimscat import generate_screen,run_slimscat
import matplotlib.pyplot as plt
import numpy as np
import os

# gaussian source
nx,ny = 220,256
yy,xx = np.meshgrid(np.arange(ny)-ny/2,np.arange(nx)-nx/2,indexing='ij')
isrc = np.exp(-0.5*(xx**2 + yy**2) / (0.07*np.min([nx,ny]))**2)

# generate screen
if not os.path.isfile('gaussian_screen.bin'):
  generate_screen(screenfile='gaussian_screen.bin')

# scatter source
iss = run_slimscat(isrc,1.,screenfile='gaussian_screen.bin')

# show result
fig,axs = plt.subplots(ncols=2)
axs[0].imshow(isrc,interpolation='nearest',cmap='hot')
axs[0].set_title('source')
axs[1].imshow(iss,interpolation='nearest',cmap='hot')
axs[1].set_title('scattered')
plt.tight_layout()
plt.savefig('gaussian.png')