.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\plot_interferogram.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_interferogram.py: Plot an interferogram ===================== .. GENERATED FROM PYTHON SOURCE LINES 7-48 .. code-block:: default import os if "SPHINX_DOC_BUILD" in os.environ: if "MSNOISE_DOC" in os.environ: os.chdir(os.environ["MSNOISE_DOC"]) import matplotlib matplotlib.use("agg") import matplotlib.pyplot as plt import numpy as np import pandas as pd from pandas.plotting import register_matplotlib_converters register_matplotlib_converters() plt.style.use("ggplot") from msnoise.api import connect, get_results, build_movstack_datelist, get_params, get_t_axis, xr_get_ccf # connect to the database db = connect() # Obtain a list of dates between ``start_date`` and ``enddate`` start, end, datelist = build_movstack_datelist(db) # Get the list of parameters from the DB: params = get_params(db) # Get the time axis for plotting the CCF: taxis = get_t_axis(db) # Get the first mov_stack configured: mov_stack = params.mov_stack[0] # Get the results for two station, filter id=1, ZZ component, mov_stack=1 and the results as a 2D array: ccf = xr_get_ccf("PF.FJS.00", "PF.FOR.00", "ZZ", 1, mov_stack, taxis, format="xarray") # Plot the interferogram ccf.plot(robust=True, figsize=(10,8)) .. rst-class:: sphx-glr-script-out .. code-block:: pytb Traceback (most recent call last): File "D:\PythonForSource\MSNoise_Stack\MSNoise\examples\plot_interferogram.py", line 27, in db = connect() File "d:\pythonforsource\msnoise_stack\msnoise\msnoise\api.py", line 109, in connect engine = get_engine(inifile) File "d:\pythonforsource\msnoise_stack\msnoise\msnoise\api.py", line 73, in get_engine dbini = read_db_inifile(inifile) File "d:\pythonforsource\msnoise_stack\msnoise\msnoise\api.py", line 159, in read_db_inifile raise DBConfigNotFoundError( msnoise.DBConfigNotFoundError: No db.ini file in this directory, please run 'msnoise db init' in this folder to initialize it as an MSNoise project folder. .. GENERATED FROM PYTHON SOURCE LINES 49-50 Running a simple moving window average can be done with pandas's functions: .. GENERATED FROM PYTHON SOURCE LINES 50-56 .. code-block:: default smooth = ccf.rolling(times=5).mean() smooth.plot(robust=True, figsize=(10,8)) .. GENERATED FROM PYTHON SOURCE LINES 57-58 Plotting the sub-daily stacks and zooming on +- 20 seconds: .. GENERATED FROM PYTHON SOURCE LINES 58-73 .. code-block:: default if "SPHINX_DOC_BUILD" in os.environ: if "MSNOISE_DOC" in os.environ: os.chdir(os.environ["MSNOISE_DOC"]) # Get the last mov_stack configured: mov_stack = params.mov_stack[-1] # Get the results for two station, filter id=1, ZZ component, mov_stack=1 and the results as a 2D array: ccf = xr_get_ccf("PF.FJS.00", "PF.FOR.00", "ZZ", 1, mov_stack, taxis, format="xarray") # Plot the interferogram and zoom in around +- 10 seconds lag ccf.loc[:,-20:20].plot(robust=True, figsize=(10,8)) .. GENERATED FROM PYTHON SOURCE LINES 74-75 Finally, stacking to a Reference function .. GENERATED FROM PYTHON SOURCE LINES 75-78 .. code-block:: default ccf.mean(axis=0).plot(figsize=(10,8)) #EOF .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.003 seconds) .. _sphx_glr_download_auto_examples_plot_interferogram.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_interferogram.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_interferogram.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_