Logo
  • Home
  • Getting Started

API Overview

  • Index
  • Read WW3 Files
  • Body Waves
  • Rayleigh Waves
  • Temporal Variations
  • Synthetic Cross-Correlation Functions
  • To noisi

User Guide

  • Tutorials
  • Site Effect
    • Rayleigh Waves Site Effect
    • Body Waves Site Effect
  • Equivalent Vertical Force Maps
    • Rayleigh Waves Equivalent Vertical Force
    • Body Waves Equivalent Vertical Force
  • Rayleigh Waves Temporal Variations
  • Synthetic Cross-Correlation Functions
    • Rayleigh Waves Synthetic Cross-correlation Functions
    • Body Waves Synthetics Cross-correlation Functions
  • WMSAN to noisi
    • Make Nice Plots
    • WMSAN to Noisi
    • Generate Source Grid
    • Create Starting Model
    • Continue with the Noisi Introduction notebook
  • Synthetic Spectrograms
    • Rayleigh Waves Power Spectrum of Vertical Displacement
    • Rayleigh Waves Synthetic Spectrograms

Developer Guide

  • How to contribute ?

About

  • About
WMSAN
  • User Guide
  • WMSAN to noisi

WMSAN to noisi¶

In [1]:
Copied!
## Distributed python packages
import os
import datetime
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import xarray as xr
import re

from math import radians, log
from wmsan.wmsan_to_noisi import run, create_sourcegrid_WW3
__author__ = "Laura Ermert, Lisa Tomasetto"
__version__ = "0.1"
__maintainer__ = "Lisa Tomasetto"
__email__ = "lisa.tomasetto@univ-grenoble-alpes.fr"
__status__ = "Production"
## Distributed python packages import os import datetime import numpy as np import matplotlib import matplotlib.pyplot as plt import xarray as xr import re from math import radians, log from wmsan.wmsan_to_noisi import run, create_sourcegrid_WW3 __author__ = "Laura Ermert, Lisa Tomasetto" __version__ = "0.1" __maintainer__ = "Lisa Tomasetto" __email__ = "lisa.tomasetto@univ-grenoble-alpes.fr" __status__ = "Production"

Make Nice Plots¶

In [2]:
Copied!
plt.style.use("ggplot")
SMALL_SIZE = 18
MEDIUM_SIZE = 22
BIGGER_SIZE = 24

plt.rc('font', size=SMALL_SIZE)          # controls default text sizes
plt.rc('axes', titlesize=SMALL_SIZE)     # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE)    # fontsize of the x and y labels
plt.rc('xtick', labelsize=SMALL_SIZE)    # fontsize of the tick labels
plt.rc('ytick', labelsize=SMALL_SIZE)    # fontsize of the tick labels
plt.rc('legend', fontsize=SMALL_SIZE)    # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title
matplotlib.rcParams['pdf.fonttype'] = 42
plt.style.use("ggplot") SMALL_SIZE = 18 MEDIUM_SIZE = 22 BIGGER_SIZE = 24 plt.rc('font', size=SMALL_SIZE) # controls default text sizes plt.rc('axes', titlesize=SMALL_SIZE) # fontsize of the axes title plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title matplotlib.rcParams['pdf.fonttype'] = 42

WMSAN to Noisi¶

This Notebook aims at transforming the outputs of the equivalent vertical force matrix into a starting model for noisi cross-correlation modeling and source inversion.

  1. Install noisi

    Please follow the instructions to install noisi and run the noisi_introduction.ipynb Jupyter notebook until Step 4 (excluded).

  2. Compute Equivalent Vertical Source Maps

    Go to /ww3-source-maps/notebooks/rayleigh-waves/.

    Run the Jupyter notebook microseismic_sources.ipynb with the option save = True .

  3. Now you can run this script.

    It will generate a file sourcegrid.npy in the noisi examples directory noisi/noisi/examples/<example_name>.

    Then it will generate an hdf5 file F_yyyymmddhh.h5 which you can rename starting_model.h5and copy in /noisi/noisi/examples/wmsan/source_1/iteration_0.

    Continue running the noisi_introduction.ipynb notebook from Step 5.

Generate Source Grid¶

