<jupyter_start><jupyter_text>Reproducing Figure 3 in Porter et al., 2011In this example we generate *P* receiver functions for a model that includes either a dipping lower crustal layer or a lower-crustal anisotropic layer. These example reproduce the results of Figure 3 in [Porter et al. (2011)](references).Start by importing the necessary packages:<jupyter_code>import numpy as np
from pyraysum import prs<jupyter_output><empty_output><jupyter_text>Define the arrays of slowness and back-azimuth values of the incident `P` wave to use as input in the simulation<jupyter_code>baz = np.arange(0., 360., 10.)
slow = 0.06<jupyter_output><empty_output><jupyter_text>Load the model file that includes layer dip<jupyter_code>model = prs.read_model('../models/model_Porter2011_dip.txt')<jupyter_output><empty_output><jupyter_text>Run the simulation. Here we specify the argument `rot=1` to produce seismograms aligned in the `R-T-Z` coordinate system. The default value is `rot=0`, which produces seismograms aligned in the `N-E-Z` coordinate system, which cannot be used to calculate receiver functions. Furthermore, we are interested only in the direct conversions, and therefore specify `mults=0` to avoid dealing with multiples. This is required to reproduce the published examples, although it is good practice to keep all first-order multiples to properly simulate the full Green's functions.<jupyter_code>streamlist = prs.run_prs(model, baz, slow, rot=1, mults=0)<jupyter_output><empty_output><jupyter_text>The function returns a `StreamList` object whose attributes are the `Model`, geometry `(baz, slow)`, a list of `Streams` as well as all run-time arguments that are used by Raysum:<jupyter_code>streamlist.__dict__.keys()<jupyter_output><empty_output><jupyter_text>We can then use the method `calculate_rfs` to calculate receiver functions:<jupyter_code>streamlist.calculate_rfs()<jupyter_output><empty_output><jupyter_text>The receiver functions are stored as an additional attribute of the streamlist object, which is itself a list of `Streams` containing the radial and transverse component RFs:<jupyter_code>streamlist.__dict__.keys()<jupyter_output><empty_output><jupyter_text>We can now filter and plot the results - we specify the key `'rfs'` to work on the receiver functions only.<jupyter_code>streamlist.filter('rfs', 'lowpass', freq=1., zerophase=True, corners=2)
streamlist.plot('rfs', tmin=-0.5, tmax=8.)<jupyter_output><empty_output><jupyter_text>Now let's reproduce the second case with the anisotropic lower crustal layer. We simply load the corresponding model and run the functions sequentially again:<jupyter_code>model = prs.read_model('../models/model_Porter2011_aniso.txt')
streamlist = prs.run_prs(model, baz, slow, dt=0.01, npts=6000, rot=1,
                         verbose=False, wvtype='P', mults=0)
streamlist.calculate_rfs()

streamlist.filter('rfs', 'lowpass', freq=1., zerophase=True, corners=2)
streamlist.plot('rfs', tmin=-0.5, tmax=8.)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09444629198536747, 'fraction_numerical': 0.016960425673428665, 'mean_word_length': 6.538847117794486, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '494173', 'license': 'MIT', 'n_tokens_mistral': 978, 'n_tokens_neox': 922, 'n_words': 309, 'path': 'pyraysum/examples/notebooks/sim_Porter2011.ipynb', 'repo_name': 'xumi1993/PyRaysum', 'size': '3007'}