Exemplo n.º 1
0
 def show_array(self, ):
     """Preview Array configuration on roof using matplotlib."""
     shading = self.shading
     pv_panel = self.pv_panel
     offset_x, offset_y = self.offset_x, self.offset_y
     fig, ax = plt.subplots(figsize=(14, 10))
     ax.imshow(shading.avg,
               extent=(0, shading.dim_x, shading.dim_y, 0),
               alpha=.7)
     if self.grid is None:
         grid_shape = self.grid_shape
         grid = -1 * np.ones(grid_shape).T
         coords = np.argwhere(grid > -2)
     else:
         grid = self.grid
     coords = np.argwhere(grid > -2)
     ax.plot(self.offset_x, self.offset_y, 'x', markersize=20, color='red')
     for x, y in coords:
         string = int(grid[x, y])
         alpha = .5 + .5 * int(string > -1)
         rect = Rectangle(
             (pv_panel.dim_x * x + offset_x, pv_panel.dim_y * y + offset_y),
             pv_panel.dim_x,
             pv_panel.dim_y,
             fill=None,
             alpha=alpha)
         bound = rect.get_extents()
         center = np.average(bound, axis=0)
         ax.add_patch(rect)
         ax.text(*center,
                 '({},{})\nStr: {}'.format(x, y, string),
                 horizontalalignment='center',
                 verticalalignment='center',
                 fontsize=12,
                 color='black',
                 alpha=alpha)
     return fig, ax