Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Osier chapter #18

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
33dfcb7
updates thesis
samgdotson Nov 11, 2024
6406323
updates outline
samgdotson Nov 12, 2024
4823ac3
moves literature review to main section
samgdotson Nov 18, 2024
61452d9
adds literature review to main section
samgdotson Nov 18, 2024
27fa24f
converts social welfare max plot to python script
samgdotson Nov 18, 2024
b505e7e
adds plotting rule to snakefile
samgdotson Nov 18, 2024
0b33092
adds rules to make plots for methods section
samgdotson Nov 19, 2024
1b05eda
updates outline
samgdotson Nov 19, 2024
3287b76
updates outline and other sections
samgdotson Dec 14, 2024
7597db1
adds directory and section specific files for osier chapter
samgdotson Dec 14, 2024
907490e
adds scaling study
samgdotson Dec 18, 2024
df50cf3
begins section on hierarchical dispatch
samgdotson Dec 18, 2024
03fa363
first draft of dispatch model descriptions
samgdotson Dec 18, 2024
676aa55
updates bibfile and adds genetic alg section
samgdotson Dec 18, 2024
9306ecb
adds description of objectives and constraints in osier
samgdotson Dec 18, 2024
ea341fb
updates osier chapter
samgdotson Dec 25, 2024
1299969
adds mycolorpy to environment file
samgdotson Jan 15, 2025
4a11d86
Merge branch 'devel' of github.com:arfc/2025-dotson-dissertation into…
samgdotson Jan 15, 2025
9824f6c
Merge branch 'osier_chapter' of github.com:arfc/2025-dotson-dissertat…
samgdotson Jan 16, 2025
19e406c
adds mga plot to osier chapter
samgdotson Jan 20, 2025
5704f78
adds script and output plot for the mga example
samgdotson Jan 20, 2025
e9c0d5c
first draft of the osier chapter
samgdotson Jan 20, 2025
145f752
minor grammar updates to osier chapter
samgdotson Jan 21, 2025
98a3131
pep8 fixes
samgdotson Jan 21, 2025
e4cba37
removes redundant script
samgdotson Jan 21, 2025
739285b
first few corrections
samgdotson Jan 27, 2025
0a5aae1
more corrections
samgdotson Jan 29, 2025
f4f3570
finishes handling comments from @katyhuff review
samgdotson Feb 2, 2025
31141f9
updates github actions
samgdotson Feb 6, 2025
fe4215c
updates upload artifact rule
samgdotson Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Create environment with Mamba
uses: conda-incubator/setup-miniconda@v2
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:

