diff --git a/solveode.py b/solveode.py index 9b2d9b9..3e23089 100644 --- a/solveode.py +++ b/solveode.py @@ -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], @@ -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() @@ -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] @@ -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') diff --git a/tracer.py b/tracer.py index 932f0b4..fe1861e 100644 --- a/tracer.py +++ b/tracer.py @@ -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): @@ -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, @@ -123,7 +123,7 @@ def bigPhi(theta): # # #if (checkcnt != totpix): -# print "WTF",checkcnt,totpix +# print("WTF",checkcnt,totpix) # exit() # donecheck = {} @@ -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() # @@ -146,7 +146,7 @@ def bigPhi(theta): # rays = {} -print "creating rays" +print("creating rays") #compute rays xfscales = np.linspace(-.5,.5,w) @@ -164,14 +164,14 @@ 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) @@ -179,7 +179,7 @@ def bigPhi(theta): thetarr = np.arccos(mindots) -print "interpolating deflection angles" +print("interpolating deflection angles") bigPhiArr = np.zeros((w,h)) @@ -187,13 +187,13 @@ def bigPhi(theta): 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() @@ -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