Skip to content

Commit

Permalink
address deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fneum committed Jan 2, 2024
1 parent e3539b0 commit 30c1a1c
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 39 deletions.
3 changes: 3 additions & 0 deletions config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ renewable:
resource:
method: wind
turbine: Vestas_V112_3MW
add_cutout_windspeed: true
capacity_per_sqkm: 3
# correction_factor: 0.93
corine:
Expand All @@ -173,6 +174,7 @@ renewable:
resource:
method: wind
turbine: NREL_ReferenceTurbine_5MW_offshore
add_cutout_windspeed: true
capacity_per_sqkm: 2
correction_factor: 0.8855
corine: [44, 255]
Expand All @@ -188,6 +190,7 @@ renewable:
resource:
method: wind
turbine: NREL_ReferenceTurbine_5MW_offshore
add_cutout_windspeed: true
capacity_per_sqkm: 2
correction_factor: 0.8855
corine: [44, 255]
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_biomass_potentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def disaggregate_nuts0(bio):
# get population in nuts2
pop_nuts2 = pop.loc[pop.index.str.len() == 4]
by_country = pop_nuts2.total.groupby(pop_nuts2.ct).sum()
pop_nuts2["fraction"] = pop_nuts2.total / pop_nuts2.ct.map(by_country)
pop_nuts2.loc[:, "fraction"] = pop_nuts2.total / pop_nuts2.ct.map(by_country)

# distribute nuts0 data to nuts2 by population
bio_nodal = bio.loc[pop_nuts2.ct]
Expand Down
56 changes: 28 additions & 28 deletions scripts/build_energy_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,26 +189,26 @@ def idees_per_country(ct, year, base_dir):
ct_totals["total residential water"] = df.at["Water heating"]

assert df.index[23] == "Electricity"
ct_totals["electricity residential water"] = df[23]
ct_totals["electricity residential water"] = df.iloc[23]

ct_totals["total residential cooking"] = df["Cooking"]

assert df.index[30] == "Electricity"
ct_totals["electricity residential cooking"] = df[30]
ct_totals["electricity residential cooking"] = df.iloc[30]

df = pd.read_excel(fn_residential, "RES_summary", index_col=0)[year]

row = "Energy consumption by fuel - Eurostat structure (ktoe)"
ct_totals["total residential"] = df[row]

assert df.index[47] == "Electricity"
ct_totals["electricity residential"] = df[47]
ct_totals["electricity residential"] = df.iloc[47]

assert df.index[46] == "Derived heat"
ct_totals["derived heat residential"] = df[46]
ct_totals["derived heat residential"] = df.iloc[46]

assert df.index[50] == "Thermal uses"
ct_totals["thermal uses residential"] = df[50]
ct_totals["thermal uses residential"] = df.iloc[50]

# services

Expand All @@ -222,26 +222,26 @@ def idees_per_country(ct, year, base_dir):
ct_totals["total services water"] = df["Hot water"]

assert df.index[24] == "Electricity"
ct_totals["electricity services water"] = df[24]
ct_totals["electricity services water"] = df.iloc[24]

ct_totals["total services cooking"] = df["Catering"]

assert df.index[31] == "Electricity"
ct_totals["electricity services cooking"] = df[31]
ct_totals["electricity services cooking"] = df.iloc[31]

df = pd.read_excel(fn_tertiary, "SER_summary", index_col=0)[year]

row = "Energy consumption by fuel - Eurostat structure (ktoe)"
ct_totals["total services"] = df[row]

assert df.index[50] == "Electricity"
ct_totals["electricity services"] = df[50]
ct_totals["electricity services"] = df.iloc[50]

assert df.index[49] == "Derived heat"
ct_totals["derived heat services"] = df[49]
ct_totals["derived heat services"] = df.iloc[49]

assert df.index[53] == "Thermal uses"
ct_totals["thermal uses services"] = df[53]
ct_totals["thermal uses services"] = df.iloc[53]

