cosima-recipes
cosima-recipes copied to clipboard
Tutorial: Making animations
Write a tutorial on how to make simple animations with the cookbook. Examples could be to show the seasonal cycle of Antarctic sea ice, or a transect that is dragged through a static, or moving, ocean...
this notebook might be a good starting point?
This notebook https://github.com/COSIMA/ACCESS-OM2-1-025-010deg-report/blob/master/figures/vorticity/vorticity.ipynb shows how this movie was done https://youtu.be/jo-xWkU0w6s
FYI this is how I made gifs @AndyHoggANU
import imageio
from pathlib import Path
image_path = Path('.')
images = list(image_path.glob('*.png'))
image_list = []
for file_name in images:
image_list.append(imageio.imread(file_name))
This finds all the images in the folder of the notebook, ordered by date made.
images
Lists the pictures, usually I check that the last few ones are the pictures I want to use if they've just been computed and saved using plt.savefig
imageio.mimwrite('drygalskideeper_T-S_monthly_volume.gif', image_list[-12:], fps=0.7)
Makes the gif using the most recent 12 images (e.g. monthly pictures for one year)
@AndyHoggANU, this is where your code
import numpy as np
from celluloid import Camera
import matplotlib.pyplot as plt
import xarray as xr
import cmocean as cm
from IPython.display import HTML
data = xr.open_dataset('ocean-2d-sfc_hflux_coupler-1-daily-mean-ym_1962_01.nc')
fig = plt.figure(figsize=(12,6.5))
camera = Camera(fig)
for i in range(90):
array = data.sfc_hflux_coupler.isel(time=i).sel(yt_ocean=slice(-50,-25)).sel(xt_ocean=slice(10,75))
array.plot(vmin=-300,vmax=300,add_colorbar=False,cmap=cm.cm.curl,)
camera.snap()
animation=camera.animate()
HTML(animation.to_html5_video()) # shows in notebook
animation.save('out.mp4') # saves file
could come very handy.
https://xmovie.readthedocs.io/en/latest/
Relevant from our recent discussion @Hangyum. Let's make a new example for Hackathon # 4?
Yes sure. As it is my first time to do a pull request in COSIMA_recipes, is there any tutorial that tells me how to do this?
Relevant from our recent discussion @Hangyum. Let's make a new example for Hackathon #4?
I see where the confusion stemmed.... @adele-morrison wrote ... for Hackathon #4
meaning the 4th Hackathon that we'll be having in July. But in Github when you write a hash (#
) and next to it a number, Github creates a link to the issue or PR of the repository with that number! @Hangyum clicked on that and asked their question...
Hi all, I've created an animation script. It saves individual daily snapshots of sea surface velocity as .png files and then combines these frames into a .mp4 movie. I am not sure how I can create a pull request with a file I created from scratch.
My script is located here in my own fork of cosima_recipes.
I can help you do that. From Tuesday/Wed?On 14 Jul 2024, at 14:03, Maurice F. Huguenin @.***> wrote: Hi all, I've created an animation script. It saves individual daily snapshots of sea surface velocity as .png files and then combines these frames into a .mp4 movie. I am not sure how I can create a pull request with a file I created from scratch. My script is located here in my own fork of cosima_recipes.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
SIDE NOTE:
In no way am I making any comment on @mauricehuguenin 's excellent work here. Just wanted to point folks to streamjoy in case there is interest.
https://ahuang11.github.io/streamjoy/example_recipes/oisst_globe/
I can help you do that. From Tuesday/Wed?
Sure, I am available tomorrow Navid - preferably after 4:30 pm (I am working in CET at the moment). Great link, thanks Thomas.
@mauricehuguenin add me as a collaborator in your repo and I can open the PR. Or we can zoom and I can help you do it.
Your call ;)