Commits

Matthew Turk committed 792c73b

Initial import of the zooming PopIII script.

Comments (0)

Files changed (1)

+from yt.mods import *
+from yt.utilities.amr_kdtree.api import *
+from mpi4py import MPI
+
+def lin_ramp(val,mi,ma):
+    scale = (val-mi)/(ma-mi)
+    if iterable(scale): 
+        scale[scale<0.0]=0.0
+    else:
+        scale = max(scale,0.0)
+    return scale
+
+pf = load("DD0087/DD0087")
+
+final_width = 10.0/pf['au']
+# initial_width = 10.0/pf['pc']
+initial_width = na.sqrt(3)
+initial_width = 1.0/pf['pc']
+initial_width = 0.5
+
+#v,c = pf.h.find_max("Density")
+c = na.array([0.49681812222843291, 0.49349863347742939, 0.49282695497822715])
+v = na.log10(1.59666e-10)
+min_v = -26.5
+
+#sp = pf.h.sphere("max", (100.0, 'au'))
+#L = sp.quantities["AngularMomentumVector"]()
+L = [ 0.38855402,  0.23911532, -0.88985934]
+
+def get_tf(offset):
+    tmi, tma = min_v - 1.0, v + 1.0
+    tf = ColorTransferFunction((tmi, tma), nbins=1024)
+    for i in range(-25, -10):
+        tf.sample_colormap(i - offset, 0.01, 0.01, "kamae")
+    return tf
+
+
+tf = get_tf(0.0)
+
+#tf.map_to_colormap(v - 0.5, v+1., colormap="kamae", scale_func = None)
+tf.plot('tf.png')
+
+Npix = 512
+Nframes = 40
+cam = pf.h.camera(c, L, initial_width, (Npix,Npix), tf, no_ghost=True, use_light = False)
+
+# This is super cheesy, but I am not sure how to wrap this all in parallel
+# objects.
+mine = range(Nframes)[MPI.COMM_WORLD.rank::MPI.COMM_WORLD.size]
+
+f = (initial_width/final_width)**(1.0/Nframes)
+for i in xrange(Nframes):
+    # Now we apply an offset so that it looks a bit like it's moving
+    cam.zoom(f)
+    if i not in mine: continue
+    cam.transfer_function = get_tf(float(i) / Nframes)
+    snapshot = cam.snapshot()
+    write_bitmap(snapshot, "frames/zoom_%04i.png" % i,
+                 max_val = 4.0*snapshot.std())
+