def test_capacity_based_roof_model_sums_to_one(self, roof_model_area_based): roof_model_capacity_based = area_to_capacity(roof_model_area_based, power_density_flat=1, power_density_tilted=2) assert roof_model_capacity_based["share_of_roof_areas"].sum( ) == pytest.approx(1.0)
def test_weight_of_flat_increased_for_higher_power_density( self, roof_model_area_based): roof_model_capacity_based = area_to_capacity(roof_model_area_based, power_density_flat=2, power_density_tilted=1) capacity_weight = float(roof_model_capacity_based.loc[("flat", 0.0)]) area_weight = float(roof_model_area_based.loc[("flat", 0.0)]) assert capacity_weight > area_weight
def test_weight_of_flat_reduced_for_lower_power_density( self, roof_model_area_based): roof_model_capacity_based = area_to_capacity(roof_model_area_based, power_density_flat=1, power_density_tilted=2) capacity_weight = float(roof_model_capacity_based.loc[("flat", 0.0)]) area_weight = float(roof_model_area_based.loc[("flat", 0.0)]) assert capacity_weight < area_weight
def pv_simulation_parameters(path_to_shapes_of_land_surface, path_to_roof_categories, bounds, ninja, maximum_power_density, path_to_output): """Create PV simulation input for renewables.ninja.""" points = point_raster_on_shapes( bounds_wgs84=bounds, shapes=gpd.read_file(path_to_shapes_of_land_surface), resolution_km2=ninja["resolution-grid"]) roof_categories = pd.read_csv(path_to_roof_categories, index_col=[0, 1]) roof_categories = area_to_capacity( roof_categories, power_density_flat=maximum_power_density["pv-on-flat-areas"], power_density_tilted=maximum_power_density["pv-on-tilted-roofs"] ).reset_index() lat_long = pd.DataFrame( data={ "lat": [point.y for point in points.geometry], "long": [point.x for point in points.geometry] }) index = pd.MultiIndex.from_product((points.index, roof_categories.index), names=["id", "roof_cat_id"]) data = pd.DataFrame(index=index).reset_index() data = data.merge( roof_categories, left_on="roof_cat_id", right_index=True).rename(columns={"share_of_roof_areas": "weight"}) data = data.merge(lat_long, left_on="id", right_index=True) data["azim"] = data["orientation"].map(orientation_to_azimuth) data["site_id"] = data.id data["sim_id"] = data.apply(lambda row: "{}_{}_{}".format( row.id, row.orientation, round(row.average_tilt)), axis=1) flat_mask = data["orientation"] == "flat" data.loc[flat_mask, "average_tilt"] = data.loc[flat_mask, "lat"].map(optimal_tilt) data["pr"] = ninja["pv-performance-ratio"] data[[ "sim_id", "weight", "site_id", "lat", "long", "average_tilt", "orientation", "azim", "pr" ]].sort_index().to_csv(path_to_output, header=True, index=False)
def test_capacity_based_roof_model_equals_area_based_for_equal_power_density( self, roof_model_area_based): roof_model_capacity_based = area_to_capacity(roof_model_area_based, power_density_flat=1, power_density_tilted=1) assert_frame_equal(roof_model_capacity_based, roof_model_area_based)