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)
|
.groupby(level=0)
|
||||||
.sum()
|
.sum()
|
||||||
.multiply(c.df.sign)
|
.multiply(c.df.sign)
|
||||||
.groupby(c.df.carrier, axis=1)
|
.T.groupby(c.df.carrier)
|
||||||
.sum()
|
.sum()
|
||||||
|
.T
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
c_energies = pd.DataFrame(
|
c_energies = pd.DataFrame(
|
||||||
@ -394,16 +395,9 @@ def calculate_supply_energy(n, label, supply_energy):
|
|||||||
if len(items) == 0:
|
if len(items) == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
s = (
|
s = (-1) * c.pnl["p" + end].reindex(items, axis=1).multiply(
|
||||||
(-1)
|
n.snapshot_weightings.objective, axis=0
|
||||||
* c.pnl["p" + end]
|
).groupby(level=0).sum().T.groupby(c.df.loc[items, "carrier"]).sum()
|
||||||
.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.index = s.index + end
|
s.index = s.index + end
|
||||||
s = pd.concat([s], keys=[c.list_name])
|
s = pd.concat([s], keys=[c.list_name])
|
||||||
s = pd.concat([s], keys=[i])
|
s = pd.concat([s], keys=[i])
|
||||||
@ -498,7 +492,7 @@ def calculate_weighted_prices(n, label, weighted_prices):
|
|||||||
else:
|
else:
|
||||||
suffix = " " + carrier
|
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:
|
if buses.empty:
|
||||||
continue
|
continue
|
||||||
@ -509,14 +503,14 @@ def calculate_weighted_prices(n, label, weighted_prices):
|
|||||||
else n.loads_t.p_set.reindex(buses, axis=1)
|
else n.loads_t.p_set.reindex(buses, axis=1)
|
||||||
)
|
)
|
||||||
for tech in value:
|
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:
|
if names.empty:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
load += (
|
load += n.links_t.p0[names].T.groupby(n.links.loc[names, "bus0"]).sum().T
|
||||||
n.links_t.p0[names].groupby(n.links.loc[names, "bus0"], axis=1).sum()
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add H2 Store when charging
|
# Add H2 Store when charging
|
||||||
# if carrier == "H2":
|
# if carrier == "H2":
|
||||||
@ -557,9 +551,9 @@ def calculate_market_values(n, label, market_values):
|
|||||||
|
|
||||||
dispatch = (
|
dispatch = (
|
||||||
n.generators_t.p[gens]
|
n.generators_t.p[gens]
|
||||||
.groupby(n.generators.loc[gens, "bus"], axis=1)
|
.T.groupby(n.generators.loc[gens, "bus"])
|
||||||
.sum()
|
.sum()
|
||||||
.reindex(columns=buses, fill_value=0.0)
|
.T.reindex(columns=buses, fill_value=0.0)
|
||||||
)
|
)
|
||||||
|
|
||||||
revenue = dispatch * n.buses_t.marginal_price[buses]
|
revenue = dispatch * n.buses_t.marginal_price[buses]
|
||||||
@ -583,9 +577,9 @@ def calculate_market_values(n, label, market_values):
|
|||||||
|
|
||||||
dispatch = (
|
dispatch = (
|
||||||
n.links_t["p" + i][links]
|
n.links_t["p" + i][links]
|
||||||
.groupby(n.links.loc[links, "bus" + i], axis=1)
|
.T.groupby(n.links.loc[links, "bus" + i])
|
||||||
.sum()
|
.sum()
|
||||||
.reindex(columns=buses, fill_value=0.0)
|
.T.reindex(columns=buses, fill_value=0.0)
|
||||||
)
|
)
|
||||||
|
|
||||||
revenue = dispatch * n.buses_t.marginal_price[buses]
|
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 = n.generators_t.p[gens.index].mul(em_pu)
|
||||||
|
|
||||||
emitted_grouped = (
|
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))
|
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()
|
end = time_weighting.cumsum()
|
||||||
start = time_weighting.cumsum().shift().fillna(0)
|
start = time_weighting.cumsum().shift().fillna(0)
|
||||||
return pd.concat([start, end], axis=1).apply(
|
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,
|
axis=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -188,7 +190,7 @@ def concat_networks(years):
|
|||||||
pnl = getattr(n, component.list_name + "_t")
|
pnl = getattr(n, component.list_name + "_t")
|
||||||
for k in iterkeys(component.pnl):
|
for k in iterkeys(component.pnl):
|
||||||
pnl_year = component.pnl[k].copy().reindex(snapshots, level=1)
|
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
|
continue
|
||||||
if component.name == "Load":
|
if component.name == "Load":
|
||||||
static_load = network.loads.loc[network.loads.p_set != 0]
|
static_load = network.loads.loc[network.loads.p_set != 0]
|
||||||
|
Loading…
Reference in New Issue
Block a user