Skip to content

A simple forward computation

Diego Melgar edited this page Jun 20, 2017 · 17 revisions

Before you begin

  • Install Mudpy. If you've already done this then run git pull from your terminal to make sure you have the up to date latest version with the right example files.
  • Configure MudPy for multiprocessor use, this can sometimes be painful and is NOT a necessary step, but try, it'll make your computations much much faster. Even your crappy laptop has at least 4 cores!

Do you have all the example files?

Look under $MUDPY/examples/forward_modeling/ you should see a listing of 6 files like so:

Ok, open the file nepal.fwd.py this is the main parameter file that you will use to command the program. This file can live anywhere in your system it doesn't really matter where.

Initialize a new project folder tree

In order to make things run smoothly and keep everything organized MudPy uses a very specific fodler structure. THis will be created for you. In the parameter file nepal.fwd.py edit the following lines:

home='/Users/dmelgar/Slip_inv/'
project_name='Nepal_forward_test'

home must already exist and is where all your MudPy projects will be stored. project_name is a name to give this particular project. This will be used to create the fodler structure. Note this is completely independent of where you are storing your .fwd.py parameter files.

Now set the action flags as follows:

init=1 
make_green=0 
make_synthetics=0 
solve=0

You are now ready to run the parameter file to create the folder structure. At your terminal run the python parameter file:

$ python $PATH_TO_FILE/nepal.fwd.py

$PATH_TO_FILE is the path where you are storing the parameter file. After s execution you should now see a new folder structure under home/project_name like so:

Prepare auxiliary files

For a forward run you will need 5 auxiliary files defining the Earth structure model, the fault geometry, the kinematic rupture, and the station locations and kinds of data you want to synthesize. Note that these files need to be in very specific locations where MudPy will look for them.

  1. Earth structure: Copy the file avouac.mod from the examples folder to home/project_name/structure/ the file should look like so:

The first column is the layer thickness in km, the second column is vs in km/s, the third column is vp in km/s, the fourth column is density in g/cm^3, the fifth column is Qs and the last column is Qp.

  1. Station locations file: Copy the file nepal.sta to home/project_name/data/station_info/. This file is simply the coordinates of the sites you are interested in synthesizing. For this example these are the locations of high rate GPS stations.

  2. Station gflist file: Copy the file gps.gflist' to home/project_name/data/station_info/`. THis file controls what types of data re synthesized, displacement (GPS), velocity (strong motion), InSAR, etc. You need to modify the paths to point to your specific project folder, right now it looks like this and points to the project folder on my system:

The columns with the 1's and 0's indicate which type of data we want to synthesized. In this case we are requesting high-rate displacement data.

  1. Fault geometry: Copy the file nepal.fault to home/project_name/data/model_info/. This file contains the fault geometry (nothing on the rupture kinematics yet) and you will need to build yourself. The header line indicates what each column is.

  2. Kinematic rupture model: Copy the file nepal.rupt to home/project_name/forward_models. This file contains the kinematic rupture description, explanations of the columns are in the headers. You need to create this file. If you have USGS finite fault inversions look under $MUDPY/src/python/mudpy/forward.py there are two functions which you might be able to modify to suit your needs, usgs2fault() creates the .fault geometry file and usgs2rupt() creates the kinematic .rupt rupture file

Run the Green's functions and synthetics

Now you are ready to generate impulse response Green's functions and convolve them with the source time function shape fo your choosing to generate synthetics. Set the action flags as follows:

init=0 
make_green=1 
make_synthetics=1 
solve=0

Now set the number of cpus you have available for computation, on my laptop this is ncpus=8. Remember to look at the openMPI instructions (see above) to make sure parallel computing works for you. Now define static=0 to ensure you compute waveforms instead of static offsets. Also define all the auxiliary files:

model_name='avouac.mod'   
rupture_name='nepal.rupt'   
fault_name='nepal.fault'    
station_file='nepal.sta'   
GF_list='gps.gflist'
G_from_file=False
G_name='nepal'

Next define the waveform parameters:

NFFT=512 ; dt=0.2  
dk=0.2 ; pmin=0 ; pmax=1 ; kmax=10   
custom_stf=None

This will generate synthetics with 512 samples sampled at 5Hz or 0.2s between samples. Now specify the event origin:

time_epi=UTCDateTime('2015-04-25T06:11:26')
epicenter=array([84.708,28.147,15]) 

And make sure you set integrate=1 if you are interested in displacement synthetics or integrate=0 for velocity synthetics.

That's it! Now run it like last time by typing at your terminal $ python $PATH_TO_FILE/nepal.fwd.py. You should see a lot of output indicating progress and you can see the GF's and synthetics being stored under home/project_name/GFs/dynamic/.

Run the waveform calculation

After the GFs and synthetics are done set the action flags as follows for the waveform calculation:

init=0 
make_green=0
make_synthetics=0
solve=1

And now simply run the parameter file again by typing at your terminal $ python $PATH_TO_FILE/nepal.fwd.py. This will load all the synthetics into a big fat matrix, delay them according tot he rupture onset times and matrix multiply with the slip model. The matrix containing the synthetics will be saved with the G_name value you specified in the parameter file and stored under home/project_name/GFs/matrices. provided you DON'T change the synthetics, you can speed up any re-runs by setting G_from_file=True. This will load the matrix rather than read each synthetic individually.

Now check the output. Data are stored in home/project_name/output/waveforms/. Data re always saved in SAC format and in SI units, meters for displacement data and meters/second for velocity data. In ipython you can do:

from matplotlib import pyplot as plt
from obspy import read

st=read(u'/Users/dmelgar/Slip_inv/Nepal_forward_test/output/waveforms/nepal.rupt/KATNP.LYN.sac')
plt.plot(st[0].times(),st[0].data)
plt.show()

which should produce this plot: