Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions solveode.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def multicore_list(sc,options ={}): # sc is a dict with indices

#random.shuffle(sci) #shuffling here is not really necessary. Just adds complexity

l4 = len(sci)/4
l4 = len(sci)//4
chunks = [
sci[0:l4],
sci[l4:2*l4],
Expand Down Expand Up @@ -183,7 +183,7 @@ def deflection_array(r,angles,options = {}):
thetas = np.arange(0.01,np.pi,0.01)
deff = deflection_array(10.0,thetas,{'maxangle':2*np.pi})
for i in range(len(deff)):
print deff[i][0], (deff[i][0] - (np.pi - deff[i][1] ))
print(deff[i][0], (deff[i][0] - (np.pi - deff[i][1] )))
exit()


Expand All @@ -200,10 +200,10 @@ def deflection_array(r,angles,options = {}):
#inc = [ [b*1000,-b*(1000**2)] for b in bs ]
inc = { d : [10.,d] for d in dirs }

print "SOLVING"
print("SOLVING")
trajs = multicore_list(inc,{'maxangle':2*6.28})

print "SAVING"
print("SAVING")
for d in dirs:
f = open('curves/infall%f'%d,'w')
(l,u) = trajs[d]
Expand All @@ -227,7 +227,7 @@ def deflection_array(r,angles,options = {}):


for d in dirs:
print d
print(d)

f = open('curves/vel%f'%d,'w')

Expand Down
28 changes: 14 additions & 14 deletions tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
DARK_GREEN = np.array([0.,.2,0.])
ZERO = np.array([0,0,0])

print "loading bg.png..."
img_bg = mpimg.imread('bg.png')
print("loading ha1024.jpg...")
img_bg = mpimg.imread('tex/ha1024.jpg')

def get_bg_uv(u,v):
try:
return img_bg[int(v*2048),int(u*4096),:]
except ValueError,IndexError:
except ValueError and IndexError:
return MAGENTA

def normalize(x):
Expand Down Expand Up @@ -95,7 +95,7 @@ def bigPhi(theta):
origin = np.array([0,0,0])


print "raytracing."
print("raytracing.")


# an array of (x,y) pixel coordinates is shuffled. We want to process pixel uniformly,
Expand Down Expand Up @@ -123,7 +123,7 @@ def bigPhi(theta):
#
#
#if (checkcnt != totpix):
# print "WTF",checkcnt,totpix
# print("WTF",checkcnt,totpix)
# exit()
#
donecheck = {}
Expand All @@ -134,7 +134,7 @@ def bigPhi(theta):
#for c in chunklist:
# ccounter += 1
#
# print (100*ccounter)/NRCHNKS, "%" #print progress and refresh display
# print((100*ccounter)/NRCHNKS, "%") #print progress and refresh display
# plt.imshow(img) #between every chunk.
# plt.draw()
#
Expand All @@ -146,7 +146,7 @@ def bigPhi(theta):
# rays = {}


print "creating rays"
print("creating rays")

#compute rays
xfscales = np.linspace(-.5,.5,w)
Expand All @@ -164,36 +164,36 @@ def bigPhi(theta):

#normalizing

print "normalizing rays"
print("normalizing rays")

invnorms = 1/np.sqrt( np.einsum('ijk,ijk->ij',rays,rays))

rays = np.einsum('ijk,ij->ijk',rays,invnorms)


print "computing view angles"
print("computing view angles")

normcampos = normalize(CAMPOS)

mindots = -np.einsum('k,ijk->ij',CAMPOS,rays)

thetarr = np.arccos(mindots)

print "interpolating deflection angles"
print("interpolating deflection angles")

bigPhiArr = np.zeros((w,h))

for (x,y) in pixlist:
bigPhiArr[x,y] = bigPhi(thetarr[x,y])


print "starting rendering..."
print("starting rendering...")

pixcount = 0

for pixel in pixlist:
if (pixcount % 400 == 0):
print (100*pixcount)/len(pixlist) , "%"
print((100*pixcount)/len(pixlist) , "%")
img = np.clip(img,0.0,1.0)
plt.imshow(img)
plt.draw()
Expand Down Expand Up @@ -247,10 +247,10 @@ def bigPhi(theta):


if donecheck[(x,y)] == 0:
print "ERROR: untraced ray in postprocessing"
print("ERROR: untraced ray in postprocessing")
exit()
if donecheck[(x,y)] == 2:
print "ERROR: reprocessing pixel"
print("ERROR: reprocessing pixel")
exit()

yp = h-y-1
Expand Down