Beispiel #1
0
    def grid(self, rows=11, cols=11, lbrt=None, situated=False, **kwargs):
        xdensity, ydensity = self.dest.xdensity, self.dest.ydensity
        l, b, r, t = self.dest.bounds.lbrt()
        half_x_unit = ((r - l) / xdensity) / 2.
        half_y_unit = ((t - b) / ydensity) / 2.
        if lbrt is None:
            l, b, r, t = (l + half_x_unit, b + half_y_unit, r - half_x_unit,
                          t - half_y_unit)
        else:
            l, b = self.dest.closest_cell_center(lbrt[0], lbrt[1])
            r, t = self.dest.closest_cell_center(lbrt[2], lbrt[3])
        x, y = np.meshgrid(np.linspace(l, r, cols), np.linspace(b, t, rows))
        coords = zip(x.flat, y.flat)

        grid_items = {}
        for x, y in coords:
            grid_items[x, y] = self.view(x, y, situated=situated, **kwargs)

        grid = GridSpace(grid_items,
                         label=' '.join([self.dest.name, self.name]),
                         group='CFs')
        grid.metadata = AttrDict(info=self.name,
                                 proj_src_name=self.src.name,
                                 proj_dest_name=self.dest.name,
                                 timestamp=self.src.simulation.time(),
                                 **kwargs)
        return grid
Beispiel #2
0
    def grid(self, rows=11, cols=11, lbrt=None, situated=False, **kwargs):
        xdensity, ydensity = self.dest.xdensity, self.dest.ydensity
        l, b, r, t = self.dest.bounds.lbrt()
        half_x_unit = ((r-l) / xdensity) / 2.
        half_y_unit = ((t-b) / ydensity) / 2.
        if lbrt is None:
            l, b, r, t = (l+half_x_unit, b+half_y_unit, r-half_x_unit, t-half_y_unit)
        else:
            l, b = self.dest.closest_cell_center(lbrt[0], lbrt[1])
            r, t = self.dest.closest_cell_center(lbrt[2], lbrt[3])
        x, y = np.meshgrid(np.linspace(l, r, cols),
                           np.linspace(b, t, rows))
        coords = zip(x.flat, y.flat)

        grid_items = {}
        for x, y in coords:
            grid_items[x, y] = self.view(x, y, situated=situated, **kwargs)

        grid = GridSpace(grid_items, label=' '.join([self.dest.name, self.name]),
                         group='CFs')
        grid.metadata = AttrDict(info=self.name,
                                 proj_src_name=self.src.name,
                                 proj_dest_name=self.dest.name,
                                 timestamp=self.src.simulation.time(),
                                 **kwargs)
        return grid
Beispiel #3
0
 def _cf_grid(self, shape=None, **kwargs):
     "Create GridSpace with the correct metadata."
     grid = GridSpace({})
     grid.metadata = AttrDict(timestamp=self.src.simulation.time(),
                              info=self.name,
                              proj_src_name=self.src.name,
                              proj_dest_name=self.dest.name,
                              **kwargs)
     return grid
Beispiel #4
0
 def _cf_grid(self, shape=None, **kwargs):
     "Create GridSpace with the correct metadata."
     grid = GridSpace({})
     grid.metadata = AttrDict(timestamp=self.src.simulation.time(),
                              info=self.name,
                              proj_src_name=self.src.name,
                              proj_dest_name=self.dest.name,
                              **kwargs)
     return grid