Exemple #1
0
    def grid_to_buffer(self):
        from stars.core.DKDEWrapper import call_kde
        x = []
        y = []
        for i in self.query_points:
            pt = self.points[i]
            x.append(pt[0])
            y.append(pt[1])
        n = len(self.query_points)
        if n < len(self.points):
            query_points = range(n)

        arr, rows, cols, grad_min, grad_max = call_kde(
            n,
            x,
            y,
            #self.query_points,
            range(n),
            self.extent,
            self.bandwidth,
            self.cell_size,
            self.kernel,
            self.color_band,
            self.opaque * 2.55)
        #from PIL import Image
        #Image.fromarray(arr).save("test.png")
        self.bmp = wx.BitmapFromBufferRGBA(cols, rows, arr)
        #self.bmp.SaveFile("test.png", wx.BITMAP_TYPE_PNG)
        self.gradient_color_min = grad_min
        self.gradient_color_max = grad_max
Exemple #2
0
 def grid_to_buffer(self):
     from stars.core.DKDEWrapper import call_kde
     x = []
     y = []
     for i in self.query_points:
         pt = self.points[i]
         x.append(pt[0])
         y.append(pt[1])
     n = len(self.query_points)
     if n < len(self.points):
         query_points = range(n)
         
     arr,rows,cols,grad_min,grad_max = call_kde(
         n,
         x,
         y,
         #self.query_points,
         range(n),
         self.extent,
         self.bandwidth, 
         self.cell_size, 
         self.kernel, 
         self.color_band, 
         self.opaque*2.55
         )
     #from PIL import Image
     #Image.fromarray(arr).save("test.png")
     self.bmp = wx.BitmapFromBufferRGBA(cols, rows, arr)
     #self.bmp.SaveFile("test.png", wx.BITMAP_TYPE_PNG)
     self.gradient_color_min = grad_min
     self.gradient_color_max = grad_max
Exemple #3
0
    pos3 = line.rfind(' ')
    pos4 = line.find(')')
    extent.append(float(line[4:pos1]))
    extent.append(float(line[pos1+1:pos2]))
    extent.append(float(line[pos2+1:pos3]))
    extent.append(float(line[pos3+1:pos4]))
f2.close()
"""
if cellsize == "":
    w = extent[2] - extent[0]
    h = extent[1] - extent[3]
    image_w = 600
    image_h = h * image_w / w
    cellsize = max(w / image_w, h / image_h)
    std_x = std(x)
    std_y = std(y)
    Q_x = quantile(x)
    Q_y = quantile(y)
    IQR_x = Q_x[2] - Q_x[0]
    IQR_y = Q_y[2] - Q_y[0]
    h_x = 0.9 * min(std_x, IQR_x / 1.34) * pow(n, -0.2)
    h_y = 0.9 * min(std_y, IQR_y / 1.34) * pow(n, -0.2)
    bandwidth = max(h_x, h_y) * 2
else:
    cellsize = float(cellsize)
    bandwidth = float(bandwidth)

itv_pts_ids = range(n)
arr, rows, cols, gmin, gmax = call_kde(n, x, y, itv_pts_ids, extent, bandwidth, cellsize, kernel, gradient, opaque)
fromarray(arr).save("test1.png")
Exemple #4
0
    pos4 = line.find(')')
    extent.append(float(line[4:pos1]))
    extent.append(float(line[pos1+1:pos2]))
    extent.append(float(line[pos2+1:pos3]))
    extent.append(float(line[pos3+1:pos4]))
f2.close()
"""
if cellsize == "":
    w = extent[2] - extent[0]
    h = extent[1] - extent[3]
    image_w = 600
    image_h = h * image_w / w
    cellsize = max(w / image_w, h / image_h)
    std_x = std(x)
    std_y = std(y)
    Q_x = quantile(x)
    Q_y = quantile(y)
    IQR_x = Q_x[2] - Q_x[0]
    IQR_y = Q_y[2] - Q_y[0]
    h_x = 0.9 * min(std_x, IQR_x / 1.34) * pow(n, -0.2)
    h_y = 0.9 * min(std_y, IQR_y / 1.34) * pow(n, -0.2)
    bandwidth = max(h_x, h_y) * 2
else:
    cellsize = float(cellsize)
    bandwidth = float(bandwidth)

itv_pts_ids = range(n)
arr, rows, cols, gmin, gmax = call_kde(n, x, y, itv_pts_ids, extent, bandwidth,
                                       cellsize, kernel, gradient, opaque)
fromarray(arr).save("test1.png")