Matthew Turk avatar Matthew Turk committed 07d28cf

Adding an image array

Comments (0)

Files changed (2)

         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])
 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()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.