Commits

Matthew Turk  committed b2c76d0

Adding in some auto-scaling which is still a bit flaky.

  • Participants
  • Parent commits da877ce

Comments (0)

Files changed (1)

 from yt.mods import *
-pf = load("/home/mturk/Research/data/JHK-DD0030/galaxy0030")
+#pf = load("/home/mturk/Research/data/JHK-DD0030/galaxy0030")
 #pf = load("/home/mturk/Research/data/DD0250/DD0250")
-proj = pf.h.proj(2, "Density")
+pf = load("/home/mturk/Research/data/bfield_j64/DD0053/DD0053")
+proj = pf.h.proj(2, "Density", weight_field="Density")
 TS = 256
 import tempfile
 from yt.visualization.image_writer import apply_colormap
 mi = na.log10(proj["Density"][proj["Density"]>0].min())
 ma = na.log10(proj["Density"][proj["Density"]>0].max())
 
+def get_realistic_bounds(field, pdx, width):
+    # We don't want to scale to anything that's as big or bigger than the
+    # possible viewing area.  This should be unique across tiles on this level.
+    min_dx = width / TS
+    ff = na.log10(field[(pdx > min_dx / 64.0) & (pdx < width * 2.0)])
+    return ff.min(), ff.max()
+
 @bottle.route("/map/:L/:x/:y.png")
 def map(L, x, y):
     dd = TS / (128 * 2.0**int(L))
     yp = pf.domain_left_edge[1] + rely * DW[1]
     frb = FixedResolutionBuffer(proj, (xp, xp+dd*DW[0], yp, yp+dd*DW[1]), (256, 256))
     tf = tempfile.TemporaryFile()
-    to_plot = apply_colormap(na.log10(frb["Density"]), color_bounds = (mi, ma))
+    cmi, cma = get_realistic_bounds(proj["Density"], proj["pdx"], dd*DW[0])
+    to_plot = apply_colormap(na.log10(frb["Density"]), color_bounds = (cmi, cma))
     print "=="
     print 'rel', dd, relx, rely
     print 'x', xp, xp+dd*DW[0]
     print 'y', yp, yp+dd*DW[1]
-    print 'mi', mi, frb["Density"].min()
-    print 'ma', ma, frb["Density"].max()
+    print 'mi', cmi, frb["Density"].min()
+    print 'ma', cma, frb["Density"].max()
     write_png_to_file(to_plot, tf)
     tf.seek(0)
     return tf.read()