Exemplo n.º 1
0
 def map(self, L, x, y):
     dd = 1.0 / (2.0**(int(L)))
     relx = int(x) * dd
     rely = int(y) * dd
     DW = (self.ds.domain_right_edge - self.ds.domain_left_edge)
     xl = self.ds.domain_left_edge[0] + relx * DW[0]
     yl = self.ds.domain_left_edge[1] + rely * DW[1]
     xr = xl + dd * DW[0]
     yr = yl + dd * DW[1]
     frb = FixedResolutionBuffer(self.data, (xl, xr, yl, yr), (256, 256))
     cmi, cma = get_color_bounds(
         self.data['px'], self.data['py'], self.data['pdx'],
         self.data['pdy'], self.data[self.field],
         self.ds.domain_left_edge[0], self.ds.domain_right_edge[0],
         self.ds.domain_left_edge[1], self.ds.domain_right_edge[1],
         dd * DW[0] / (64 * 256), dd * DW[0])
     if self.ds._get_field_info(self.field).take_log:
         cmi = np.log10(cmi)
         cma = np.log10(cma)
         to_plot = apply_colormap(np.log10(frb[self.field]),
                                  color_bounds=(cmi, cma))
     else:
         to_plot = apply_colormap(frb[self.field], color_bounds=(cmi, cma))
     rv = write_png_to_string(to_plot)
     return rv
 def map(self, L, x, y):
     dd = 1.0 / (2.0**(int(L)))
     relx = int(x) * dd
     rely = int(y) * dd
     DW = (self.ds.domain_right_edge - self.ds.domain_left_edge)
     xl = self.ds.domain_left_edge[0] + relx * DW[0]
     yl = self.ds.domain_left_edge[1] + rely * DW[1]
     xr = xl + dd*DW[0]
     yr = yl + dd*DW[1]
     frb = FixedResolutionBuffer(self.data, (xl, xr, yl, yr), (256, 256))
     cmi, cma = get_color_bounds(self.data['px'], self.data['py'],
                                 self.data['pdx'], self.data['pdy'],
                                 self.data[self.field],
                                 self.ds.domain_left_edge[0],
                                 self.ds.domain_right_edge[0],
                                 self.ds.domain_left_edge[1],
                                 self.ds.domain_right_edge[1],
                                 dd*DW[0] / (64*256),
                                 dd*DW[0])
     if self.ds._get_field_info(self.field).take_log:
         cmi = np.log10(cmi)
         cma = np.log10(cma)
         to_plot = apply_colormap(np.log10(frb[self.field]), color_bounds = (cmi, cma))
     else:
         to_plot = apply_colormap(frb[self.field], color_bounds = (cmi, cma))
     rv = write_png_to_string(to_plot)
     return rv
Exemplo n.º 3
0
    def map(self, field, L, x, y):
        if "," in field:
            field = tuple(field.split(","))
        cmap = self.cmap
        dd = 1.0 / (2.0**(int(L)))
        relx = int(x) * dd
        rely = int(y) * dd
        DW = self.ds.domain_right_edge - self.ds.domain_left_edge
        xl = self.ds.domain_left_edge[0] + relx * DW[0]
        yl = self.ds.domain_left_edge[1] + rely * DW[1]
        xr = xl + dd * DW[0]
        yr = yl + dd * DW[1]
        try:
            self.lock()
            w = 256  # pixels
            data = self.data[field]
            frb = FixedResolutionBuffer(self.data, (xl, xr, yl, yr), (w, w))
            cmi, cma = get_color_bounds(
                self.data["px"],
                self.data["py"],
                self.data["pdx"],
                self.data["pdy"],
                data,
                self.ds.domain_left_edge[0],
                self.ds.domain_right_edge[0],
                self.ds.domain_left_edge[1],
                self.ds.domain_right_edge[1],
                dd * DW[0] / (64 * 256),
                dd * DW[0],
            )
        finally:
            self.unlock()

        if self.takelog:
            cmi = np.log10(cmi)
            cma = np.log10(cma)
            to_plot = apply_colormap(np.log10(frb[field]),
                                     color_bounds=(cmi, cma),
                                     cmap_name=cmap)
        else:
            to_plot = apply_colormap(frb[field],
                                     color_bounds=(cmi, cma),
                                     cmap_name=cmap)

        rv = write_png_to_string(to_plot)
        return rv
Exemplo n.º 4
0
    def map(self, field, L, x, y):
        if ',' in field:
            field = tuple(field.split(','))
        dd = 1.0 / (2.0**(int(L)))
        relx = int(x) * dd
        rely = int(y) * dd
        DW = (self.ds.domain_right_edge - self.ds.domain_left_edge)
        xl = self.ds.domain_left_edge[0] + relx * DW[0]
        yl = self.ds.domain_left_edge[1] + rely * DW[1]
        xr = xl + dd*DW[0]
        yr = yl + dd*DW[1]
        try:
            self.lock()
            data = self.data[field]
            frb = FixedResolutionBuffer(self.data, (xl, xr, yl, yr), (256, 256))
            cmi, cma = get_color_bounds(self.data['px'], self.data['py'],
                                        self.data['pdx'], self.data['pdy'],
                                        data,
                                        self.ds.domain_left_edge[0],
                                        self.ds.domain_right_edge[0],
                                        self.ds.domain_left_edge[1],
                                        self.ds.domain_right_edge[1],
                                        dd*DW[0] / (64*256),
                                        dd*DW[0])
        finally:
            self.unlock()

        if self.takelog:
            cmi = np.log10(cmi)
            cma = np.log10(cma)
            to_plot = apply_colormap(np.log10(frb[field]), color_bounds = (cmi, cma))
        else:
            to_plot = apply_colormap(frb[field], color_bounds = (cmi, cma))

        rv = write_png_to_string(to_plot)
        return rv