Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

animation output example #2

Open
ZhiangChen opened this issue May 15, 2023 · 0 comments
Open

animation output example #2

ZhiangChen opened this issue May 15, 2023 · 0 comments

Comments

@ZhiangChen
Copy link

from PIL import Image
import os


if not os.path.exists('save_fig'):
    os.makedirs(save_fig)
else:
    [os.remove(os.path.join('save_fig',f)) for f in os.listdir('save_fig') if f.endswith('.png')]

frames = []
for i in range(200):
    start_time = time.time()
    # Flow Accumulator
    fr.run_one_step()
    # Stream Power
    spr.run_one_step(dt)
    # linear Diffuser
    dd.run_one_step(dt)
    
    frame = grid.at_node["topographic__elevation"][:].reshape(grid.shape)
    plt.imshow(frame)
    plt.colorbar()
    plt.savefig(f'save_fig/{i}.png')
    plt.close()
    frames.append(Image.open(f'save_fig/{i}.png')) 
    
frames[0].save('output.gif', format='GIF', append_images=frames[1:], save_all=True, duration=50, loop=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant