Exemple #1
0
# Convert to pixels

ipos = int(round(xpos / ys))
jpos = int(round(-ypos / ys))
rpix = rad / ys

src = aux.cgs(ny, rpix, jpos, ipos)  # Source plane
b = np.zeros((nx, nx))  # Image plane

### RAYTRACER ###

j1, j2 = np.mgrid[0:nx, 0:nx]
x1 = -xl + j2 * xs
x2 = -xl + j1 * xs

y1, y2 = aux.pt_lens(x1, x2, xlens + 0.1, ylens, mlens)
i2 = np.round((y1 + yl) / ys)
i1 = np.round((y2 + yl) / ys)

ind = (i1 >= 0) & (i1 < ny) & (i2 >= 0) & (i2 < ny)

i1n = i1[ind]
i2n = i2[ind]
j1n = j1[ind]
j2n = j2[ind]

for i in np.arange(np.size(i1n)):
    b[int(j1n[i]), int(j2n[i])] = src[int(i1n[i]), int(i2n[i])]

### PLOT ###
Exemple #2
0
                    j_src)  # Source is circular gaussian
img_plane = np.zeros((n_img, n_img))  # Image plane is empty

### RAYTRACE ###

mapped = 0
unmapped = 0

for a in range(n_img):
    for b in range(n_img):
        # Image pixels to coordinates
        x_coord = -rmap_img + b * px_img
        y_coord = -rmap_img + a * px_img

        # Deflection by point source
        x_def, y_def = aux.pt_lens(x_coord, y_coord, x_lens, y_lens, m_lens)

        # Coordinates back to pixels
        y_px = int(round((x_def + rmap_src) / px_src))
        x_px = int(round((y_def + rmap_src) / px_src))

        # If a ray hits a pixel within the source, map that pixel on the image plane
        # and count pixels which do map
        if ((y_px >= 0) and (y_px < n_src) and (x_px >= 0) and (x_px < n_src)):
            img_plane[a, b] = src_plane[x_px, y_px]
            mapped += 1
        else:
            unmapped += 1

### PLOTS ###