Skip to content

Commit

Permalink
Merge pull request #54 from florianjehn/main
Browse files Browse the repository at this point in the history
clean up for publication
  • Loading branch information
florianjehn authored Jan 27, 2023
2 parents 1626de3 + 52ece97 commit 13b6995
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,4 @@ data/gridded_data_global/47tg/nw_PO4_120_months_47tg.pkl
data/gridded_data_global/47tg/nw_SALT_120_months_47tg.pkl
data/gridded_data_global/47tg/nw_TEMP_120_months_47tg.pkl
data/geospatial_information/grid/harbor_50km_coast_2.5km_buffer.gpkg
*.zip
10 changes: 5 additions & 5 deletions docs/sources/modules/src/plotting/plotter_grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


### cluster_spatial
[source](https://github.com/allfed/Seaweed-Growth-Model/blob/master/src/plotting/plotter_grid.py/#L22)
[source](https://github.com/allfed/Seaweed-Growth-Model/blob/master/src/plotting/plotter_grid.py/#L23)
```python
.cluster_spatial(
growth_df, global_or_US, scenario
Expand All @@ -26,7 +26,7 @@ None, but saves the plot


### growth_rate_spatial_by_year
[source](https://github.com/allfed/Seaweed-Growth-Model/blob/master/src/plotting/plotter_grid.py/#L73)
[source](https://github.com/allfed/Seaweed-Growth-Model/blob/master/src/plotting/plotter_grid.py/#L74)
```python
.growth_rate_spatial_by_year(
growth_df, global_or_US, scenario, optimal_growth_rate
Expand All @@ -50,7 +50,7 @@ None, but saves the plot


### cluster_timeseries_all_parameters_q_lines
[source](https://github.com/allfed/Seaweed-Growth-Model/blob/master/src/plotting/plotter_grid.py/#L140)
[source](https://github.com/allfed/Seaweed-Growth-Model/blob/master/src/plotting/plotter_grid.py/#L141)
```python
.cluster_timeseries_all_parameters_q_lines(
parameters, global_or_US, scenario, areas
Expand All @@ -73,7 +73,7 @@ None, but saves the plot


### compare_nw_scenarios
[source](https://github.com/allfed/Seaweed-Growth-Model/blob/master/src/plotting/plotter_grid.py/#L278)
[source](https://github.com/allfed/Seaweed-Growth-Model/blob/master/src/plotting/plotter_grid.py/#L279)
```python
.compare_nw_scenarios(
areas, optimal_growth_rate
Expand All @@ -97,7 +97,7 @@ None


### compare_nutrient_subfactors
[source](https://github.com/allfed/Seaweed-Growth-Model/blob/master/src/plotting/plotter_grid.py/#L385)
[source](https://github.com/allfed/Seaweed-Growth-Model/blob/master/src/plotting/plotter_grid.py/#L400)
```python
.compare_nutrient_subfactors(
nitrate, ammonium, phosphate, scenario, areas
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ channels:
dependencies:
- python=3.10
- pandas=1.4.3
- setuptools=61.2.0
- setuptools=65.5.1
- pytest=7.1.2
- numpy=1.23.1
- matplotlib=3.5.1
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pandas==1.4.3
setuptools==61.2.0
setuptools==65.5.1
pytest==7.1.2
numpy==1.23.1
matplotlib==3.5.1
Expand Down
Binary file modified results/grid/150tg/cluster_spatial_US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified results/grid/150tg/cluster_timeseries_all_param_q_lines_US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified results/grid/150tg/comparing_nutrient_subfactors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified results/grid/150tg/growth_rate_spatial_year_1_US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified results/grid/150tg/growth_rate_spatial_year_2_US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified results/grid/150tg/growth_rate_spatial_year_3_US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified results/grid/5tg/cluster_timeseries_all_param_q_lines_global.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified results/grid/comparing_nw_scenarios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 25 additions & 10 deletions src/plotting/plotter_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import numpy as np
import pandas as pd
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.lines import Line2D

from src.processing import read_files as rf
from src.utilities import prepare_geometry, weighted_quantile
Expand Down Expand Up @@ -157,7 +158,7 @@ def cluster_timeseries_all_parameters_q_lines(
"nutrient_factor": "Nutrient Factor",
"illumination_factor": "Illumination Factor",
"temp_factor": "Temperature Factor",
"seaweed_growth_rate": "Seaweed Growth Rate",
"seaweed_growth_rate": "Total Growth Factor",
}
clusters = 4 if global_or_US == "US" else 3
fig, axes = plt.subplots(
Expand Down Expand Up @@ -286,15 +287,14 @@ def compare_nw_scenarios(areas, optimal_growth_rate):
"""
print("Starting the NW comparison plots")
# A dictionary of seven colors, starting with #3A913F for the scenarios
# All following colors are 12% lighter than the previous one
colors = {
"150 Tg": "#3A913F",
"47 Tg": "#3F9C4A",
"37 Tg": "#45A755",
"27 Tg": "#4BB260",
"16 Tg": "#50BD6B",
"5 Tg": "#56C877",
"Control": "#5BD282",
"47 Tg": "#5DAF5D",
"37 Tg": "#7FC17F",
"27 Tg": "#A1DCA1",
"16 Tg": "#C3F5C3",
"5 Tg": "#E6FFE6",
"Control": "#95c091",
}
# have a list that is used to save the scenario results
median_weighted_list = []
Expand Down Expand Up @@ -366,15 +366,30 @@ def compare_nw_scenarios(areas, optimal_growth_rate):
# Add one to the years, so that the first year is 1
all_medians.index = all_medians.index + 1
# plot them all in the same subplot as bar plots
ax = all_medians.plot.bar(color=colors, edgecolor="black", linewidth=0.1)
ax = all_medians.plot.bar(color=colors, edgecolor="black", linewidth=0.1, legend=False)
# Create a custom legend for the plot with 7 columns
custom_lines = [
Line2D([0], [0], color=colors["150 Tg"], lw=4),
Line2D([0], [0], color=colors["47 Tg"], lw=4),
Line2D([0], [0], color=colors["37 Tg"], lw=4),
Line2D([0], [0], color=colors["27 Tg"], lw=4),
Line2D([0], [0], color=colors["16 Tg"], lw=4),
Line2D([0], [0], color=colors["5 Tg"], lw=4),
Line2D([0], [0], color=colors["Control"], lw=4),
]
ax.legend(
custom_lines,
["150 Tg", "47 Tg", "37 Tg", "27 Tg", "16 Tg", "5 Tg", "Control"],
ncol=7,
fontsize=8,
)
# Make it nicer
ax.set_xlabel("Year after Nuclear War")
ax.set_ylabel("Median Daily Growth Rate [%]")
# Rotate the xtick labels so they are parallel to the x axis
plt.xticks(rotation=0)
# Remove the x grid
ax.xaxis.grid(False)
plt.legend()
plt.savefig(
"results" + os.sep + "grid" + os.sep + "comparing_nw_scenarios.png",
dpi=350,
Expand Down

0 comments on commit 13b6995

Please sign in to comment.