1. Matthew Turk
  2. yt.web_interactors

Commits

Matthew Turk  committed 07d28cf

Adding an image array

  • Participants
  • Parent commits e2761dc
  • Branches default

Comments (0)

Files changed (2)

File disp_types.py

View file
  • Ignore whitespace
         data = "data:image/png;base64,%s" % img_data
         return "<IMG SRC='%s' WIDTH='%s' HEIGHT='%s'>" % (
             data, value.buff_size[0], value.buff_size[1])
+
+class ImageArray(DisplayType):
+    name = "image_array"
+
+    def transmit(self, value):
+        return ""
+
+    def represent(self, value = None):
+        if value is None: return "<IMG SRC=''>"
+        to_plot = apply_colormap(value)
+        pngs = write_png_to_string(to_plot)
+        img_data = base64.b64encode(pngs)
+        data = "data:image/png;base64,%s" % img_data
+        return "<IMG SRC='%s' WIDTH='%s' HEIGHT='%s'>" % (
+            data, value.shape[0], value.shape[1])

File simple_test.py

View file
  • Ignore whitespace
 from disp_types import display_types as dt
 from interact import Interactor
 
-print vt.keys()
-
-pf = load("/home/mturk/data/JHK-DD0030/galaxy0030")
+pf = load("/home/mturk/data/DD0039/output_0039")
 
 @Interactor(coord = vt['float_range'](0.0, 1.0),
             axis = vt['item_list']('x', 'y', 'z'),
-            return_value = dt['frb'](field = "Density"))
-def slice_image(coord, axis):
+            field = vt['item_list'](*pf.h.field_list),
+            return_value = dt['image_array']())
+def slice_image(coord, axis, field):
     ax = {'x':0,'y':1,'z':2}
     sl = pf.h.slice(ax[axis], coord)
     frb = sl.to_frb(1.0, 512)
-    return frb
+    return na.log10(frb[field])
 
 slice_image.serve()