<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Quasidynamic earthquake simulation plotting
Here, we'll make some useful plots to see what happened in the QD simulation from fullspace_qd_run.ipynb.
First, let's import our tools!
Step1:  Now, we load the data from the previous run. Check what folder was created! If you ran the simulation code multiple times, each time a new folder will be created in sequential order (data0, data1, data2, ...). This tct.qd.load function hides some of the data loading logic that was described at the end of fullspace_qd_run.ipynb.
Step2:  It can be nice to make some figures while the simulation is still running. For long running, large simulations, it's expensive to reload all the data, so load_new_files() allows updating the data object with any new time steps that have been completed and saved. By default, results are saved in 100 time step chunks. Look in the data0 folder to see.
Step3:  Create the plotting object. This process the data a bit to make field like slip and velocity easier to plot.
Step4:  The summary() function makes four useful plots that show the overall evolution of the fault
Step5:  The qdp.V_info function provides the necessary values, levels, contour levels, and colormap to the qdp.nicefig function to make a handy figure of the state of the x component of slip rate at the 1050th time step.
Step6:  Let's make a whole bunch of this same figure and turn them into a video. We'll make a figure every 4th step and name the final video qd_video. This should create a qd_video0.mp4 file. Enjoy!
<ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import tectosaur as tct
import tectosaur.qd
import tectosaur.qd.plotting
tct.qd.configure(
    gpu_idx = 0, # Which GPU to use if there are multiple. Best to leave as 0. 
    fast_plot = True, # Let's make fast, inexpensive figures. Set to false for higher resolution plots with latex fonts. 
)
plt.style.use('default')
Explanation: Quasidynamic earthquake simulation plotting
Here, we'll make some useful plots to see what happened in the QD simulation from fullspace_qd_run.ipynb.
First, let's import our tools!
End of explanation
folder_name = 'data0'
data = tct.qd.load(folder_name, tct.qd.FullspaceModel)
Explanation: Now, we load the data from the previous run. Check what folder was created! If you ran the simulation code multiple times, each time a new folder will be created in sequential order (data0, data1, data2, ...). This tct.qd.load function hides some of the data loading logic that was described at the end of fullspace_qd_run.ipynb.
End of explanation
data.load_new_files()
Explanation: It can be nice to make some figures while the simulation is still running. For long running, large simulations, it's expensive to reload all the data, so load_new_files() allows updating the data object with any new time steps that have been completed and saved. By default, results are saved in 100 time step chunks. Look in the data0 folder to see.
End of explanation
qdp = tct.qd.plotting.QDPlotData(data)
Explanation: Create the plotting object. This process the data a bit to make field like slip and velocity easier to plot.
End of explanation
qdp.summary()
Explanation: The summary() function makes four useful plots that show the overall evolution of the fault:
The minimum state variable value on the fault as a function of time.
The $log_{10}$ of the maximum slip rate on the fault as a function of time.
The time as a function of time step index.
The time step size as a function of time step index.
From this summary, we can see that as the fault evolved, there were some slow slip events of growing magnitude until at approximate time 0.042, the fault ruptured for the first time. It ruptured again at time 0.047.
End of explanation
qdp.nicefig(*qdp.V_info(99), dim = [0,2])
Explanation: The qdp.V_info function provides the necessary values, levels, contour levels, and colormap to the qdp.nicefig function to make a handy figure of the state of the x component of slip rate at the 1050th time step.
End of explanation
video_name = qdp.qd_video(range(1, qdp.n_steps, 4), qdp.V_info, video_prefix = 'qd_video', dim = [0,2])
tct.qd.plotting.make_mp4(video_name)
Explanation: Let's make a whole bunch of this same figure and turn them into a video. We'll make a figure every 4th step and name the final video qd_video. This should create a qd_video0.mp4 file. Enjoy!
End of explanation
<END_TASK>