Skip to content

Commit

Permalink
Rewrite prior_biome_before_desertification
Browse files Browse the repository at this point in the history
Delete most of the function.
  • Loading branch information
iamgiddyaboutgit committed Dec 12, 2023
1 parent 65f8695 commit e65826e
Showing 1 changed file with 14 additions and 34 deletions.
48 changes: 14 additions & 34 deletions src/sim_world_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,43 +104,23 @@ def stoch_pro_lin(

return s

def prior_biome_before_desertification(current_biome, prob_not_desert, rng:np.random.Generator):
def prior_biome_before_desertification(rng:np.random.Generator):
"""Returns the prior biome.
Args:
current_biome: str.
prob_not_desert: float. This is a number between
0 and 1 indicating the probability that the current
desert biome used to be another biome at the start
of the simulation.
Returns:
str. Indicates what the biome was historically.
"""
# If it's not desert now, then we do not
# worry about it being something else historically.
if current_biome != "Deserts & Xeric Shrublands":
past_biome = current_biome
else:
# We have a desert that could have been
# something else.
r = rng.random()
if r <= prob_not_desert:
# It wasn't desert
other_biome_choices = [
"Tropical & Subtropical Grasslands, Savannas & Shrublands",
"Flooded Grasslands & Savannas",
"Temperate Grasslands, Savannas & Shrublands",
"Temperate Conifer Forests",
"Montane Grasslands & Shrublands",
"Temperate Broadleaf & Mixed Forests"
]
past_biome = rng.choice(
a=other_biome_choices,
size=1
)
else:
# It has always been desert
past_biome = current_biome

other_biome_choices = [
"Tropical & Subtropical Grasslands, Savannas & Shrublands",
"Flooded Grasslands & Savannas",
"Temperate Grasslands, Savannas & Shrublands",
"Temperate Conifer Forests",
"Montane Grasslands & Shrublands",
"Temperate Broadleaf & Mixed Forests"
]
past_biome = rng.choice(
a=other_biome_choices,
size=1
)[0]

return past_biome

0 comments on commit e65826e

Please sign in to comment.