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

[pre-commit.ci] pre-commit autoupdate #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -11,19 +11,19 @@ repos:
args: ["--autofix", "--indent=2", "--no-sort-keys"]

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.8.0
hooks:
- id: black
args: ["--line-length", "100"]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.260"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.5"
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
rev: 1.8.7
hooks:
- id: nbqa-ruff
args: ["--fix"]
Expand All @@ -35,7 +35,7 @@ repos:
args: ["--py37-plus"]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
rev: v4.0.0-alpha.8
hooks:
- id: prettier
language_version: system
Expand All @@ -51,7 +51,7 @@ repos:
)$"

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
rev: v4.0.0-alpha.8
hooks:
- id: prettier
name: prettier-markdown
Expand Down
7 changes: 4 additions & 3 deletions notebooks/Figure-1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import os\n",
"\n",
"import fsspec\n",
"import json\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
"import matplotlib.pyplot as plt\n",
"import numpy as np"
]
},
{
Expand Down
9 changes: 5 additions & 4 deletions notebooks/Figure-3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import os\n",
"\n",
"import fsspec\n",
"import json\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import statsmodels.formula.api as smf\n",
"import matplotlib.pyplot as plt"
"import pandas as pd\n",
"import statsmodels.formula.api as smf"
]
},
{
Expand Down
34 changes: 24 additions & 10 deletions notebooks/Figure-5.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import os\n",
"\n",
"import fsspec\n",
"import json\n",
"import pandas as pd\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from matplotlib import ticker"
]
},
Expand Down Expand Up @@ -93,9 +94,15 @@
" np.percentile(data[key][\"delta_arbocs\"], 75) / get(key)[\"arbocs\"][\"issuance\"]\n",
" for key in data.keys()\n",
"]\n",
"df[\"absolute_low\"] = [np.percentile(data[key][\"delta_arbocs\"], 5) for key in data.keys()]\n",
"df[\"absolute_med\"] = [np.percentile(data[key][\"delta_arbocs\"], 50) for key in data.keys()]\n",
"df[\"absolute_high\"] = [np.percentile(data[key][\"delta_arbocs\"], 95) for key in data.keys()]\n",
"df[\"absolute_low\"] = [\n",
" np.percentile(data[key][\"delta_arbocs\"], 5) for key in data.keys()\n",
"]\n",
"df[\"absolute_med\"] = [\n",
" np.percentile(data[key][\"delta_arbocs\"], 50) for key in data.keys()\n",
"]\n",
"df[\"absolute_high\"] = [\n",
" np.percentile(data[key][\"delta_arbocs\"], 95) for key in data.keys()\n",
"]\n",
"df[\"project_size\"] = [get(key)[\"arbocs\"][\"issuance\"] for key in data.keys()]\n",
"df[\"cp_slag\"] = [get(key)[\"carbon\"][\"common_practice\"][\"value\"] for key in data.keys()]\n",
"df[\"alternate_slag\"] = [np.percentile(data[key][\"alt_slag\"], 50) for key in data.keys()]\n",
Expand All @@ -117,8 +124,10 @@
"metadata": {},
"outputs": [],
"source": [
"def format_si(num, precision=0, suffixes=[\"\", \"K\", \"M\", \"G\", \"T\", \"P\"], show_suffix=False):\n",
" m = sum([abs(num / 1000.0 ** x) >= 1 for x in range(1, len(suffixes))])\n",
"def format_si(\n",
" num, precision=0, suffixes=[\"\", \"K\", \"M\", \"G\", \"T\", \"P\"], show_suffix=False\n",
"):\n",
" m = sum([abs(num / 1000.0**x) >= 1 for x in range(1, len(suffixes))])\n",
" if show_suffix:\n",
" return f\"{num/1000.0**m:.{precision}f}{suffixes[m]}\"\n",
" else:\n",
Expand Down Expand Up @@ -154,7 +163,10 @@
" total.append(np.nansum([data[key][\"delta_arbocs\"][i] for key in data.keys()]))\n",
" total_arbocs = np.percentile(total, [5, 50, 95])\n",
" total_percentage = np.percentile(total, [5, 50, 95]) / np.sum(\n",
" [[x for x in db if x[\"id\"] == key][0][\"arbocs\"][\"issuance\"] for key in data.keys()]\n",
" [\n",
" [x for x in db if x[\"id\"] == key][0][\"arbocs\"][\"issuance\"]\n",
" for key in data.keys()\n",
" ]\n",
" )"
]
},
Expand Down Expand Up @@ -284,7 +296,9 @@
"axs[1].vlines(df[\"id\"], -1, 1.5, color=(0.95, 0.95, 0.95), linewidth=1)\n",
"axs[1].hlines([0], [0], [len(df) - 1], color=(0.75, 0.75, 0.75), linewidth=2)\n",
"axs[1].plot(df[\"id\"], df[\"percent_med\"], \".\", color=\"#7EB36A\", markersize=12)\n",
"axs[1].vlines(df[\"id\"], df[\"percent_low\"], df[\"percent_high\"], color=\"black\", linewidth=1.25)\n",
"axs[1].vlines(\n",
" df[\"id\"], df[\"percent_low\"], df[\"percent_high\"], color=\"black\", linewidth=1.25\n",
")\n",
"axs[1].set_xticks([])\n",
"axs[1].set_ylim([-1.1, 1.1])\n",
"axs[1].set_ylabel(\"Crediting error (%)\")\n",
Expand Down
38 changes: 26 additions & 12 deletions notebooks/Figure-6.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import os\n",
"\n",
"import fsspec\n",
"import json\n",
"import geopandas\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
Expand All @@ -26,7 +27,6 @@
"from mpl_toolkits.axes_grid1.inset_locator import inset_axes\n",
"from shapely.geometry import Point\n",
"\n",
"\n",
"crs = \"+proj=aea +lat_0=23 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs=True\""
]
},
Expand Down Expand Up @@ -100,7 +100,9 @@
"outputs": [],
"source": [
"proj_centroids = {\n",
" project[\"opr_id\"]: Point(project[\"shape_centroid\"][0][0], project[\"shape_centroid\"][0][1])\n",
" project[\"opr_id\"]: Point(\n",
" project[\"shape_centroid\"][0][0], project[\"shape_centroid\"][0][1]\n",
" )\n",
" for project in db\n",
" if (79 in project[\"supersection_ids\"])\n",
" and (\n",
Expand All @@ -119,7 +121,9 @@
"outputs": [],
"source": [
"proj_points = geopandas.GeoDataFrame(\n",
" data=list(proj_centroids.keys()), geometry=list(proj_centroids.values()), crs=\"epsg:4326\"\n",
" data=list(proj_centroids.keys()),\n",
" geometry=list(proj_centroids.values()),\n",
" crs=\"epsg:4326\",\n",
")"
]
},
Expand Down Expand Up @@ -214,9 +218,9 @@
"metadata": {},
"outputs": [],
"source": [
"vmin, vmax = arbitrage_df.mean_local_slag.quantile(0.025), arbitrage_df.mean_local_slag.quantile(\n",
" 0.975\n",
")\n",
"vmin, vmax = arbitrage_df.mean_local_slag.quantile(\n",
" 0.025\n",
"), arbitrage_df.mean_local_slag.quantile(0.975)\n",
"\n",
"norm = mpl.colors.Normalize(vmin, vmax)"
]
Expand Down Expand Up @@ -276,9 +280,13 @@
"outputs": [],
"source": [
"supersection_sections = (\n",
" ecomap_sections.loc[ecomap_sections[\"MAP_UNIT_S\"].isin(ecosections)].to_crs(crs).copy()\n",
" ecomap_sections.loc[ecomap_sections[\"MAP_UNIT_S\"].isin(ecosections)]\n",
" .to_crs(crs)\n",
" .copy()\n",
")\n",
"supersection_sections[\"slag\"] = supersection_sections[\"MAP_UNIT_S\"].map(\n",
" slag_per_section\n",
")\n",
"supersection_sections[\"slag\"] = supersection_sections[\"MAP_UNIT_S\"].map(slag_per_section)\n",
"supersection_outline = supersection_sections.dissolve(\"PROJECT\")"
]
},
Expand Down Expand Up @@ -327,10 +335,14 @@
" vmax=55,\n",
" legend_kwds={\"label\": \"\", \"orientation\": \"vertical\"},\n",
")\n",
"cax.set_ylabel(\"$\\Delta$ Carbon\\n(tCO2e / acre)\", loc=\"center\", labelpad=-75, fontsize=12)\n",
"cax.set_ylabel(\n",
" \"$\\\\Delta$ Carbon\\n(tCO2e / acre)\", loc=\"center\", labelpad=-75, fontsize=12\n",
")\n",
"cax.yaxis.set_ticks_position(\"none\")\n",
"\n",
"proj_points.to_crs(crs).plot(ax=ax[0], marker=\"^\", color=\"k\", markersize=100, edgecolor=None)\n",
"proj_points.to_crs(crs).plot(\n",
" ax=ax[0], marker=\"^\", color=\"k\", markersize=100, edgecolor=None\n",
")\n",
"supersection_outline.plot(ax=ax[0], edgecolor=\"k\", lw=0.2, color=\"None\")\n",
"\n",
"supersection_sections.plot(\n",
Expand All @@ -342,7 +354,9 @@
" vmin=-55,\n",
" vmax=55,\n",
")\n",
"proj_points.to_crs(crs).plot(ax=ax[1], marker=\"^\", color=\"k\", markersize=100, edgecolor=None)\n",
"proj_points.to_crs(crs).plot(\n",
" ax=ax[1], marker=\"^\", color=\"k\", markersize=100, edgecolor=None\n",
")\n",
"\n",
"\n",
"xys = {\"M261D\": (0.7, 0.25), \"M261A\": (0.15, 0.8), \"M261B\": (0.4, 0.15)}\n",
Expand Down
Loading
Loading