Once you run the next cell, a file named sourcegrid.npy should be in the noisi example directory you fill in.

In [3]:
Copied!
create_sourcegrid_WW3(-78, 80.5, -180, 180, '/Users/tomasetl/Documents/code/noisi/noisi/examples/wmsan/')
create_sourcegrid_WW3(-78, 80.5, -180, 180, '/Users/tomasetl/Documents/code/noisi/noisi/examples/wmsan/')

Create Starting Model¶

Then create a strating model to compute cross-correlations using noisi.

After running microseismic_sources.ipynb with the option save = True , you should see netcdf files matching corresponding dates in the /ww3-source-maps/notebooks/rayleigh-waves/F/ directory.

These files will be reformatted to fit the noisi format of the starting_model.h5given a source grid.

In [4]:
Copied!
# INPUT ######################################################################
    noise_source_file = "./F/F_2008111506.nc"  # the source file from microseism_source.ipynb in N.s^{1/2}
    # To compute the source term we need the square of the values in N^2.s (already multiplied by the surface area in m^2)

    grid_file = "/Users/tomasetl/Documents/code/noisi/noisi/examples/wmsan/sourcegrid.npy"
    # the green's function file is needed to get the right frequency sampling
    # and the right number of time steps.
    greens_function_file = "/Users/tomasetl/Documents/code/noisi/noisi/examples/wmsan/greens/G.SSB..MXZ.h5"
    
    # END ##################################################################
    output_file = re.sub("nc", "h5", noise_source_file)
    if os.path.exists(output_file):
        raise ValueError("Output file must not exist yet: " + output_file)
    run(noise_source_file, grid_file, greens_function_file)
# INPUT ###################################################################### noise_source_file = "./F/F_2008111506.nc" # the source file from microseism_source.ipynb in N.s^{1/2} # To compute the source term we need the square of the values in N^2.s (already multiplied by the surface area in m^2) grid_file = "/Users/tomasetl/Documents/code/noisi/noisi/examples/wmsan/sourcegrid.npy" # the green's function file is needed to get the right frequency sampling # and the right number of time steps. greens_function_file = "/Users/tomasetl/Documents/code/noisi/noisi/examples/wmsan/greens/G.SSB..MXZ.h5" # END ################################################################## output_file = re.sub("nc", "h5", noise_source_file) if os.path.exists(output_file): raise ValueError("Output file must not exist yet: " + output_file) run(noise_source_file, grid_file, greens_function_file)
<xarray.Dataset> Size: 16MB
Dimensions:    (frequency: 18, latitude: 317, longitude: 720, time: 240)
Coordinates:
  * latitude   (latitude) float32 1kB -78.0 -77.5 -77.0 -76.5 ... 79.0 79.5 80.0
  * longitude  (longitude) float32 3kB -180.0 -179.5 -179.0 ... 179.0 179.5
  * time       (time) datetime64[ns] 2kB 2008-11-15T06:00:00 ... 2008-11-15T0...
  * frequency  (frequency) float32 72B 0.09027 0.09929 0.1092 ... 0.4148 0.4562
Data variables:
    F_f        (frequency, latitude, longitude) float32 16MB 0.0 0.0 ... 0.0 0.0
Attributes:
    title:     Equivalent Vertical Force on 2008-11-15-06
    subtitle:  Equivalent Force every 3 hours for the secondary microseismic ...
Frequency 1 of 18
Frequency 2 of 18
Frequency 3 of 18
Frequency 4 of 18
Frequency 5 of 18
Frequency 6 of 18
Frequency 7 of 18
Frequency 8 of 18
Frequency 9 of 18
Frequency 10 of 18
Frequency 11 of 18
Frequency 12 of 18
Frequency 13 of 18
Frequency 14 of 18
Frequency 15 of 18
Frequency 16 of 18
Frequency 17 of 18
Frequency 18 of 18

Continue with the Noisi Introduction notebook¶

  1. Rename the output .h5 file as starting_model.h5
  2. Copy it in the /noisi/noisi/examples/wmsan/source_1/iteration_0 directory.
  3. Continue running the noisi_introduction.ipynb notebook from Step 5.
Previous Next

Built with MkDocs using a theme provided by Read the Docs.
GitLab « Previous Next »