"# function that generates a grid of rectangles over a given rooftop. The grids are always started from the bottom-left corner of the (south-facing) rooftop\n",
"# \"rooftop\" must have the following attributes:\n",
"# - n_rows, n_cols: number of rows and columns of grid to be created, respectively\n",
"# - cell_width, cell_height: PROJECTED width and height of cells (original height multiplied by panel_tilt)\n",
"# - origin_x_rot, origin_y_rot: bottom left corner of the roof if rotated to face south\n",
"# - TILT_FIELD: tilt of rooftop (different rule of placing panels for flat and for tilted roofs)\n",
" \n",
" # get input parameters\n",
" split_x = int(rooftop.n_cols) # number of splits in x-direction\n",
" split_y = int(rooftop.n_rows) # number of splits in y-direction\n",
" \n",
" # define x and y coordinates of grid corners\n",
" y_coords = [ float(rooftop.origin_y) + i * float(rooftop.cell_height) for i in range( split_y + 1 )]\n",
" x_coords = [ float(rooftop.origin_x) + i * float(rooftop.cell_width) for i in range( split_x + 1 )]\n",
"\n",
" # if roof is flat, skip every other row:\n",
" if rooftop[TILT_FIELD].values[0] == 0:\n",
" range_y = range(0, split_y, 2)\n",
" else:\n",
" range_y = range(split_y)\n",
"\n",
" # loop through all polygons and append coordinates of each corner (generate \"fishnet\")\n",