Plot a Reference CCF

[1]:
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

plt.style.use("ggplot")

from msnoise.core.db import connect
from msnoise.results import MSNoiseResult

# connect to the database
db = connect()

# Build a result object at the refstack step
result = MSNoiseResult.from_ids(db, preprocess=1, cc=1, filter=1, stack=1, refstack=1)

# Get the reference CCF for two stations, filter 1, ZZ component:
ref = result.get_ref(pair="PF.FJS.00:PF.FOR.00", components="ZZ",
                     )

ref.plot(figsize=(8, 8))

#EOF
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
File D:\PythonForSource\MSNoise_Stack\MSNoise\msnoise\core\db.py:153, in read_db_inifile(inifile)
    152 try:
--> 153     f = open(inifile, 'rb')
    154 #except FileNotFoundError:  # This is better but only for python3

FileNotFoundError: [Errno 2] No such file or directory: 'D:\\PythonForSource\\MSNoise_Stack\\MSNoise\\doc\\auto_examples\\db.ini'

During handling of the above exception, another exception occurred:

DBConfigNotFoundError                     Traceback (most recent call last)
Cell In[1], line 17
     14 from msnoise.results import MSNoiseResult
     16 # connect to the database
---> 17 db = connect()
     19 # Build a result object at the refstack step
     20 result = MSNoiseResult.from_ids(db, preprocess=1, cc=1, filter=1, stack=1, refstack=1)

File D:\PythonForSource\MSNoise_Stack\MSNoise\msnoise\core\db.py:104, in connect(inifile)
    101 if not inifile:
    102     inifile = os.path.join(os.getcwd(), 'db.ini')
--> 104 engine = get_engine(inifile)
    105 session = sessionmaker(bind=engine)
    106 return session()

File D:\PythonForSource\MSNoise_Stack\MSNoise\msnoise\core\db.py:67, in get_engine(inifile)
     65 from sqlalchemy import create_engine
     66 from sqlalchemy.pool import NullPool
---> 67 dbini = read_db_inifile(inifile)
     68 if dbini.tech == 1:
     69     engine = create_engine('sqlite:///%s' % dbini.hostname, echo=False,
     70                            connect_args={'check_same_thread': False})

File D:\PythonForSource\MSNoise_Stack\MSNoise\msnoise\core\db.py:156, in read_db_inifile(inifile)
    154 #except FileNotFoundError:  # This is better but only for python3
    155 except IOError:
--> 156     raise DBConfigNotFoundError(
    157             "No db.ini file in this directory, please run "
    158             "'msnoise db init' in this folder to initialize it as "
    159             "an MSNoise project folder.")
    160 try:
    161     # New ini file with prefix support
    162     tech, hostname, database, username, password, prefix = pickle.load(f)

DBConfigNotFoundError: No db.ini file in this directory, please run 'msnoise db init' in this folder to initialize it as an MSNoise project folder.