v0.14.0
animated_plot.sh
Go to the documentation of this file.
1 #!/bin/bash
2 # This script generates a animated plot movie using series of png plots.
3 # Default plot is crack area against load factor. Plot setttings can be changed
4 # by modifying the gnuplot script get_animated_plot.gnu
5 #
6 # Input:
7 # displacement_loadFactor_crackArea_energy.csv
8 #
9 # Output:
10 # animated_plot.mp4
11 #
12 # Usage:
13 # 1. Change working directory to the place where csv file is located.
14 # This csv file is generated after running plotting_data.sh
15 #
16 # 2. Make sure animated_plot.sh and get_animated_plot.gnu are accessible
17 # from the working directory. This can be done by either copying
18 # those two files to the working directory or adding them to the same
19 # PATH (in .bashrc or .bash_profile)
20 #
21 # 3. Make sure package ffmpeg is installed and loaded by a package
22 # manager, for example, spack.
23 #
24 # 4. If needed, modify parameter 'fps' in animated_plot.sh to the desired
25 # number of frames per second for the output movie
26 #
27 # 5. Run animated_plot.sh
28 #
29 # 6. Obtain animated movie, animated_plot.mp4, in the same directory.
30 # Movie will be opened automatically if macOS is used.
31 
32 # Generate png plots
33 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
34 gnuplot -e "load '$DIR/get_animated_plot.gnu'; quit"
35 
36 # Load ffmpeg, if already installed using spack
37 # spack load ffmpeg
38 
39 # Frame per second
40 fps=45
41 
42 # Generate animated plot
43 ffmpeg -y -f image2 -r $fps -i 'png/animated_plot_%03d.png' animated_plot.mp4
44 
45 # Delete generated png plots
46 rm -R png
47 
48 # Open animated plot
49 machine="$(uname -s)"
50 # echo ${machine}
51 if [ ${machine} = "Darwin" ]
52 then
53  # echo "This is a Mac computer"
54  open animated_plot.mp4
55 else
56  echo "Animated plot is ready to open"
57 fi