# Upload the generated PDF as an artifact
- name: Upload PDF artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: 2025-dotson-thesis
path: docs/2025-dotson-thesis.pdf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ data/benchmark/data/*
docs/_minted-thesis
pres/_minted-arfc-pres
_minted-*
figure-log.txt
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ cd analysis
snakemake --cores=1
```

> [!NOTE]
> _Why use `snakemake` to build the dissertation when there is already a `Make` file in the `docs` directory?_
>
> Primarily because Windows _can't execute `make`_. There are additional
> advantages as well. `snakemake` is arguably easier to understand and produces
> a nice DAG model of the workflow itself.
>

# Compiling the dissertation

If you only want to reproduce the document itself without running any analysis,
Expand Down
62 changes: 57 additions & 5 deletions analysis/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ latexopt = """
"""

docs_path = "../docs/"
figure_log = "figures.log"

with open(f"{docs_path}Makefile", "r") as file:
lines = file.readlines()
Expand All @@ -18,16 +19,35 @@ output_name = lines[0].strip('\n').replace(' ', '').split('=')[-1]
rule targets:
input:
thesis = f"{docs_path}{output_name}.pdf",
dag = "dag.png"
dag = "dag.png",

rule collect_figures:
input:
social_max_plot = f"{docs_path}figures/social_max.pgf",
elasticity_plot = f"{docs_path}figures/elasticity.pgf",
example_pareto_plot = f"{docs_path}figures/truss2d_pareto.pgf",
near_optimal_plot = f"{docs_path}figures/near-optimal-pareto.pgf",
interior_points_plot = f"{docs_path}figures/nd-mga-paretofront.pgf",
pareto_3d = f"{docs_path}figures/3d-mga-paretofront.pgf",
example_mga_plot = f"{docs_path}figures/mga-fft-example.pgf",
output:
log = figure_log
shell:
"""
for file in {input}; do
echo $file >> {output.log}
done
"""

if sys.platform == 'Windows':
rule build_thesis:
input:
main_tex = f"{docs_path}{output_name}.tex"
main_tex = f"{docs_path}{output_name}.tex",
log = figure_log
output: f"{docs_path}{output_name}.pdf"
shell:
f"""
cd ../docs && \
cd {docs_path} && \
pdflatex {latexopt} {output_name}.tex && \
biber {output_name} && \
pdflatex {latexopt} {output_name}.tex && \
Expand All @@ -36,7 +56,8 @@ if sys.platform == 'Windows':
elif sys.platform in ['darwin', 'linux']:
rule build_thesis:
input:
main_tex = f"{docs_path}{output_name}.tex"
main_tex = f"{docs_path}{output_name}.tex",
log = figure_log
output: f"{docs_path}{output_name}.pdf"
shell:
f"""
Expand All @@ -48,4 +69,35 @@ rule build_dag:
output:
"dag.png"
shell:
"snakemake --dag | dot -Tpng > {output}"
"snakemake --dag | dot -Tpng > {output}"


rule plot_social_welfare_max:
input: "scripts/social_welfare_maximization.py"
output:
social_max_plot = f"{docs_path}figures/social_max.pgf",
elasticity_plot = f"{docs_path}figures/elasticity.pgf"
script: f"{input}"


rule plot_example_fronts:
input: "scripts/pareto_front.py"
output:
example_pareto_plot = f"{docs_path}figures/truss2d_pareto.pgf",
interior_points_plot = f"{docs_path}figures/nd-mga-paretofront.pgf",
near_optimal_plot = f"{docs_path}figures/near-optimal-pareto.pgf"
script: f"{input}"


rule plot_mga_example:
input: "scripts/mga_fft_example.py"
output:
example_mga_plot = f"{docs_path}figures/mga-fft-example.pgf",
script: f"{input}"


rule plot_3d_fronts:
input: "scripts/pareto_3D.py"
output:
pareto_3d = f"{docs_path}figures/3d-mga-paretofront.pgf"
script: f"{input}"
Binary file modified analysis/dag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
315 changes: 7 additions & 308 deletions analysis/methods_figures/pareto-front.ipynb

Large diffs are not rendered by default.

293 changes: 0 additions & 293 deletions analysis/methods_figures/social_welfare_maximization.ipynb

This file was deleted.

196 changes: 196 additions & 0 deletions analysis/notebooks/energy-justice.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"import matplotlib.pyplot as plt\n",
"import json\n",
"import numpy as np\n",
"import pandas as pd\n",
"import geopandas as gpd\n",
"import us\n",
"import os\n",
"from dotenv import load_dotenv\n",
"\n",
"load_dotenv(\"../../.env\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"eia_key = os.environ['EIA_API_KEY']"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Access power plant data"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"params = {\n",
" \"frequency\": \"monthly\",\n",
" \"data\": [\n",
" \"latitude\",\n",
" \"longitude\",\n",
" \"nameplate-capacity-mw\",\n",
" \"operating-year-month\"\n",
" ],\n",
" \"facets\": {\n",
" \"energy_source_code\": [\n",
" \"BIT\",\n",
" \"SUB\"\n",
" ]\n",
" },\n",
" \"start\": \"2024-09\",\n",
" \"end\": None,\n",
" \"sort\": [\n",
" {\n",
" \"column\": \"period\",\n",
" \"direction\": \"desc\"\n",
" }\n",
" ],\n",
" \"offset\": 0,\n",
" \"length\": 5000\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"BASE_URL = \"https://api.eia.gov/v2/\"\n",
"\n",
"dataset = \"electricity/operating-generator-capacity\"\n",
"route = dataset + \"/data\""
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"headers = {\n",
" \"X-Api-Key\": eia_key,\n",
" \"X-Params\": json.dumps(params),\n",
" }"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"r = requests.get(BASE_URL+route, headers=headers)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Total records: 428\n"
]
}
],
"source": [
"response = r.json()['response']\n",
"\n",
"print(f\"Total records: {response['total']}\")\n",
"\n",
"data = response['data']\n",
"\n",
"df = pd.DataFrame(data)\n",
"df.drop(columns=['stateName','sector','sectorName','entityid',\n",
" 'balancing-authority-name','statusDescription', \n",
" 'entityName','nameplate-capacity-mw-units',\n",
" 'energy_source_code','generatorid','status',\n",
" 'unit', 'period'\n",
" ],\n",
" inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"df['nameplate-capacity-mw'] = df['nameplate-capacity-mw'].astype('float')"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"df = df.pivot_table(index=['stateid','plantid','balancing_authority_code','latitude','longitude'],\n",
" columns=['technology'],\n",
" values=['nameplate-capacity-mw']).reset_index(drop=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "thesis",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.10"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading
Loading