Merge branch 'master' of github.com:PyPSA/pypsa-eur
This commit is contained in:
commit
560e2854b7
@ -246,8 +246,9 @@ def calculate_energy(n, label, energy):
|
||||
.groupby(level=0)
|
||||
.sum()
|
||||
.multiply(c.df.sign)
|
||||
.groupby(c.df.carrier, axis=1)
|
||||
.T.groupby(c.df.carrier)
|
||||
.sum()
|
||||
.T
|
||||
)
|
||||
else:
|
||||
c_energies = pd.DataFrame(
|
||||
@ -394,16 +395,9 @@ def calculate_supply_energy(n, label, supply_energy):
|
||||
if len(items) == 0:
|
||||
continue
|
||||
|
||||
s = (
|
||||
(-1)
|
||||
* c.pnl["p" + end]
|
||||
.reindex(items, axis=1)
|
||||
.multiply(n.snapshot_weightings.objective, axis=0)
|
||||
.groupby(level=0)
|
||||
.sum()
|
||||
.groupby(c.df.loc[items, "carrier"], axis=1)
|
||||
.sum()
|
||||
).T
|
||||
s = (-1) * c.pnl["p" + end].reindex(items, axis=1).multiply(
|
||||
n.snapshot_weightings.objective, axis=0
|
||||
).groupby(level=0).sum().T.groupby(c.df.loc[items, "carrier"]).sum()
|
||||
s.index = s.index + end
|
||||
s = pd.concat([s], keys=[c.list_name])
|
||||
s = pd.concat([s], keys=[i])
|
||||
@ -498,7 +492,7 @@ def calculate_weighted_prices(n, label, weighted_prices):
|
||||
else:
|
||||
suffix = " " + carrier
|
||||
|
||||
buses = n.buses.index[n.buses.index.str[2:] == suffix]
|
||||
buses = n.buses.index[n.buses.index.str[5:] == suffix]
|
||||
|
||||
if buses.empty:
|
||||
continue
|
||||
@ -509,14 +503,14 @@ def calculate_weighted_prices(n, label, weighted_prices):
|
||||
else n.loads_t.p_set.reindex(buses, axis=1)
|
||||
)
|
||||
for tech in value:
|
||||
names = n.links.index[n.links.index.to_series().str[-len(tech) :] == tech]
|
||||
names = n.links.index[
|
||||
n.links.index.to_series().str[-len(tech) - 5 : -5] == tech
|
||||
]
|
||||
|
||||
if names.empty:
|
||||
continue
|
||||
|
||||
load += (
|
||||
n.links_t.p0[names].groupby(n.links.loc[names, "bus0"], axis=1).sum()
|
||||
)
|
||||
load += n.links_t.p0[names].T.groupby(n.links.loc[names, "bus0"]).sum().T
|
||||
|
||||
# Add H2 Store when charging
|
||||
# if carrier == "H2":
|
||||
@ -557,9 +551,9 @@ def calculate_market_values(n, label, market_values):
|
||||
|
||||
dispatch = (
|
||||
n.generators_t.p[gens]
|
||||
.groupby(n.generators.loc[gens, "bus"], axis=1)
|
||||
.T.groupby(n.generators.loc[gens, "bus"])
|
||||
.sum()
|
||||
.reindex(columns=buses, fill_value=0.0)
|
||||
.T.reindex(columns=buses, fill_value=0.0)
|
||||
)
|
||||
|
||||
revenue = dispatch * n.buses_t.marginal_price[buses]
|
||||
@ -583,9 +577,9 @@ def calculate_market_values(n, label, market_values):
|
||||
|
||||
dispatch = (
|
||||
n.links_t["p" + i][links]
|
||||
.groupby(n.links.loc[links, "bus" + i], axis=1)
|
||||
.T.groupby(n.links.loc[links, "bus" + i])
|
||||
.sum()
|
||||
.reindex(columns=buses, fill_value=0.0)
|
||||
.T.reindex(columns=buses, fill_value=0.0)
|
||||
)
|
||||
|
||||
revenue = dispatch * n.buses_t.marginal_price[buses]
|
||||
@ -652,7 +646,7 @@ def calculate_co2_emissions(n, label, df):
|
||||
emitted = n.generators_t.p[gens.index].mul(em_pu)
|
||||
|
||||
emitted_grouped = (
|
||||
emitted.groupby(level=0).sum().groupby(n.generators.carrier, axis=1).sum().T
|
||||
emitted.groupby(level=0).sum().T.groupby(n.generators.carrier).sum()
|
||||
)
|
||||
|
||||
df = df.reindex(emitted_grouped.index.union(df.index))
|
||||
|
@ -56,7 +56,9 @@ def get_investment_weighting(time_weighting, r=0.01):
|
||||
end = time_weighting.cumsum()
|
||||
start = time_weighting.cumsum().shift().fillna(0)
|
||||
return pd.concat([start, end], axis=1).apply(
|
||||
lambda x: sum(get_social_discount(t, r) for t in range(int(x[0]), int(x[1]))),
|
||||
lambda x: sum(
|
||||
get_social_discount(t, r) for t in range(int(x.iloc[0]), int(x.iloc[1]))
|
||||
),
|
||||
axis=1,
|
||||
)
|
||||
|
||||
@ -188,7 +190,7 @@ def concat_networks(years):
|
||||
pnl = getattr(n, component.list_name + "_t")
|
||||
for k in iterkeys(component.pnl):
|
||||
pnl_year = component.pnl[k].copy().reindex(snapshots, level=1)
|
||||
if pnl_year.empty and ~(component.name == "Load" and k == "p_set"):
|
||||
if pnl_year.empty and (not (component.name == "Load" and k == "p_set")):
|
||||
continue
|
||||
if component.name == "Load":
|
||||
static_load = network.loads.loc[network.loads.p_set != 0]
|
||||
|
Loading…
Reference in New Issue
Block a user