Open AndyHoggANU opened 4 years ago
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.
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...
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...