Merge remote-tracking branch 'origin/master' into update-district-heating-cops

This commit is contained in:
AmosSchledorn 2024-08-02 17:03:51 +02:00
commit e5152897e1
7 changed files with 14 additions and 13 deletions

View File

@ -852,7 +852,7 @@ if __name__ == "__main__":
fuel_price = pd.read_csv(
snakemake.input.fuel_price, index_col=0, header=0, parse_dates=True
)
fuel_price = fuel_price.reindex(n.snapshots).fillna(method="ffill")
fuel_price = fuel_price.reindex(n.snapshots).ffill()
else:
fuel_price = None

View File

@ -890,7 +890,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.T.groupby(axis=1).sum().T
tau = c_m / heat_transfer_perm2.groupby().sum()
alpha = alpha_H_0 + (tau / tau_H_0)
# heat balance ratio
gamma = (1 / Q_ht).mul(Q_gain.sum(axis=1), axis=0)

View File

@ -58,6 +58,9 @@ def build_clustered_gas_network(df, bus_regions, length_factor=1.25):
# drop pipes within the same region
df = df.loc[df.bus1 != df.bus0]
if df.empty:
return df
# recalculate lengths as center to center * length factor
df["length"] = df.apply(
lambda p: length_factor

View File

@ -631,7 +631,7 @@ def calculate_co2_emissions(n, label, df):
weightings = n.snapshot_weightings.generators.mul(
n.investment_period_weightings["years"]
.reindex(n.snapshots)
.fillna(method="bfill")
.bfill()
.fillna(1.0),
axis=0,
)

View File

@ -70,7 +70,7 @@ if __name__ == "__main__":
optimized = optimized[["Generator", "StorageUnit"]].droplevel(0, axis=1)
optimized = optimized.rename(columns=n.buses.country, level=0)
optimized = optimized.rename(columns=carrier_groups, level=1)
optimized = optimized.groupby(axis=1, level=[0, 1]).sum()
optimized = optimized.T.groupby(level=[0, 1]).sum().T
data = pd.concat([historic, optimized], keys=["Historic", "Optimized"], axis=1)
data.columns.names = ["Kind", "Country", "Carrier"]

View File

@ -137,9 +137,7 @@ def add_emission_prices(n, emission_prices={"co2": 0.0}, exclude_co2=False):
def add_dynamic_emission_prices(n):
co2_price = pd.read_csv(snakemake.input.co2_price, index_col=0, parse_dates=True)
co2_price = co2_price[~co2_price.index.duplicated()]
co2_price = (
co2_price.reindex(n.snapshots).fillna(method="ffill").fillna(method="bfill")
)
co2_price = co2_price.reindex(n.snapshots).ffill().bfill()
emissions = (
n.generators.carrier.map(n.carriers.co2_emissions) / n.generators.efficiency

View File

@ -2748,10 +2748,11 @@ def add_industry(n, costs):
)
domestic_navigation = pop_weighted_energy_totals.loc[
nodes, "total domestic navigation"
nodes, ["total domestic navigation"]
].squeeze()
international_navigation = (
pd.read_csv(snakemake.input.shipping_demand, index_col=0).squeeze() * nyears
pd.read_csv(snakemake.input.shipping_demand, index_col=0).squeeze(axis=1)
* nyears
)
all_navigation = domestic_navigation + international_navigation
p_set = all_navigation * 1e6 / nhours
@ -3919,12 +3920,11 @@ if __name__ == "__main__":
snakemake = mock_snakemake(
"prepare_sector_network",
# configfiles="test/config.overnight.yaml",
simpl="",
opts="",
clusters="37",
ll="v1.0",
sector_opts="730H-T-H-B-I-A-dist1",
clusters="1",
ll="vopt",
sector_opts="",
planning_horizons="2050",
)