Skip to content

Commit

Permalink
Merge pull request #136 from allfed/to_pass_tests3
Browse files Browse the repository at this point in the history
To pass tests3
  • Loading branch information
morganrivers authored Apr 9, 2024
2 parents 8fdf5e5 + 78375a9 commit f2dcc88
Show file tree
Hide file tree
Showing 17 changed files with 196 additions and 546 deletions.
36 changes: 36 additions & 0 deletions docs/Figure_4/combine_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
In your command line, be sure to run the following if you update the Dot images:
dot -Tpng overview.dot -o overview.png
dot -Tpng overview_legend.dot -o overview_legend.png
Then to form the complete diagram, run the python script below:
"""

from PIL import Image

# Load the images
image1_path = "overview.png"
image2_path = "overview_legend.png"
image1 = Image.open(image1_path)
image2 = Image.open(image2_path)

# Calculate the size of the combined image
total_width = max(image1.width, image2.width)
total_height = image1.height + image2.height

# Create a new image with the appropriate size and white background
combined_image = Image.new(
"RGB", (int(total_width * 1.1), total_height - image2.height // 2), color="white"
)

# Paste the first image at the top
combined_image.paste(image1, (int(total_width * 0.1), 0))

# Paste the second image at the bottom
combined_image.paste(image2, (0, image1.height - image2.height // 2))

# Save the combined image
combined_image_path = "../overview.png"
combined_image.save(combined_image_path)
84 changes: 84 additions & 0 deletions docs/Figure_4/overview.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
digraph ModelOverview{
// Food Consumption during normal times
norm_consumption [label="Food\nConsumption", fontsize=20, style="filled",fillcolor="#55AA55"];
Waste[style="filled", fillcolor="#55AA55",fontsize=20]
Waste -> norm_consumption;
Feed[style="filled", fillcolor="#55AA55",fontsize=20]
Feed -> norm_consumption;
Biofuel[style="filled", fillcolor="#55AA55", fontsize=20]
Biofuel -> norm_consumption;

// Food Ressources during Standard Times
std_resources [label="Standard Food\nResources", style="filled",fontsize=20,fillcolor="#55AA55"];
stored_food [label="Stored\nFood",style="filled", fontsize=20,fillcolor="#55AA55"];
outdoor_crop [label="Outdoor\nCrop",style="filled",fontsize=20, fillcolor="#55AA55"];
meat [label="Meat/Dairy",style="filled", fontsize=20,fillcolor="#55AA55"];
Fish [style="filled",fontsize=20, fillcolor="#55AA55"]
stored_food -> std_resources;
outdoor_crop -> std_resources;
meat -> std_resources;
Fish -> std_resources;

// Resilient Foods
res_resources [label="Resilient Food\nResources", style="filled",fontsize=20,fillcolor="#55AA55"];
Seaweed[style="filled",fontsize=20, fillcolor="#55AA55"]
Seaweed -> res_resources;
Greenhouses[style="filled",fontsize=20, fillcolor="#55AA55"]
Greenhouses -> res_resources;
industrial_food [label="Industrial\nFood",style="filled",fontsize=20, fillcolor="#55AA55"];
industrial_food -> res_resources;

// Link foods to the model
model [label="Import\nData", fontsize=25, style="filled", fillcolor="#669999"];
norm_consumption -> model;
std_resources -> model;
res_resources -> model;

// Create base scenarios
nw [label="Nuclear\nWinter", fillcolor="#D46A6A",fontsize=20, style="filled"];
Baseline [label="Baseline", fillcolor="#D49A6A",fontsize=20, style="filled"];
model -> Baseline;
model -> nw;

// Create 150 tg scenarios
nw_trade [label="With Trade\nGlobal", fillcolor="#D46A6A", fontsize=20,style="filled"];
nw_no_trade [label="No Trade\nBy Country", fillcolor="#D46A6A",fontsize=20, style="filled"];
nw -> nw_trade;
nw -> nw_no_trade;

nw_trade_no_res_food [label="No Resilient\nFood", fontsize=20, fillcolor="#D46A6A", style="filled"];
nw_trade_res_food [label="Resilient\nFood", fontsize=20,fillcolor="#D46A6A", style="filled"];
nw_no_trade_no_res_food [label="No Resilient\nFood",fontsize=20, fillcolor="#D46A6A", style="filled"];
nw_no_trade_res_food [label="Resilient\nFood", fontsize=20, fillcolor="#D46A6A", style="filled"];
nw_trade -> nw_trade_no_res_food;
nw_trade -> nw_trade_res_food;
nw_no_trade -> nw_no_trade_no_res_food;
nw_no_trade -> nw_no_trade_res_food;


// Create baseline scenarios
Baseline_trade [label="With Trade\nGlobal", fontsize=20, fillcolor="#D49A6A", style="filled"];
Baseline_no_trade [label="No Trade\nBy Country",fontsize=20, fillcolor="#D49A6A", style="filled"];
Baseline -> Baseline_trade;
Baseline -> Baseline_no_trade;


// Link to optomization and analysis
opt [label="Optimization", style="filled", fontsize=20,fillcolor="#669999"];
Baseline_trade -> opt;
Baseline_no_trade -> opt;
nw_trade_no_res_food -> opt;
nw_trade_res_food -> opt;
nw_no_trade_no_res_food -> opt;
nw_no_trade_res_food -> opt;

// Link to analysis
analysis [label="Analysis", style="filled",fontsize=20, fillcolor="#669999"];
opt -> analysis;






}
Binary file added docs/Figure_4/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions docs/Figure_4/overview_legend.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
digraph ModelOverview {
subgraph cluster_0 {
label="Legend";
// Remove or modify these attributes to control the box appearance
// color=black; // Removed to avoid drawing the box
// penwidth=1; // Removed since we don't want an outline
style=invis; // Makes the subgraph border invisible
fontsize=20; // Increased fontsize for the legend label
fontname="Helvetica bold"; // Specify a bold font for the legend label

Baseline [label="Baseline Climate\nScenarios", fontsize=20, fillcolor="#D49A6A", style="filled"];
nw [label="Nuclear Winter\nScenarios", fontsize=20, fillcolor="#D46A6A", style="filled"];
model [label="Model", fontsize=20, style="filled", fillcolor="#669999"];
norm_consumption [label="Model\nInputs", fontsize=20, style="filled", fillcolor="#55AA55"];

// Define any edges here if necessary
}
// Define any nodes or edges outside the subgraph if you want them outside the box
}
Binary file added docs/Figure_4/overview_legend.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 docs/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 15 additions & 9 deletions plot_manuscript_figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


# COMMAND LINE INTERFACE FUNCTIONS #
RUN_FIGURE_1_WITH_BASELINE_CLIMATE = False
RUN_FIGURE_1_AND_3_WITH_BASELINE_CLIMATE = False
RUN_FIGURE_1_LEAVING_TYPICAL_BUFFERS = False
RUN_FIGURE_1_NO_STORAGE = False

Expand Down Expand Up @@ -108,8 +108,6 @@ def main(args):
RECALCULATE_PLOTS = args[0] == "rerun"
plots_to_run = args[1:] if "all" not in args[1:] else ["1", "2", "3", "s1"]
for plot_to_display in plots_to_run:
print("plot_to_display")
print(plot_to_display)
if RECALCULATE_PLOTS:
if plot_to_display == "1":
worlds, ratios = recalculate_plot_1()
Expand Down Expand Up @@ -255,7 +253,7 @@ def call_scenario_runner_and_set_options(
assert "nutrition" not in this_simulation_copy, "ERROR: nutrition overwritten"
assert "fat" not in this_simulation_copy, "ERROR: fat overwritten"
assert "protein" not in this_simulation_copy, "ERROR: protein overwritten"
if RUN_FIGURE_1_WITH_BASELINE_CLIMATE:
if RUN_FIGURE_1_AND_3_WITH_BASELINE_CLIMATE:
this_simulation_copy["crop_disruption"] = "zero"
this_simulation_copy["grasses"] = "baseline"
this_simulation_copy["fish"] = "baseline"
Expand Down Expand Up @@ -511,7 +509,7 @@ def recalculate_plot_1():
if RUN_FIGURE_1_LEAVING_TYPICAL_BUFFERS:
print("\nTypical buffers remain in place in figure 1\n")

if RUN_FIGURE_1_WITH_BASELINE_CLIMATE:
if RUN_FIGURE_1_AND_3_WITH_BASELINE_CLIMATE:
print("\nBaseline climate run for figure 1\n")

if RUN_FIGURE_1_NO_STORAGE:
Expand Down Expand Up @@ -595,10 +593,19 @@ def recalculate_plot_3():
# WORST CASE #
this_simulation = {}
this_simulation["NMONTHS"] = 120

if RUN_FIGURE_1_AND_3_WITH_BASELINE_CLIMATE:
this_simulation["crop_disruption"] = "zero"
this_simulation["grasses"] = "baseline"
this_simulation["fish"] = "baseline"
this_simulation["seasonality"] = "baseline_globally"
else:
this_simulation["crop_disruption"] = "global_nuclear_winter"
this_simulation["grasses"] = "global_nuclear_winter"
this_simulation["fish"] = "nuclear_winter"
this_simulation["seasonality"] = "nuclear_winter_globally"

this_simulation["scale"] = "global"
this_simulation["crop_disruption"] = "global_nuclear_winter"
this_simulation["grasses"] = "global_nuclear_winter"
this_simulation["fish"] = "nuclear_winter"
this_simulation["stored_food"] = "baseline"

this_simulation["nutrition"] = "catastrophe"
Expand All @@ -609,7 +616,6 @@ def recalculate_plot_3():
this_simulation["scenario"] = "no_resilient_foods"

this_simulation["end_simulation_stocks_ratio"] = "no_stored_between_years"
this_simulation["seasonality"] = "nuclear_winter_globally"

this_simulation["cull"] = "do_eat_culled"

Expand Down
84 changes: 0 additions & 84 deletions results/Figure_4/overview.dot

This file was deleted.

Binary file removed results/Figure_4/overview.dot.png
Binary file not shown.
Loading

0 comments on commit f2dcc88

Please sign in to comment.