# agriculture, forestry and fishing

Expand Down Expand Up @@ -282,28 +282,28 @@ def idees_per_country(ct, year, base_dir):
ct_totals["total two-wheel"] = df["Powered 2-wheelers (Gasoline)"]

assert df.index[19] == "Passenger cars"
ct_totals["total passenger cars"] = df[19]
ct_totals["total passenger cars"] = df.iloc[19]

assert df.index[30] == "Battery electric vehicles"
ct_totals["electricity passenger cars"] = df[30]
ct_totals["electricity passenger cars"] = df.iloc[30]

assert df.index[31] == "Motor coaches, buses and trolley buses"
ct_totals["total other road passenger"] = df[31]
ct_totals["total other road passenger"] = df.iloc[31]

assert df.index[39] == "Battery electric vehicles"
ct_totals["electricity other road passenger"] = df[39]
ct_totals["electricity other road passenger"] = df.iloc[39]

assert df.index[41] == "Light duty vehicles"
ct_totals["total light duty road freight"] = df[41]
ct_totals["total light duty road freight"] = df.iloc[41]

assert df.index[49] == "Battery electric vehicles"
ct_totals["electricity light duty road freight"] = df[49]
ct_totals["electricity light duty road freight"] = df.iloc[49]

row = "Heavy duty vehicles (Diesel oil incl. biofuels)"
ct_totals["total heavy duty road freight"] = df[row]

assert df.index[61] == "Passenger cars"
ct_totals["passenger car efficiency"] = df[61]
ct_totals["passenger car efficiency"] = df.iloc[61]

df = pd.read_excel(fn_transport, "TrRail_ene", index_col=0)[year]

Expand All @@ -312,39 +312,39 @@ def idees_per_country(ct, year, base_dir):
ct_totals["electricity rail"] = df["Electricity"]

assert df.index[15] == "Passenger transport"
ct_totals["total rail passenger"] = df[15]
ct_totals["total rail passenger"] = df.iloc[15]

assert df.index[16] == "Metro and tram, urban light rail"
assert df.index[19] == "Electric"
assert df.index[20] == "High speed passenger trains"
ct_totals["electricity rail passenger"] = df[[16, 19, 20]].sum()
ct_totals["electricity rail passenger"] = df.iloc[[16, 19, 20]].sum()

assert df.index[21] == "Freight transport"
ct_totals["total rail freight"] = df[21]
ct_totals["total rail freight"] = df.iloc[21]

assert df.index[23] == "Electric"
ct_totals["electricity rail freight"] = df[23]
ct_totals["electricity rail freight"] = df.iloc[23]

df = pd.read_excel(fn_transport, "TrAvia_ene", index_col=0)[year]

assert df.index[6] == "Passenger transport"
ct_totals["total aviation passenger"] = df[6]
ct_totals["total aviation passenger"] = df.iloc[6]

assert df.index[10] == "Freight transport"
ct_totals["total aviation freight"] = df[10]
ct_totals["total aviation freight"] = df.iloc[10]

assert df.index[7] == "Domestic"
ct_totals["total domestic aviation passenger"] = df[7]
ct_totals["total domestic aviation passenger"] = df.iloc[7]

assert df.index[8] == "International - Intra-EU"
assert df.index[9] == "International - Extra-EU"
ct_totals["total international aviation passenger"] = df[[8, 9]].sum()
ct_totals["total international aviation passenger"] = df.iloc[[8, 9]].sum()

assert df.index[11] == "Domestic and International - Intra-EU"
ct_totals["total domestic aviation freight"] = df[11]
ct_totals["total domestic aviation freight"] = df.iloc[11]

assert df.index[12] == "International - Extra-EU"
ct_totals["total international aviation freight"] = df[12]
ct_totals["total international aviation freight"] = df.iloc[12]

