lower log level in plot_summary.py and fix warning
reduce the level of "Dropping technology energy balance smaller than {snakemake.config['plotting']['energy_threshold']/10} {units}" and "Total energy balance for {v} of {round(df.sum()[0],2)} {units}" from INFO-> DEBUG. Extra warning fix Add `plt.cla()` in the `for k, v in balances.items()` and take out fig, ax = plt.subplots(figsize=(12,8)) from that for loop to fix RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
This commit is contained in:
parent
379ed0da93
commit
f75cec93d6
@ -245,6 +245,8 @@ def plot_balances():
|
|||||||
balances = {i.replace(" ","_"): [i] for i in balances_df.index.levels[0]}
|
balances = {i.replace(" ","_"): [i] for i in balances_df.index.levels[0]}
|
||||||
balances["energy"] = [i for i in balances_df.index.levels[0] if i not in co2_carriers]
|
balances["energy"] = [i for i in balances_df.index.levels[0] if i not in co2_carriers]
|
||||||
|
|
||||||
|
fig, ax = plt.subplots(figsize=(12,8))
|
||||||
|
|
||||||
for k, v in balances.items():
|
for k, v in balances.items():
|
||||||
|
|
||||||
df = balances_df.loc[v]
|
df = balances_df.loc[v]
|
||||||
@ -265,12 +267,12 @@ def plot_balances():
|
|||||||
else:
|
else:
|
||||||
units = "TWh/a"
|
units = "TWh/a"
|
||||||
|
|
||||||
logger.info(f"Dropping technology energy balance smaller than {snakemake.config['plotting']['energy_threshold']/10} {units}")
|
logger.debug(f"Dropping technology energy balance smaller than {snakemake.config['plotting']['energy_threshold']/10} {units}")
|
||||||
logger.debug(df.loc[to_drop])
|
logger.debug(df.loc[to_drop])
|
||||||
|
|
||||||
df = df.drop(to_drop)
|
df = df.drop(to_drop)
|
||||||
|
|
||||||
logger.info(f"Total energy balance for {v} of {round(df.sum()[0],2)} {units}")
|
logger.debug(f"Total energy balance for {v} of {round(df.sum()[0],2)} {units}")
|
||||||
|
|
||||||
if df.empty:
|
if df.empty:
|
||||||
continue
|
continue
|
||||||
@ -279,8 +281,6 @@ def plot_balances():
|
|||||||
|
|
||||||
new_columns = df.columns.sort_values()
|
new_columns = df.columns.sort_values()
|
||||||
|
|
||||||
fig, ax = plt.subplots(figsize=(12,8))
|
|
||||||
|
|
||||||
df.loc[new_index,new_columns].T.plot(kind="bar",ax=ax,stacked=True,color=[snakemake.config['plotting']['tech_colors'][i] for i in new_index])
|
df.loc[new_index,new_columns].T.plot(kind="bar",ax=ax,stacked=True,color=[snakemake.config['plotting']['tech_colors'][i] for i in new_index])
|
||||||
|
|
||||||
|
|
||||||
@ -303,6 +303,8 @@ def plot_balances():
|
|||||||
|
|
||||||
fig.savefig(snakemake.output.balances[:-10] + k + ".pdf", bbox_inches='tight')
|
fig.savefig(snakemake.output.balances[:-10] + k + ".pdf", bbox_inches='tight')
|
||||||
|
|
||||||
|
plt.cla()
|
||||||
|
|
||||||
|
|
||||||
def historical_emissions(cts):
|
def historical_emissions(cts):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user