Skip to content

Commit

Permalink
Promotion animation
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorht committed May 21, 2024
1 parent a0906a5 commit 8e9a1ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Binary file added article/figures/promotion_animation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 8 additions & 9 deletions article/notebooks/promotion_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pseudobatch import pseudobatch_transform, pseudobatch_transform_pandas
from pseudobatch.datasets._dataloaders import _prepare_simulated_dataset

FIGURES_DIR = pathlib.Path("article/figures")

def animate_line(i, line, xdata: pd.Series, ydata: pd.Series):
line.set_data(
Expand All @@ -34,8 +35,6 @@ def prepare_data():
data_path = pathlib.Path("article/data/standard_fed-batch_process.csv")
fedbatch_df = _prepare_simulated_dataset(data_path)

FIGURES_DIR = pathlib.Path("article/figures")

# pseudo batch transform
fedbatch_df["c_Biomass_pseudo"] = pseudobatch_transform(
measured_concentration=fedbatch_df["c_Biomass"].to_numpy(),
Expand Down Expand Up @@ -149,14 +148,14 @@ def animate(i, scene_splits: list[int]):
+ r"$\bf{samples}$"
+ " are drawn from\n"
+ "a "
+ r"$\bf{fedbatch \: culture}$",
+ r"$\bf{fedbatch \: culture}$?",
)
if i == scene_splits[2]:
ax.texts[-1].set_text(
"The "
+ r"$\bf{exponential \: growth \: rate}$"
+ " estimate is\n"
+ "WRONG"
+ r"$\bf{WRONG}$"
)
if i == scene_splits[3]:
ax.texts[-1].set_text(
Expand All @@ -169,11 +168,11 @@ def animate(i, scene_splits: list[int]):
# call the animator. blit=True means only re-draw the parts that have changed.
scenes = [
len(plot_data["timestamp"]),
5, # pause
len(x_pred),
50, # pause
len(x_pred),
100, # pause
len(plot_data["timestamp"]),
50, # pause
100, # pause
]
n_frames = sum(scenes)
scene_splits_list = list(np.cumsum(scenes))
Expand All @@ -192,8 +191,8 @@ def animate(i, scene_splits: list[int]):
interval=10,
)
print("Saving animation")
plt.show()
# anim.save(FIGURES_DIR / "animation.gif", fps=10)
# plt.show()
anim.save(FIGURES_DIR / "promotion_animation.gif", fps=10)


if __name__ == "__main__":
Expand Down

0 comments on commit 8e9a1ea

Please sign in to comment.