ct_totals["total domestic aviation"] = (
ct_totals["total domestic aviation freight"]
Expand All @@ -364,7 +364,7 @@ def idees_per_country(ct, year, base_dir):
df = pd.read_excel(fn_transport, "TrRoad_act", index_col=0)[year]

assert df.index[85] == "Passenger cars"
ct_totals["passenger cars"] = df[85]
ct_totals["passenger cars"] = df.iloc[85]

return pd.Series(ct_totals, name=ct)

Expand Down
2 changes: 1 addition & 1 deletion scripts/build_line_rating.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def calculate_line_rating(n, cutout):
.apply(lambda x: int(re.findall(r"(\d+)-bundle", x)[0]))
)
# Set default number of bundles per line
relevant_lines["n_bundle"].fillna(1, inplace=True)
relevant_lines["n_bundle"] = relevant_lines["n_bundle"].fillna(1)
R *= relevant_lines["n_bundle"]
R = calculate_resistance(T=353, R_ref=R)
Imax = cutout.line_rating(shapes, R, D=0.0218, Ts=353, epsilon=0.8, alpha=0.8)
Expand Down
5 changes: 2 additions & 3 deletions scripts/build_retro_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,7 @@ def calculate_heat_losses(u_values, data_tabula, l_strength, temperature_factor)
F_red_temp = map_to_lstrength(l_strength, F_red_temp)

Q_ht = (
heat_transfer_perm2.groupby(level=1, axis=1)
.sum()
heat_transfer_perm2.T.groupby(level=1).sum().T
.mul(F_red_temp.droplevel(0, axis=1))
.mul(temperature_factor.reindex(heat_transfer_perm2.index, level=0), axis=0)
)
Expand Down Expand Up @@ -878,7 +877,7 @@ def calculate_gain_utilisation_factor(heat_transfer_perm2, Q_ht, Q_gain):
Calculates gain utilisation factor nu.
"""
# time constant of the building tau [h] = c_m [Wh/(m^2K)] * 1 /(H_tr_e+H_tb*H_ve) [m^2 K /W]
tau = c_m / heat_transfer_perm2.groupby(level=1, axis=1).sum()
tau = c_m / heat_transfer_perm2.T.groupby(axis=1).sum().T
alpha = alpha_H_0 + (tau / tau_H_0)
# heat balance ratio
gamma = (1 / Q_ht).mul(Q_gain.sum(axis=1), axis=0)
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_ship_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
with zipfile.ZipFile(snakemake.input.ship_density) as zip_f:
zip_f.extract("shipdensity_global.tif")
with rioxarray.open_rasterio("shipdensity_global.tif") as ship_density:
ship_density = ship_density.drop(["band"]).sel(
ship_density = ship_density.drop_vars(["band"]).sel(
x=slice(min(xs), max(Xs)), y=slice(max(Ys), min(ys))
)
ship_density.rio.to_raster(snakemake.output[0])
Expand Down
10 changes: 5 additions & 5 deletions scripts/prepare_sector_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,7 @@ def build_heat_demand(n):
electric_nodes = n.loads.index[n.loads.carrier == "electricity"]
n.loads_t.p_set[electric_nodes] = (
n.loads_t.p_set[electric_nodes]
- electric_heat_supply.groupby(level=1, axis=1).sum()[electric_nodes]
- electric_heat_supply.T.groupby(level=1).sum().T[electric_nodes]
)

return heat_demand
Expand Down Expand Up @@ -1724,15 +1724,15 @@ def add_heat(n, costs):
if sector in name:
heat_load = (
heat_demand[[sector + " water", sector + " space"]]
.groupby(level=1, axis=1)
.sum()[nodes[name]]
.T.groupby(level=1)
.sum().T[nodes[name]]
.multiply(factor)
)

if name == "urban central":
heat_load = (
heat_demand.groupby(level=1, axis=1)
.sum()[nodes[name]]
heat_demand.T.groupby(level=1)
.sum().T[nodes[name]]
.multiply(
factor * (1 + options["district_heating"]["district_heating_loss"])
)
Expand Down

0 comments on commit 30c1a1c

Please sign in to comment.