def plot_res(ext, show): end_year = '2105' data = {} for name, df in TablesRecorder.generate_dataframes('thames_output.h5'): df.columns = ['Very low', 'Low', 'Central', 'High', 'Very high'] data[name] = df fig1, ax1 = plt.subplots(figsize=(16, 5), dpi=300) data['reservoir1'].loc[:end_year, 'Central'].plot(ax=ax1) ax1.set_ylabel('Volume [$Mm^3$]') plt.tight_layout() fig2, ax2 = plt.subplots(figsize=(16, 5), dpi=300) data['demand_saving_level'].loc[:end_year, 'Central'].plot(ax=ax2) ax2.set_ylabel('Demand saving level') plt.tight_layout() fig3, ax3 = plt.subplots(figsize=(16, 5), dpi=300) data['demand_max_flow'].loc[:end_year, 'Central'].plot(ax=ax3) ax3.set_ylabel('Demand [$Mm^3/day$]') plt.tight_layout() for ax in (ax1, ax2, ax3): ax.grid(True) if ext is not None: fig1.savefig(f'Reservoir.{ext}', dpi=300) fig2.savefig(f'Demand saving level.{ext}', dpi=300) fig3.savefig(f'Demand.{ext}', dpi=300) if show: plt.show()
def figures(ext, show): for name, df in TablesRecorder.generate_dataframes('thames_output.h5'): df.columns = ['Very low', 'Low', 'Central', 'High', 'Very high'] fig, (ax1, ax2) = plt.subplots(figsize=(12, 4), ncols=2, sharey='row', gridspec_kw={'width_ratios': [3, 1]}) df['2100':'2125'].plot(ax=ax1) df.quantile(np.linspace(0, 1)).plot(ax=ax2) if name.startswith('reservoir'): ax1.set_ylabel('Volume [$Mm^3$]') else: ax1.set_ylabel('Flow [$Mm^3/day$]') for ax in (ax1, ax2): ax.set_title(name) ax.grid(True) plt.tight_layout() if ext is not None: fig.savefig(f'{name}.{ext}', dpi=300) if show: plt.show()
def plot_res(ext, show): end_year = "2105" data = {} for name, df in TablesRecorder.generate_dataframes("thames_output.h5"): df.columns = ["Very low", "Low", "Central", "High", "Very high"] data[name] = df fig1, ax1 = plt.subplots(figsize=(16, 5), dpi=300) data["reservoir1"].loc[:end_year, "Central"].plot(ax=ax1) ax1.set_ylabel("Volume [$Mm^3$]") plt.tight_layout() fig2, ax2 = plt.subplots(figsize=(16, 5), dpi=300) data["demand_saving_level"].loc[:end_year, "Central"].plot(ax=ax2) ax2.set_ylabel("Demand saving level") plt.tight_layout() fig3, ax3 = plt.subplots(figsize=(16, 5), dpi=300) data["demand_max_flow"].loc[:end_year, "Central"].plot(ax=ax3) ax3.set_ylabel("Demand [$Mm^3/day$]") plt.tight_layout() for ax in (ax1, ax2, ax3): ax.grid(True) if ext is not None: fig1.savefig(f"Reservoir.{ext}", dpi=300) fig2.savefig(f"Demand saving level.{ext}", dpi=300) fig3.savefig(f"Demand.{ext}", dpi=300) if show: plt.show()
def figures(ext, show): for name, df in TablesRecorder.generate_dataframes("thames_output.h5"): df.columns = ["Very low", "Low", "Central", "High", "Very high"] fig, (ax1, ax2) = plt.subplots( figsize=(12, 4), ncols=2, sharey="row", gridspec_kw={"width_ratios": [3, 1]} ) df["2100":"2125"].plot(ax=ax1) df.quantile(np.linspace(0, 1)).plot(ax=ax2) if name.startswith("reservoir"): ax1.set_ylabel("Volume [$Mm^3$]") else: ax1.set_ylabel("Flow [$Mm^3/day$]") for ax in (ax1, ax2): ax.set_title(name) ax.grid(True) plt.tight_layout() if ext is not None: fig.savefig(f"{name}.{ext}", dpi=300) if show: plt.show()
def plot_res2(ext, show): end_year = '2105' data = {} for name, df in TablesRecorder.generate_dataframes('thames_output.h5'): df.columns = ['Very low', 'Low', 'Central', 'High', 'Very high'] data[name] = df fig1, ax1 = plt.subplots(figsize=(16, 5), dpi=300) data['reservoir1'].loc[:end_year].plot(ax=ax1) ax1.set_ylabel('Volume [$Mm^3$]') plt.legend() plt.tight_layout() fig2, ax2 = plt.subplots(figsize=(16, 5), dpi=300) data['reservoir1'].quantile(np.linspace(0, 1)).plot(ax=ax2) ax2.set_ylabel('Volume [$Mm^3$]') ax2.set_xlabel('Quantile') plt.tight_layout() fig3, ax3 = plt.subplots(figsize=(16, 5), dpi=300) df = data['demand_saving_level'].apply(pandas.Series.value_counts) df /= df.sum(axis=0) df.plot.bar(ax=ax3) ax3.set_ylabel('Proportion of time.') ax3.set_xlabel('Demand saving level') plt.tight_layout() for ax in (ax1, ax2, ax3): ax.grid(True) if ext is not None: fig1.savefig(f'Reservoir (scenarios).{ext}', dpi=300) fig2.savefig(f'Reservoir SDC (scenarios).{ext}', dpi=300) fig3.savefig(f'Demand saving level count (scenarios).{ext}', dpi=300) if show: plt.show()
def plot_res2(ext, show): end_year = "2105" data = {} for name, df in TablesRecorder.generate_dataframes("thames_output.h5"): df.columns = ["Very low", "Low", "Central", "High", "Very high"] data[name] = df fig1, ax1 = plt.subplots(figsize=(16, 5), dpi=300) data["reservoir1"].loc[:end_year].plot(ax=ax1) ax1.set_ylabel("Volume [$Mm^3$]") plt.legend() plt.tight_layout() fig2, ax2 = plt.subplots(figsize=(16, 5), dpi=300) data["reservoir1"].quantile(np.linspace(0, 1)).plot(ax=ax2) ax2.set_ylabel("Volume [$Mm^3$]") ax2.set_xlabel("Quantile") plt.tight_layout() fig3, ax3 = plt.subplots(figsize=(16, 5), dpi=300) df = data["demand_saving_level"].apply(pandas.Series.value_counts) df /= df.sum(axis=0) df.plot.bar(ax=ax3) ax3.set_ylabel("Proportion of time.") ax3.set_xlabel("Demand saving level") plt.tight_layout() for ax in (ax1, ax2, ax3): ax.grid(True) if ext is not None: fig1.savefig(f"Reservoir (scenarios).{ext}", dpi=300) fig2.savefig(f"Reservoir SDC (scenarios).{ext}", dpi=300) fig3.savefig(f"Demand saving level count (scenarios).{ext}", dpi=300) if show: plt.show()