Commits

Sam Skillman committed 11624ec

Adding a smooth background, increasing opaque isocontours, and an opaque core

Comments (0)

Files changed (6)

         nim = im/(nz.mean()+stdval*na.std(nz))
         nim[nim>1.0]=1.0
         nim[nim<0.0]=0.0
-        write_bitmap(nim, output_file)
+        write_bitmap(nim, output_file, transpose=False)
         del im, nim, nz
     else:
         im = pl.imread(input_file)[:,:,:3]
             del nz
         nim[:,:][nim>1.0]=1.0
         nim[:,:][nim<0.0]=0.0
-        write_bitmap(nim, output_file)
+        write_bitmap(nim, output_file, transpose=False)
         del im, nim
 
 input_files = sys.argv[1:-1]

interactive_script.py

+# First run single_dens.py
+
+cam.transfer_function = get_tf(0.0,-9.95)
+cam.snapshot()
+cam.transfer_function.map_to_colormap(-10.5-0.1, -10.5+0.1, scale=2.0, colormap='seismic')
+cam.snapshot()
+cam.save_frames('interactive')
+cam.orienter.steady_north = True
+cam.rotation(2*na.pi, 100)
+cam.save_frames('interactive')

interactive_script2.py

+_ip.magic("run single_dens.py")
+
+
+cam.transfer_function = get_tf(0.0,-9.95)
+cam.snapshot()
+cam.transfer_function.map_to_colormap(-10.5-0.1, -10.5+0.1, scale=2.0, colormap='seismic')
+cam.snapshot()
+cam.transfer_function.map_to_colormap(-10.5-0.1, -10.5+0.1, scale=2.0, colormap='Greens_r')
+cam.snapshot()
+cam.zoom(0.8)
+cam.snapshot()
+cam.rotation(2*na.pi, 10)
+cam.save_frames('interactive')
+_ip.magic("save interactive_script2.py 1-16")

interactive_work.py

+_ip.magic("run single_dens.py")
+cam.transfer_function = get_tf(0.0,-10.5)
+cam.snapshot()
+
+
+cam.transfer_function.map_to_colormap(op_val-0.1, op_val+0.1, colormap="BuPu_r", scale=3.0, scale_func = None)
+op_val = -10.5
+cam.transfer_function.map_to_colormap(op_val-0.1, op_val+0.1, colormap="BuPu_r", scale=3.0, scale_func = None)
+cam.snapshot()
+cam.transfer_function.map_to_colormap(op_val-0.1, op_val+0.1, colormap="BuPu_r", scale=6.0, scale_func = None)
+cam.snapshot()
+cam.transfer_function.map_to_colormap(op_val-0.1, op_val+0.1, colormap="BuPu_r", scale=4.0, scale_func = None)
+cam.snapshot()
+cam.transfer_function.map_to_colormap(op_val-0.1, op_val+0.1, colormap="BuPu_r", scale=5.0, scale_func = None)
+cam.snapshot()
+cam.save_frames('test_frame')
+cam.rotation(na.pi, 10)
+cam.save_frames('test_frame')
+op_val = -10.3
+cam.transfer_function.map_to_colormap(op_val-0.1, op_val+0.1, colormap="BuPu_r", scale=5.0, scale_func = None)
+cam.transfer_function = get_tf(0.0,-10.3)
+cam.transfer_function.map_to_colormap(op_val-0.1, op_val+0.1, colormap="BuPu_r", scale=5.0, scale_func = None)
+cam.snapshot()
+cam.rotation(na.pi, 1)
+cam.rotation(na.pi/2., 1)
+
+cam.transfer_function = get_tf(0.0,-10.8)
+op_val = -10.8
+cam.transfer_function.map_to_colormap(op_val-0.1, op_val+0.1, colormap="BuPu_r", scale=5.0, scale_func = None)
+cam.snapshot()
+cam.rotation(-na.pi/4., 1)
+cam.save_frames('test_frame')
+op_val = -11.0
+cam.transfer_function.map_to_colormap(op_val-0.1, op_val+0.1, colormap="BuPu_r", scale=5.0, scale_func = None)
+cam.snapshot()
+cam.save_frames('test_frame')
+cam.width[0]*pf['au']
+from yt.mods import *
+from yt.utilities.amr_kdtree.api import *
+
+def lin_ramp(val,mi,ma):
+    val, mi, ma = 10.**val, 10.**mi, 10.**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")
+
+final_width = 1.0/pf['au']
+# initial_width = 10.0/pf['pc']
+initial_width = na.sqrt(3)
+initial_width = 100.0/pf['au']
+
+#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.0
+
+#sp = pf.h.sphere("max", (100.0, 'au'))
+#L = sp.quantities["AngularMomentumVector"]()
+L = [ 0.38855402,  0.23911532, -0.88985934]
+
+def get_tf(offset, op_val=None):
+    tmi, tma = min_v - 2.0, v + 2.0
+    tf = ColorTransferFunction((min_v-3., v+3.), nbins=1024)
+    alphas = 0.01
+    cvals = range(-25, -10)
+    cvals = na.linspace(-25.5, -11.5, 15) 
+    alphas = na.logspace(-1., 0.5, len(cvals))
+
+    # Add a smooth background
+    tf.map_to_colormap(-28.0, v, colormap='kamae', scale = 1.0,
+            scale_func=lin_ramp) 
+
+    # Add isocontours
+    for i,alpha in zip(cvals, alphas):
+        tf.sample_colormap(i - offset, 0.01, alpha, "kamae", col_bounds=(min_v,v))
+
+    # Add a more opaque iso at op_val
+    if op_val is not None:
+        tf.map_to_colormap(op_val-0.1, op_val+0.1, colormap="BuPu_r", scale=5.0, scale_func = None)
+    return tf
+
+tf = get_tf(0.0, -10.8)
+
+Npix = 512
+
+interactive = False
+
+if interactive:
+    cam = pf.h.interactive_camera(c, L, initial_width, (Npix,Npix), tf, no_ghost=False )
+else:
+    cam = pf.h.camera(c, L, initial_width, (Npix,Npix), tf, no_ghost=False )
+cam.volume.load_kd_bricks()
+
+frame = 0
+if interactive:
+    cam.snapshot()
+    cam.save_frames('test_frame')
+else:
+    im = cam.snapshot()
+    write_bitmap(im, "density.png")
+
+
 from yt.mods import *
 from yt.utilities.amr_kdtree.api import *
