Skip to content

Commit

Permalink
Squelch flake8 complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
gnn committed Nov 10, 2022
1 parent 1f4dbc3 commit 482466e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 33 deletions.
3 changes: 2 additions & 1 deletion src/egon/data/datasets/electrical_neighbours.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,8 @@ def insert_storage(capacities, session=None):
"""
)

# Add missing information suitable for eTraGo selected from scenario_parameter table
# Add missing information suitable for eTraGo selected from
# scenario_parameter table
parameters_pumped_hydro = scenario_parameters.electricity("eGon2035")[
"efficiency"
]["pumped_hydro"]
Expand Down
9 changes: 5 additions & 4 deletions src/egon/data/datasets/power_plants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from geoalchemy2 import Geometry
from sqlalchemy import (
BigInteger,
Boolean,
Column,
Float,
Integer,
Expand All @@ -19,14 +18,14 @@

from egon.data import db
from egon.data.datasets import Dataset
from egon.data.datasets.power_plants import assign_weather_data
from egon.data.datasets.power_plants.conventional import (
match_nep_no_chp,
select_nep_power_plants,
select_no_chp_combustion_mastr,
)
from egon.data.datasets.power_plants.pv_rooftop import pv_rooftop_per_mv_grid
import egon.data.config
import egon.data.datasets.power_plants.assign_weather_data as assign_weather_data
import egon.data.datasets.power_plants.pv_ground_mounted as pv_ground_mounted
import egon.data.datasets.power_plants.wind_farms as wind_onshore
import egon.data.datasets.power_plants.wind_offshore as wind_offshore
Expand Down Expand Up @@ -799,10 +798,12 @@ def allocate_other_power_plants():

# Select power plants representing carrier 'others' from MaStR files
mastr_sludge = pd.read_csv(cfg["sources"]["mastr_gsgk"]).query(
"""EinheitBetriebsstatus=='InBetrieb'and Energietraeger=='Klaerschlamm'"""
"EinheitBetriebsstatus=='InBetrieb' and Energietraeger=='Klaerschlamm'"
)
mastr_geothermal = pd.read_csv(cfg["sources"]["mastr_gsgk"]).query(
"""EinheitBetriebsstatus=='InBetrieb' and Energietraeger=='Geothermie' and Technologie == 'ORCOrganicRankineCycleAnlage'"""
"EinheitBetriebsstatus=='InBetrieb'"
" and Energietraeger=='Geothermie'"
" and Technologie == 'ORCOrganicRankineCycleAnlage'"
)

mastr_sg = mastr_sludge.append(mastr_geothermal)
Expand Down
38 changes: 18 additions & 20 deletions src/egon/data/datasets/power_plants/pv_ground_mounted.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from shapely import wkb
import geopandas as gpd
import numpy as np
import pandas as pd
import psycopg2

from egon.data import db

Expand Down Expand Up @@ -36,7 +34,7 @@ def mastr_existing_pv(path, pow_per_area):
)
df = df[df["Lage"] == "Freiflaeche"]

### examine data concerning geographical locations and drop NaNs
# examine data concerning geographical locations and drop NaNs
x1 = df["Laengengrad"].isnull().sum()
x2 = df["Breitengrad"].isnull().sum()
print(" ")
Expand Down Expand Up @@ -104,7 +102,7 @@ def mastr_existing_pv(path, pow_per_area):
v_l.loc[index] = np.NaN
mastr["voltage_level"] = v_l

### examine data concerning voltage level
# examine data concerning voltage level
x1 = mastr["voltage_level"].isnull().sum()
print(" ")
print("Examination of voltage levels in MaStR data set:")
Expand All @@ -127,7 +125,7 @@ def mastr_existing_pv(path, pow_per_area):
x3 = len(index_names)
mastr.drop(index_names, inplace=True)

### further examination
# further examination
print("Number of PVs in low voltage level: " + str(x2))
print("Number of PVs in LVMV level: " + str(x3))
print(
Expand Down Expand Up @@ -173,7 +171,7 @@ def potential_areas(con, join_buffer):

# roads and railways

### counting variable for examination
# counting variable for examination
before = len(potentials_rora)

# get small areas and create buffer for joining around them
Expand All @@ -199,7 +197,7 @@ def potential_areas(con, join_buffer):
join = gpd.GeoSeries(data=[x, y])
potentials_rora["geom"].loc[index_potentials] = join.unary_union

### examination of joining of areas
# examination of joining of areas
count_small = len(small_buffers)
count_join = len(o)
count_delete = count_small - count_join
Expand All @@ -216,7 +214,7 @@ def potential_areas(con, join_buffer):

# agriculture

### counting variable for examination
# counting variable for examination
before = len(potentials_agri)

# get small areas and create buffer for joining around them
Expand All @@ -242,7 +240,7 @@ def potential_areas(con, join_buffer):
join = gpd.GeoSeries(data=[x, y])
potentials_agri["geom"].loc[index_potentials] = join.unary_union

### examination of joining of areas
# examination of joining of areas
count_small = len(small_buffers)
count_join = len(o)
count_delete = count_small - count_join
Expand All @@ -261,7 +259,7 @@ def potential_areas(con, join_buffer):

# check intersection of potential areas

### counting variable
# counting variable
agri_vorher = len(potentials_agri)

# if areas intersect, keep road & railway potential areas and drop agricultural ones
Expand All @@ -272,7 +270,7 @@ def potential_areas(con, join_buffer):
index = o.iloc[i]
potentials_agri.drop([index], inplace=True)

### examination of intersection of areas
# examination of intersection of areas
print(" ")
print("Review function to avoid intersection of potential areas:")
print("Initial length potentials_agri: " + str(agri_vorher))
Expand Down Expand Up @@ -323,7 +321,7 @@ def select_pot_areas(mastr, potentials_pot):
# get voltage level of existing PVs
index_pv = o.index[i]
pot_sel["voltage_level"] = mastr["voltage_level"].loc[index_pv]
pot_sel = pot_sel[pot_sel["selected"] == True]
pot_sel = pot_sel[pot_sel["selected"] is True]
pot_sel.drop("selected", axis=1, inplace=True)

# drop selected existing pv parks from mastr
Expand Down Expand Up @@ -471,7 +469,7 @@ def build_additional_pv(potentials, pv, pow_per_area, con):

overlay = gpd.sjoin(centroids, distr)

### examine potential area per grid district
# examine potential area per grid district
anz = len(overlay)
anz_distr = len(overlay["index_right"].unique())
size = 137500 # m2 Fläche für > 5,5 MW: (5500 kW / (0,04 kW/m2))
Expand Down Expand Up @@ -902,7 +900,7 @@ def run_methodology(
if len(distr_i) > 0:
distr_i["nuts"] = target[target["nuts"] == i]["nuts"].iloc[0]

### examination of built PV parks per state
# examination of built PV parks per state
rora_i_mv = rora_i[rora_i["voltage_level"] == 5]
rora_i_hv = rora_i[rora_i["voltage_level"] == 4]
agri_i_mv = agri_i[agri_i["voltage_level"] == 5]
Expand Down Expand Up @@ -983,8 +981,8 @@ def run_methodology(
con,
)

### create map to show distribution of installed capacity
if show_map == True:
# create map to show distribution of installed capacity
if show_map:

# 1) eGon2035

Expand Down Expand Up @@ -1029,7 +1027,7 @@ def run_methodology(
cmap="magma_r",
legend=True,
legend_kwds={
"label": f"Installed capacity in MW",
"label": "Installed capacity in MW",
"orientation": "vertical",
},
)
Expand Down Expand Up @@ -1080,7 +1078,7 @@ def run_methodology(
cmap="magma_r",
legend=True,
legend_kwds={
"label": f"Installed capacity in MW",
"label": "Installed capacity in MW",
"orientation": "vertical",
},
)
Expand Down Expand Up @@ -1151,7 +1149,7 @@ def insert_pv_parks(
sql = "SELECT MAX(id) FROM supply.egon_power_plants"
max_id = pd.read_sql(sql, con)
max_id = max_id["max"].iat[0]
if max_id == None:
if max_id is None:
max_id = 1

pv_park_id = max_id + 1
Expand Down Expand Up @@ -1214,7 +1212,7 @@ def insert_pv_parks(
show_map=False,
)

### examination of results
# examination of results
if len(pv_per_distr) > 0:
pv_per_distr_mv = pv_per_distr[pv_per_distr["voltage_level"] == 5]
pv_per_distr_hv = pv_per_distr[pv_per_distr["voltage_level"] == 4]
Expand Down
14 changes: 9 additions & 5 deletions src/egon/data/datasets/scenario_capacities.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from egon.data.datasets import Dataset
import egon.data.config

### will be later imported from another file ###
# will be later imported from another file #
Base = declarative_base()


Expand Down Expand Up @@ -168,7 +168,8 @@ def insert_capacities_per_federal_state_nep():
# List federal state with an assigned wind offshore capacity
index_list = list(df_windoff_fs.index.values)

# Overwrite capacities in df_windoff with more accurate values from df_windoff_fs
# Overwrite capacities in df_windoff with more accurate values from
# df_windoff_fs

for state in index_list:

Expand All @@ -193,7 +194,7 @@ def insert_capacities_per_federal_state_nep():
"Haushaltswaermepumpen": "residential_rural_heat_pump",
"KWK < 10 MW": "small_chp",
}
#'Elektromobilitaet gesamt': 'transport',
# 'Elektromobilitaet gesamt': 'transport',
# 'Elektromobilitaet privat': 'transport'}

# nuts1 to federal state in Germany
Expand Down Expand Up @@ -265,7 +266,8 @@ def insert_capacities_per_federal_state_nep():
# Filter by carrier
updated = insert_data[insert_data["carrier"].isin(carriers)]

# Merge to replace capacities for carriers "oil", "other_non_renewable" and "pumped_hydro"
# Merge to replace capacities for carriers "oil",
# "other_non_renewable" and "pumped_hydro"
updated = (
updated.merge(capacities_list, on=["carrier", "nuts"], how="left")
.fillna(0)
Expand Down Expand Up @@ -702,7 +704,9 @@ def eGon100_capacities():
"OCGT": "gas",
"rural_ground_heat_pump": "residential_rural_heat_pump",
"urban_central_air_heat_pump": "urban_central_heat_pump",
"urban_central_solar_thermal": "urban_central_solar_thermal_collector",
"urban_central_solar_thermal": (
"urban_central_solar_thermal_collector"
),
},
inplace=True,
)
Expand Down
5 changes: 4 additions & 1 deletion src/egon/data/datasets/scenario_parameters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ def download_pypsa_technology_data():
sources = egon.data.config.datasets()["pypsa-technology-data"]["sources"][
"zenodo"
]
url = f"""https://zenodo.org/record/{sources['deposit_id']}/files/{sources['file']}"""
url = (
f"https://zenodo.org/record/{sources['deposit_id']}/files/"
f"{sources['file']}"
)
target_file = egon.data.config.datasets()["pypsa-technology-data"][
"targets"
]["file"]
Expand Down
4 changes: 2 additions & 2 deletions src/egon/data/datasets/storages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ def allocate_pumped_hydro_eGon100RE():
else:
raise ValueError(f"'{boundary}' is not a valid dataset boundary.")

# Get allocation of pumped_hydro plants in eGon2035 scenario as the reference
# for the distribution in eGon100RE scenario
# Get allocation of pumped_hydro plants in eGon2035 scenario as the
# reference for the distribution in eGon100RE scenario
allocation = allocate_pumped_hydro_eGon2035(export=False)

scaling_factor = capacity_phes / allocation.el_capacity.sum()
Expand Down

0 comments on commit 482466e

Please sign in to comment.