Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions scripts/icar_visualization.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# IPython log file

import xarray as xr
import os
import xarray as xr
import matplotlib.pyplot as plt

ds=xr.open_dataset("output_simple/icar_out_000001_2000-10-01_00-00-00.nc") # image 000001 domain partition
import matplotlib.animation as animation

data_dir_path=os.environ.get("TRAINING_DATA")
ds=xr.open_mfdataset(data_dir_path + "/training_input-image-_*.nc") # temporarily hardcoded file
print(ds)
ds["precipitation"][-1].plot() # -1 refers to last time step
ds["precipitation"][-1].plot(vmax=2) # set max of color scale (for a longer time, try vmax ~ 2000)
ds["precipitation"][ -1].plot() # -1 refers to last time step
#ds["precipitation"][-1].plot(vmax=2) # set max of color scale (for a longer time, try vmax ~ 2000)


# write an image to a file
for i in range(len(ds.time)):
fig, ax = plt.subplots()
def func(frame):
plt.clf()
ds["precipitation"][i].plot(vmax=2)
plt.pause(0.1) # 0.1 sec pause between frames
plt.savefig("file_name.png") # edit this to insert frame number into file name to prevent overwrites
ds["precipitation"][frame].plot(vmax=2)
# plt.pause(0.1) # 0.1 sec pause between frames

#anim = animation.FuncAnimation(fig,func,len(ds.time))
anim = animation.FuncAnimation(fig,func,60)

anim.save('animation02 .mp4','ffmpeg',30)