Skip to content

Commit

Permalink
Generalise to plots with multiple techs
Browse files Browse the repository at this point in the history
  • Loading branch information
mal84emma committed Jan 25, 2025
1 parent d912ac0 commit 0d0aae4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
48 changes: 32 additions & 16 deletions analysis/plot_scenario_operation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -45,28 +45,38 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"expt_id = 1\n",
"expt_id = 'two_techs'\n",
"techs = ['CAES','Li-ion']"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"techs_str = '-'.join(techs)\n",
"settings, base_params = get_experiment_config(expt_id)\n",
"available_technologies = list(settings['probability_settings']['storage'].keys())"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"design_fpath = os.path.join(*settings['results_dir'],'prior','CAES_design.yaml')\n",
"design_fpath = os.path.join(*settings['results_dir'],'prior',f'{techs_str}_design.yaml')\n",
"scenario_fpaths = [os.path.join(*settings['scenarios_dir'],'thetas','scenario_0.yaml')]"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -104,7 +114,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -146,7 +156,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -157,7 +167,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -204,7 +214,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -214,7 +224,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -233,9 +243,11 @@
"\n",
"fig = add_profile(fig, scenario.load[:solved_model.T]/1e3, name='Plant',\n",
" legendgroup='load', legendgrouptitle_text='Load',\n",
" visible='legendonly',\n",
" line=dict(color='black', width=2.5, dash='dash'), zorder=10)\n",
"fig = add_profile(fig, solved_model.grid_energies[m].solution.values/1e3, name='Grid',\n",
" legendgroup='load',\n",
" visible='legendonly',\n",
" line=dict(color='black', width=2.5), zorder=10)\n",
"\n",
"wind = solved_model.scenarios[m].norm_wind_gen*solved_model.model.variables.wind_capacity.solution.values\n",
Expand All @@ -245,6 +257,7 @@
"solar = solved_model.scenarios[m].norm_solar_gen*solved_model.model.variables.solar_capacity.solution.values\n",
"fig = add_profile(fig, solar/1e3, name=f'Solar',\n",
" legendgroup='generation',\n",
" visible='legendonly',\n",
" line=dict(color='#fac205', width=2.5), zorder=5)\n",
"curtailment = getattr(solved_model.model.variables,f'generation_curtailment_s{m}').solution.values\n",
"fig = add_profile(fig, curtailment/1e3, name='Curtailment',\n",
Expand All @@ -256,11 +269,12 @@
" SOC = getattr(solved_model.model.variables,f'SOC_{tech}_s{m}').solution\n",
" fig = add_profile(fig, SOC/1e6, name=tech, yaxis=f'y2',\n",
" legendgroup='soc', legendgrouptitle_text='Storage SOC',\n",
" visible='legendonly',\n",
" #visible='legendonly',\n",
" line=dict(color=colors[available_technologies.index(tech)], width=3), zorder=8)\n",
"\n",
"fig = add_profile(fig, solved_model.scenarios[m].elec_prices, name='Electricity price', yaxis='y3',\n",
" legendgroup='other', legendgrouptitle_text='Other', visible='legendonly',\n",
" legendgroup='other', legendgrouptitle_text='Other',\n",
" #visible='legendonly',\n",
" line=dict(color='#ff028d', width=2.5), zorder=12)\n",
"fig = add_profile(fig, solved_model.get_flared_energy()[f's{m}']['total_energy_dump']/1e3, name='Flared energy', yaxis='y',\n",
" legendgroup='other', visible='legendonly',\n",
Expand All @@ -269,7 +283,9 @@
"fig.update_layout(legend=dict(groupclick=\"toggleitem\"))\n",
"fig.update_layout(hovermode=\"x\")\n",
"\n",
"fig.write_html(f'temp_plot.html')\n",
"fig['layout']['xaxis'].update(range=['2000-05-26','2000-06-09'])\n",
"fig.write_html(os.path.join('plots',f'{techs_str}_operation_plot.html'))\n",
"fig.write_image(os.path.join('plots',f'{techs_str}_operation_plot.pdf'), width=1800, height=600)\n",
"fig.show()"
]
},
Expand Down Expand Up @@ -325,7 +341,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.19"
"version": "3.9.18"
}
},
"nbformat": 4,
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
gurobipy==12.0.0
highspy==1.7.2
ipykernel==6.29.5
kaleido==0.2.1
matplotlib==3.7.5
multiprocess==0.70.16
nbformat==5.10.4
Expand Down

0 comments on commit 0d0aae4

Please sign in to comment.