-from mpi4py import MPI
 
 def lin_ramp(val,mi,ma):
+    val, mi, ma = 10.**val, 10.**mi, 10.**ma
     scale = (val-mi)/(ma-mi)
     if iterable(scale): 
         scale[scale<0.0]=0.0
 
 pf = load("../DD0087")
 
-final_width = 10.0/pf['au']
+final_width = 100.0/pf['au']
 # initial_width = 10.0/pf['pc']
 initial_width = na.sqrt(3)
 initial_width = 1.0/pf['pc']
-initial_width = 0.5
+initial_width = 2.0
 
 #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
+min_v = -26.0
 
 #sp = pf.h.sphere("max", (100.0, 'au'))
 #L = sp.quantities["AngularMomentumVector"]()
 L = [ 0.38855402,  0.23911532, -0.88985934]
 
-def get_tf(offset):
+def get_tf(offset, op_val=None):
     tmi, tma = min_v - 2.0, v + 2.0
-    tf = ColorTransferFunction((tmi, tma), nbins=1024)
+    tf = ColorTransferFunction((min_v-3., v+3.), nbins=1024)
     alphas = 0.01
-    for i,alpha in zip(range(-25, -10), na.logspace(-1.,0.5, 15)):
+    cvals = range(-25, -10)
+    cvals = na.linspace(-25.5, -11.5, 15) 
+    alphas = na.logspace(-1., 0.5, len(cvals))
+
+    # Add a smooth background
+    tf.map_to_colormap(-28.0, v, colormap='kamae', scale = 1.0,
+            scale_func=lin_ramp) 
+
+    # Add isocontours
+    for i,alpha in zip(cvals, alphas):
         tf.sample_colormap(i - offset, 0.01, alpha, "kamae", col_bounds=(min_v,v))
-    tf.map_to_colormap(v-0.1, v+0.1, colormap="seismic", scale=3.0, scale_func = None)
+
+    # Add a more opaque iso at op_val
+    if op_val is not None:
+        tf.map_to_colormap(op_val-0.1, op_val+0.1, colormap="BuPu_r", scale=5.0, scale_func = None)
     return tf
 
-tf = get_tf(0.0)
+tf = get_tf(0.0, -10.8)
 
 tf.plot('tf.png')
 
 Npix = 512
-Nframes = 40
-cam = pf.h.camera(c, L, initial_width, (Npix,Npix), tf, no_ghost=False, use_light = False)
+Nframes = 100 
+Nrotate = 100
+cam = pf.h.camera(c, L, initial_width, (Npix,Npix), tf, no_ghost=False)
 
 try:
     cam.volume.load_kd_bricks()
 except:
-    pass
+    cam.snapshot('frames/first_snap.png')
+    cam.volume.store_kd_bricks()
 
-#cam.snapshot()
-#cam.volume.store_kd_bricks()
-#balls
+frame = 0
+for i, snapshot in enumerate(cam.zoomin(initial_width/final_width, Nframes)):
+    write_bitmap(snapshot, "frames/zoom2_%04i.png" % (frame))
+    frame += 1
 
-# 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]
+for i, snapshot in enumerate(cam.rotation(2*na.pi, Nrotate)):
+    write_bitmap(snapshot, "frames/zoom2_%04i.png" % frame)
+    frame += 1
 
-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 < 32: continue
-    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)
-
-
+# # This is super cheesy, but I am not sure how to wrap this all in parallel
+# # objects.
+# 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)
+#     print cam.width[0]*pf['au']
+#     snapshot = cam.snapshot()
+#     write_bitmap(snapshot, "frames/zoom2_%04i.png" % (i))
+# 
+#