diff --git a/scripts/icar_visualization.py b/scripts/icar_visualization.py index 59051886..4a01e89e 100644 --- a/scripts/icar_visualization.py +++ b/scripts/icar_visualization.py @@ -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)