Getting Started#

Welcome to the NoisePy Colab Tutorial!

This tutorial will walk you through the basic steps of using NoisePy to compute ambient noise cross correlation functions.

First, we install the noisepy-seis package

# Uncomment and run this line if the environment doesn't have noisepy already installed:
# ! pip install noisepy-seis 

Warning: NoisePy uses obspy as a core Python module to manipulate seismic data. Restart the runtime now for proper installation of obspy on Colab.

Then we import the basic modules

from noisepy.seis import download, cross_correlate, stack_cross_correlations, __version__
from noisepy.seis.io import plotting_modules
from noisepy.seis.io.asdfstore import ASDFRawDataStore, ASDFCCStore, ASDFStackStore
from noisepy.seis.io.datatypes import CCMethod, ConfigParameters, FreqNorm, RmResp, TimeNorm
from datetime import datetime, timezone
from datetimerange import DateTimeRange
import os
import shutil
print(f"Using NoisePy version {__version__}")

path = os.path.join(".", "get_started_data")

os.makedirs(path,exist_ok=True)
raw_data_path = os.path.join(path, "RAW_DATA")
cc_data_path = os.path.join(path, "CCF")
stack_data_path = os.path.join(path, "STACK")
/opt/hostedtoolcache/Python/3.10.17/x64/lib/python3.10/site-packages/noisepy/seis/io/utils.py:13: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)
  from tqdm.autonotebook import tqdm
Using NoisePy version 0.1.dev1

Ambient Noise Project Configuration#

We store the metadata information about the ambient noise cross correlation workflow in a ConfigParameters() object. We first initialize it, then we tune the parameters for this cross correlation.

config = ConfigParameters() # default config parameters which can be customized
config.inc_hours = 12
config.sampling_rate = 20  # (int) Sampling rate in Hz of desired processing (it can be different than the data sampling rate)
config.cc_len = 3600  # (float) basic unit of data length for fft (sec)
    # criteria for data selection
config.ncomp = 3  # 1 or 3 component data (needed to decide whether do rotation)

config.acorr_only = False  # only perform auto-correlation or not
config.xcorr_only = True  # only perform cross-correlation or not

config.inc_hours = 12 # if the data is first 

config.lamin = 31       # min latitude
config.lamax = 42       # max latitude
config.lomin = -124     # min longitude
config.lomax = -115     # max longitude

# pre-processing parameters
config.step = 1800.0  # (float) overlapping between each cc_len (sec)
config.stationxml = False  # station.XML file used to remove instrument response for SAC/miniseed data
config.rm_resp = RmResp.INV  # select 'no' to not remove response and use 'inv' if you use the stationXML,'spectrum',
config.freqmin = 0.05
config.freqmax = 2.0
config.max_over_std  = 10  # threshold to remove window of bad signals: set it to 10*9 if prefer not to remove them

# TEMPORAL and SPECTRAL NORMALISATION
config.freq_norm = FreqNorm.RMA # choose between "rma" for a soft whitenning or "no" for no whitening. Pure whitening is not implemented correctly at this point.
config.smoothspect_N = 10  # moving window length to smooth spectrum amplitude (points)
    # here, choose smoothspect_N for the case of a strict whitening (e.g., phase_only)

config.time_norm = TimeNorm.NO  # 'no' for no normalization, or 'rma', 'one_bit' for normalization in time domain,
    # TODO: change time_norm option from "no" to "None"
config.smooth_N = 10  # moving window length for time domain normalization if selected (points)

config.cc_method = CCMethod.XCORR # 'xcorr' for pure cross correlation OR 'deconv' for deconvolution;
    # FOR "COHERENCY" PLEASE set freq_norm to "rma", time_norm to "no" and cc_method to "xcorr"

# OUTPUTS:
config.substack = True  # True = smaller stacks within the time chunk. False: it will stack over inc_hours
config.substack_windows = 1  # how long to stack over (for monitoring purpose)
    # if substack=True, substack_windows=2, then you pre-stack every 2 correlation windows.
    # for instance: substack=True, substack_windows=1 means that you keep ALL of the correlations

config.maxlag = 200  # lags of cross-correlation to save (sec)
config.substack = True

Step 0: download data#

This step will download data using obspy and save them into ASDF files locally. The data will be stored for each time chunk defined in hours by inc_hours.

The download will clean up the raw data by detrending, removing the mean, bandpassing (broadly), removing the instrumental response, merging gaps, ignoring too-gappy data.

Use the function download with the following arguments:

  • path:where to put the data

  • config: configuration settings, in particular:

    • channel: list of the seismic channels to download, and example is shown below

    • stations: list of the seismic stations, it can be “*” (not “all”)

    • start_time

    • end_time

  • client_url_key: the string for FDSN clients

config.networks = ["*"]
config.stations = ["A*"]
config.channels = ["BH?"]
config.start_date = datetime(2019, 2, 1, tzinfo=timezone.utc)
config.end_date = datetime(2019, 2, 2, tzinfo=timezone.utc)
timerange = DateTimeRange(config.start_date, config.end_date)

# Download data locally. Enters raw data path, channel types, stations, config, and fdsn server.
download(raw_data_path, config)
2025-04-17 01:59:06,826 140136010730368 INFO fdsn_download.download(): Download
        From: 2019-02-01T00:00:00.000000Z
        To: 2019-02-02T00:00:00.000000Z
        Networks: ['*']
        Stations: ['A*']
        Channels: ['BH?']
        
2025-04-17 01:59:09,027 140136010730368 INFO fdsn_download.download(): Fetched inventory
2025-04-17 01:59:09,028 140136010730368 INFO utils.log_raw(): TIMING:  2.202 secs for Getting inventory
2025-04-17 01:59:11,295 140134477465280 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHE | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:11,506 140134225807040 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHE | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:11,514 140134341150400 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHE | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:11,523 140134378899136 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHN | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:11,674 140134496339648 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHZ | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:11,703 140134244681408 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHZ | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:11,719 140134360024768 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHN | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:11,781 140134206932672 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHN | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:13,481 140136010730368 INFO fdsn_download.download(): Downloaded BHE/bhe_00
2025-04-17 01:59:13,897 140136010730368 INFO fdsn_download.download(): Downloaded BHE/bhe_00
2025-04-17 01:59:14,051 140136010730368 INFO fdsn_download.download(): Downloaded BHN/bhn_00
2025-04-17 01:59:14,191 140136010730368 INFO fdsn_download.download(): Downloaded BHN/bhn_00
2025-04-17 01:59:14,310 140136010730368 INFO fdsn_download.download(): Downloaded BHE/bhe_00
2025-04-17 01:59:14,427 140136010730368 INFO fdsn_download.download(): Downloaded BHZ/bhz_00
2025-04-17 01:59:14,550 140136010730368 INFO fdsn_download.download(): Downloaded BHZ/bhz_00
2025-04-17 01:59:14,748 140136010730368 INFO fdsn_download.download(): Downloaded BHN/bhn_00
2025-04-17 01:59:14,779 140134477465280 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHZ | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:15,144 140134341150400 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHE | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:15,374 140134378899136 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHN | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:15,658 140134360024768 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHZ | 2019-02-01T00:00:00.000000Z - 2019-02-01T11:59:59.950000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:15,924 140136010730368 INFO fdsn_download.download(): Downloaded BHZ/bhz_00
2025-04-17 01:59:16,462 140136010730368 INFO fdsn_download.download(): Downloaded BHN/bhn_00
2025-04-17 01:59:16,576 140136010730368 INFO fdsn_download.download(): Downloaded BHE/bhe_00
2025-04-17 01:59:16,757 140136010730368 INFO fdsn_download.download(): Downloaded BHZ/bhz_00
2025-04-17 01:59:18,905 140134341150400 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHE | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:19,042 140134360024768 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHN | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:19,054 140134378899136 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHZ | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:19,334 140134477465280 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHN | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:19,412 140134206932672 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHE | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:19,578 140134496339648 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHN | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:19,674 140134244681408 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHZ | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:19,696 140134225807040 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHE | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:21,279 140136010730368 INFO fdsn_download.download(): Downloaded BHN/bhn_00
2025-04-17 01:59:21,583 140136010730368 INFO fdsn_download.download(): Downloaded BHE/bhe_00
2025-04-17 01:59:21,786 140136010730368 INFO fdsn_download.download(): Downloaded BHZ/bhz_00
2025-04-17 01:59:21,934 140136010730368 INFO fdsn_download.download(): Downloaded BHN/bhn_00
2025-04-17 01:59:22,053 140136010730368 INFO fdsn_download.download(): Downloaded BHE/bhe_00
2025-04-17 01:59:22,169 140136010730368 INFO fdsn_download.download(): Downloaded BHN/bhn_00
2025-04-17 01:59:22,287 140136010730368 INFO fdsn_download.download(): Downloaded BHE/bhe_00
2025-04-17 01:59:22,406 140136010730368 INFO fdsn_download.download(): Downloaded BHZ/bhz_00
2025-04-17 01:59:23,179 140134378899136 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHN | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:23,196 140134360024768 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHZ | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:23,259 140134341150400 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHE | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:23,359 140134477465280 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHZ | 2019-02-01T11:59:59.950000Z - 2019-02-01T23:59:59.900000Z | 20.0 Hz, 864000 samples using inv
2025-04-17 01:59:24,413 140136010730368 INFO fdsn_download.download(): Downloaded BHN/bhn_00
2025-04-17 01:59:24,556 140136010730368 INFO fdsn_download.download(): Downloaded BHE/bhe_00
2025-04-17 01:59:24,670 140136010730368 INFO fdsn_download.download(): Downloaded BHZ/bhz_00
2025-04-17 01:59:24,785 140136010730368 INFO fdsn_download.download(): Downloaded BHZ/bhz_00
2025-04-17 01:59:24,901 140136010730368 INFO utils.log_raw(): TIMING: 18.075 secs for Total Download

List the files that were downloaded, just to make sure !

print(os.listdir(raw_data_path))
['2019_02_01_00_00_00T2019_02_01_12_00_00.h5', '2019_02_01_12_00_00T2019_02_02_00_00_00.h5', 'station.csv']

Plot the raw data, make sure it’s noise!

file = os.path.join(raw_data_path, "2019_02_01_00_00_00T2019_02_01_12_00_00.h5")
raw_store = ASDFRawDataStore(raw_data_path) # Store for reading raw data
timespans = raw_store.get_timespans()
plotting_modules.plot_waveform(raw_store, timespans[0], 'CI','ADO', 0.01, 0.4) # this function takes for input: filename, network, station, freqmin, freqmax for a bandpass filter
_images/3739665e26fe2ce58b8011398ccbd43565a147991825f79b65a41dbe90ccbe0c.png

Step 1: Cross-correlation#

This step will perform the cross correlation. For each time chunk, it will read the data, perform classic ambient noise pre-processing (time and frequency normalization), FFT, cross correlation, substacking, saving cross correlations in to a temp ASDF file (this is not fast and will be improved).

# For this tutorial make sure the previous run is empty
if os.path.exists(cc_data_path):
    shutil.rmtree(cc_data_path)
config.freq_norm = FreqNorm.RMA
cc_store = ASDFCCStore(cc_data_path) # Store for writing CC data

# print the configuration parameters. Some are chosen by default but we cab modify them
print(config)
client_url_key='SCEDC' start_date=datetime.datetime(2019, 2, 1, 0, 0, tzinfo=datetime.timezone.utc) end_date=datetime.datetime(2019, 2, 2, 0, 0, tzinfo=datetime.timezone.utc) sampling_rate=20 single_freq=True cc_len=3600 lamin=31 lamax=42 lomin=-124 lomax=-115 down_list=False networks=['*'] stations=['A*'] channels=['BH?'] step=1800.0 freqmin=0.05 freqmax=2.0 freq_norm=<FreqNorm.RMA: 'rma'> time_norm=<TimeNorm.NO: 'no'> cc_method=<CCMethod.XCORR: 'xcorr'> smooth_N=10 smoothspect_N=10 substack=True substack_windows=1 maxlag=200 inc_hours=12 max_over_std=10 ncomp=3 stationxml=False rm_resp=<RmResp.INV: 'inv'> rm_resp_out='VEL' respdir=None acorr_only=False xcorr_only=True stack_method=<StackMethod.LINEAR: 'linear'> keep_substack=False rotation=True correction=False correction_csv=None storage_options=defaultdict(<class 'dict'>, {})

Perform the cross correlation

cross_correlate(raw_store, config, cc_store)
2025-04-17 01:59:25,840 140136010730368 INFO correlate.cross_correlate(): Starting Cross-Correlation with 4 cores
2025-04-17 01:59:25,867 140136010730368 INFO utils.log_raw(): TIMING CC Main:  0.025 secs for get 12 channels
2025-04-17 01:59:25,868 140136010730368 INFO correlate.cc_timespan(): Checking for stations already done: 10 pairs
2025-04-17 01:59:25,870 140136010730368 INFO utils.log_raw(): TIMING CC Main:  0.002 secs for check for 4 stations already done (warm up cache)
2025-04-17 01:59:25,872 140136010730368 INFO utils.log_raw(): TIMING CC Main:  0.002 secs for check for stations already done
2025-04-17 01:59:25,872 140136010730368 INFO correlate.cc_timespan(): Still need to process: 4/4 stations, 12/12 channels, 10/10 pairs for 2019-02-01T00:00:00+0000 - 2019-02-01T12:00:00+0000
2025-04-17 01:59:26,169 140136010730368 INFO correlate._filter_channel_data(): Picked 20.0 as the closest sampling_rate to 20.0. 
2025-04-17 01:59:26,170 140136010730368 INFO correlate._filter_channel_data(): Filtered to 12/12 channels with sampling rate == 20.0
2025-04-17 01:59:26,171 140136010730368 INFO utils.log_raw(): TIMING CC Main:  0.299 secs for Read channel data: 12 channels
2025-04-17 01:59:26,424 140133133190848 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHE | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:26,479 140133487609536 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHN | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:26,494 140133286282944 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHE | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:26,503 140133267408576 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHN | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:26,507 140133170939584 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHZ | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:26,524 140133152065216 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHN | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:26,552 140133305157312 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHE | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:26,559 140133468735168 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHZ | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:28,956 140133286282944 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHZ | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:29,296 140133487609536 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHE | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:29,335 140133267408576 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHZ | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:29,349 140133133190848 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHN | 2019-02-01T00:00:00.000000Z - 2019-02-01T12:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:30,660 140136010730368 INFO utils.log_raw(): TIMING CC Main:  4.490 secs for Preprocess: 12 channels
2025-04-17 01:59:30,661 140136010730368 INFO correlate.check_memory(): Require  0.07gb memory for cross correlations
2025-04-17 01:59:31,297 140136010730368 INFO utils.log_raw(): TIMING CC Main:  0.635 secs for Compute FFTs: 12 channels
2025-04-17 01:59:31,298 140136010730368 INFO correlate.cc_timespan(): Starting CC with 10 station pairs
2025-04-17 01:59:32,911 140136010730368 INFO utils.log_raw(): TIMING CC Main:  1.614 secs for Correlate and write to store
2025-04-17 01:59:33,002 140136010730368 INFO utils.log_raw(): TIMING CC Main:  7.161 secs for Process the chunk of 2019-02-01T00:00:00+0000 - 2019-02-01T12:00:00+0000
2025-04-17 01:59:33,032 140136010730368 INFO utils.log_raw(): TIMING CC Main:  0.025 secs for get 12 channels
2025-04-17 01:59:33,033 140136010730368 INFO correlate.cc_timespan(): Checking for stations already done: 10 pairs
2025-04-17 01:59:33,035 140136010730368 INFO utils.log_raw(): TIMING CC Main:  0.002 secs for check for 4 stations already done (warm up cache)
2025-04-17 01:59:33,036 140136010730368 INFO utils.log_raw(): TIMING CC Main:  0.002 secs for check for stations already done
2025-04-17 01:59:33,037 140136010730368 INFO correlate.cc_timespan(): Still need to process: 4/4 stations, 12/12 channels, 10/10 pairs for 2019-02-01T12:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 01:59:33,305 140136010730368 INFO correlate._filter_channel_data(): Picked 20.0 as the closest sampling_rate to 20.0. 
2025-04-17 01:59:33,305 140136010730368 INFO correlate._filter_channel_data(): Filtered to 12/12 channels with sampling rate == 20.0
2025-04-17 01:59:33,306 140136010730368 INFO utils.log_raw(): TIMING CC Main:  0.270 secs for Read channel data: 12 channels
2025-04-17 01:59:33,530 140133487609536 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHE | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv

2025-04-17 01:59:33,565 140133349197504 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHN | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:33,570 140133267408576 INFO noise_module.preprocess_raw(): removing response for CI.ADO..BHZ | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:33,641 140134378899136 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHN | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:33,700 140134211126976 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHN | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:33,776 140134341150400 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHE | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:33,789 140133330323136 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHE | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:33,795 140134360024768 INFO noise_module.preprocess_raw(): removing response for CI.ALP..BHZ | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:36,320 140134378899136 INFO noise_module.preprocess_raw(): removing response for CI.ARV..BHZ | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:36,425 140133487609536 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHE | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:36,544 140133267408576 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHZ | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:36,547 140133349197504 INFO noise_module.preprocess_raw(): removing response for CI.AVM..BHN | 2019-02-01T12:00:00.000000Z - 2019-02-02T00:00:00.000000Z | 20.0 Hz, 864001 samples using inv
2025-04-17 01:59:37,845 140136010730368 INFO utils.log_raw(): TIMING CC Main:  4.540 secs for Preprocess: 12 channels
2025-04-17 01:59:37,847 140136010730368 INFO correlate.check_memory(): Require  0.07gb memory for cross correlations
2025-04-17 01:59:38,485 140136010730368 INFO utils.log_raw(): TIMING CC Main:  0.638 secs for Compute FFTs: 12 channels
2025-04-17 01:59:38,487 140136010730368 INFO correlate.cc_timespan(): Starting CC with 10 station pairs
2025-04-17 01:59:39,809 140136010730368 INFO utils.log_raw(): TIMING CC Main:  1.323 secs for Correlate and write to store
2025-04-17 01:59:39,900 140136010730368 INFO utils.log_raw(): TIMING CC Main:  6.893 secs for Process the chunk of 2019-02-01T12:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 01:59:39,906 140136010730368 INFO utils.log_raw(): TIMING CC Main: 14.066 secs for Step 1 in total with 4 cores

Plot a single set of the cross correlation

pairs = cc_store.get_station_pairs()
timespans = cc_store.get_timespans(*pairs[0])
plotting_modules.plot_substack_cc(cc_store, timespans[0], 0.1, 1, 200, False)
_images/3855713349fba54585bbce440d9ccdfa2af65fb96bab32d4313489f06d7b49c9.png _images/7ac368a10692e202e4271368ac8b377cea4165b1db44d5443408104e0427e118.png _images/e3aea3ec6c7757c64c5ab2b912c22b3aaacebbe7f997000065104d754a01078a.png _images/833bcf770e93d6f401b0074f780f9dc31bb9faf64adc7edd6eb72005e6edb370.png _images/349f0f0d780fe195d629702128aedbb96d591801316f34c1b235f0b0b8c4a1c2.png _images/0472546356269431a3311f2f89e52b540935b5ee3e6abe4160b3b691104ce295.png _images/78c5e600581dbcaeb2d1659a3a4893262aad10dc80f6eebed8d98d7ac36af06a.png _images/7262aeac6325c21241f5cac498729344bd37a05b1a02cf6b7a38588c986a23a4.png _images/a629ea91fae630f47ca742209dcbd66728c738056dad761f2f786d35a135c52a.png _images/6bbd5f258d2b27414f1a6cc200cad07a8f6c8ecde939ec6e531b60923d38dc24.png _images/7c44d41564f42e2566b10d937a1c08245c752a499cdaeba9995dd046f01ebcbd.png _images/fabc9ef32b7e3d2cb561c5ae5003946cf51103f82b9d648a6a755ce69fa259fc.png _images/f50b506f582827c4e0b8b85cc0da8045d22b327eb59ca58ad1eccc89da6e7da2.png _images/70e0a1ea175bc25e4e06d4f228e69b7fb67645b63e2d6cdb8a52c3c2073569c3.png _images/24430fdeb12e813dbec9c956052e49f7817e79c7c9afdfdf82cdac21b975b4ac.png _images/88b7f3e28a5b7ec7eedbe04bfc59e25630151b0e447c8b53b039275b10ee781b.png _images/170fb45076510e6f6dc22c793678c34e0c33732299e0325451b9aa3049fdd1f8.png _images/cfb1fcac592d5609b3c238acf53d2f2b45b11b0125abf287bbdf33dc5a0d7824.png _images/4f29d58f8eaa0dbffbbfa8f48de4d38870cff361710e3bc11a1ba1e96f9a6480.png _images/e8209991e95c9adae165eafcc7fbe522f8b7432f26b072729a7734782fa42ea5.png _images/751a35e2cedc4731a9ebc5af4c8ef617e1a5ef5b5cd406602bd1db3fa15cf38f.png _images/92bcff07d86a6b8c357bad50975841d3077f261a781d3776a65a524fa6d7a1d8.png _images/100d0cd104b590bea4ca278fba829d95cc25aa57317c0dfebac8803f09fd6c84.png _images/c7a43e7dbfbba1f3eb8dc4a43e7f10c0a8b138dd7b43d13cd42287bb888a0e03.png _images/e7f95f75844bc827d3801972fc72d51f8e8b78308d557c377d4261ca7e707d19.png _images/1c4e5ac341c615828b607fb074e119c581168057f1a2cec0bbddfd859f89cded.png _images/701615a91f0f31fba418dfe9622d9e04a35086f6ff1588d0efd78188221aef79.png _images/d363cb8b29cacf3801baa53a60427992e9ad345bc10d06bd44894be4fbb5f7ff.png _images/ff62e49307a921fd13f23fdc495dd3f38556920726d37407f98053ae640f1d90.png _images/fd86f539820fc83c6438b3b434a12785c7173a158fe3e1c994c57aa3a574eeca.png _images/69600e7a87aab642782f833ba61ac4e4d04a93018b818f67ae5269687c5edbb1.png _images/16193b50c38ab6a0099fa6d0b7abd2260ed1e3145410ef591f3e47715d971a05.png _images/4b8084f2ac3f6f50ef6f87974f26f8bbb6de7ae5b00f1c2263b0147a13e86227.png _images/ec8a25bf1dbb39cc51d30dd2b8ba3d99d17cf6773e80bab90cb899c00687ab9a.png _images/5d6d65269db83f6ac0d705a8a7fda91cd8bc7882039e832517e766aa4d5bf1f5.png _images/c02fcd6cd7b0b7777ed54df7505f032fc25535d40c5a5e3dbc584f2a09ccda45.png _images/c0b1b94d1bcf63cb374ddb214aa032a9c665abc9c5aa34ed6c3ecd08f48a59e8.png _images/f27b82ed8efe874fe3c4c738d3c3ba3433a577f78160c24004db5ca07a2f0726.png _images/477d622e6874960f7b9c11913a3804b652d9a5596fe900383384eda3d6fed5b1.png _images/01903fec54d89e8e91c4d8c379266a721ce1763d62751c4d3b150325036b5b22.png _images/3689c4e88bbe5f3c0a3a511b55425278e9fc6ce836a1a114136264894ae720a9.png _images/907570914bb22cde2c61d7c8d9cb148c2a602c863cc4addb617398daa142ac64.png _images/0ab06e24eb8f40e3230d1ad3cea73d2620a21f3360f0993d3925584862002c84.png _images/b072b1110c819e3f70556fea4972affdc4f6f9ca0047d55423cf4716b2ff02b5.png _images/cb60bd03090630f9fa4162eb1b77807f88bcdfea619781bec811cf6e32622b85.png _images/92c275c5a65335e3d8d52974fcd058789694b1e27c387c5f9b1746bf816221f4.png _images/7a823bc08a96369217929d60b4e368956a834f916c7fee66c0346384c0fea81e.png _images/a41c3c53278b08bd4849cab7ea31ea1ce6b7e3aa1d828c6a52f8b182a33213c1.png _images/f81f7f25b17a73be45d2429060dbd5a43fef1626c15b0f93b3b37a3c853adc4e.png _images/48fb95fc8957c8b8b2048eb61d1d003de9ec19634b9d7cb91dce575b04fdeec8.png _images/5755e21d6aff739b7fce611365977c47a68a749fa89e52da99808d8e3416efa7.png _images/04374e3d2cc717f78485801e762d0c860b99361f8aac6910d2dbe5dcfad820fc.png _images/9405cb4ad2ec90d3a4bfd0884b14230d3b7e9769d2c2315fa70ac30f391bedb8.png _images/4d945a33ee81febf528d347623920114633f6823a622b5f9fc56af97e29a634a.png _images/03cf98c3de5db6cfaa6fb37fb0298b0bfd58da3439ce3a3436f337f92dd641a5.png _images/cdd3a01a1f35f73b99ca347cd047da1accd481db4bf19caac5c43c0242ee6baa.png _images/0fbe288efb35a58298939ff7d152810fc174b55e5155ad97d0f52087af66db0d.png _images/f9a5e73369281d91bf6327399d340d641c7a5d7b3ed35e13ea9aae033067e526.png _images/f11672b52b24419c3520531a230e32f0a7932681d737371faf12838adb1def80.png _images/db3a3c5d645d94d8b93bac31b7672b8c08cb0f3d9f8cfdb982f78f1b1482fed3.png _images/8b80cb03a2ff87e467d4b4876eb0276d9b06a99e507c0eea0233c5c5f6082461.png _images/1e29408b75577ea764d777f8b7cdf6ef4e51fe66b599ca81f15342baa92c2ec0.png _images/b26756834644aa4d7d59c470004ddbee22a8db54bc3e23ae56f60763dce42f20.png _images/0df02cd08b58a4af864bd75b5fb54d84c77f204add6ac9d1943a7fe503f8741f.png _images/d3a41e79a023cf7451bbe4be28674a736418a12f9c928f66a1fff755a622a526.png _images/29f272cf4ede519d2ce080aa90b8d52eee3e61b4e89d737bac32e326ff12c367.png _images/7e0dfb831b6af14b42ffc9d8138d0559f7527afc4cf6b4fd2ea9c6708747e0b2.png _images/1e6bf68651b7951f46c6f7812069ad31a07262709ce5a08650e05a327b54fc55.png _images/b570c3128374314cae4b0f2b48f4be1bfee0b0d1940120b6b0b7dc14fa485b02.png _images/9fc17cf915e24668940d5e5686e213f2c3d20e08cadea9e8f470ee8b592a63f3.png _images/254db301152ac8979569f6c531f94bd36244508f8c33f3e63cba1ca2e98fb66b.png _images/7eb8b932ea36375902a9968ecd335d4bed4d8308b9e2920d38beeb2a006bff8e.png _images/e3fab6958f00491e48da3715af24c5c78033d5e294614dd23e5abe4943855be0.png _images/93186fd5b4514648cbdec8b49dd8e7c8ecba5d3853cb36ce94d793247c89b5f3.png _images/61f1767e77572bb0dc84715d167601b1906a2bdfb064693197cbcd4458c75a9b.png _images/25233e4b8ab2c3ebaa7fc10aed73376409acf192e22e669fe806e913cc40ae42.png _images/6fb57d58060948cd11a5be103f9cf98aaf3e0362c8f97fb8e74faae4e5b8ab22.png _images/461e13296787ef4ef87d2393153d26c232724618f1c37f59fcc2b1340944dff7.png

Step 2: Stack the cross correlation#

This combines the time-chunked ASDF files to stack over each time chunk and at each station pair.

# open a new cc store in read-only mode since we will be doing parallel access for stacking
cc_store = ASDFCCStore(cc_data_path, mode="r")
print(cc_store.get_station_pairs())
stack_store = ASDFStackStore(stack_data_path)
config.stations = ["*"] # stacking doesn't support prefixes yet, so allow all stations
stack_cross_correlations(cc_store, stack_store, config)
2025-04-17 02:00:00,692 140136010730368 INFO stack.initializer(): Station pairs: 10
[(CI.ADO, CI.ARV), (CI.ADO, CI.ADO), (CI.ADO, CI.ALP), (CI.ALP, CI.AVM), (CI.ARV, CI.ARV), (CI.ARV, CI.AVM), (CI.ALP, CI.ARV), (CI.ALP, CI.ALP), (CI.AVM, CI.AVM), (CI.ADO, CI.AVM)]
2025-04-17 02:00:04,131 140344971148160 INFO stack.stack_store_pair(): Stacking CI.ADO_CI.ALP/2019-02-01T00:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 02:00:04,138 140598713457536 INFO stack.stack_store_pair(): Stacking CI.ADO_CI.ARV/2019-02-01T00:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 02:00:04,158 140713501756288 INFO stack.stack_store_pair(): Stacking CI.ADO_CI.AVM/2019-02-01T00:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 02:00:04,175 140223277329280 INFO stack.stack_store_pair(): Stacking CI.ADO_CI.ADO/2019-02-01T00:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 02:00:04,197 140344971148160 INFO utils.log_raw(): TIMING:  0.061 secs for loading CCF data
2025-04-17 02:00:04,207 140344971148160 INFO utils.log_raw(): TIMING:  0.009 secs for stack/rotate all station pairs (CI.ADO, CI.ALP)
2025-04-17 02:00:04,209 140598713457536 INFO utils.log_raw(): TIMING:  0.065 secs for loading CCF data
2025-04-17 02:00:04,218 140598713457536 INFO utils.log_raw(): TIMING:  0.010 secs for stack/rotate all station pairs (CI.ADO, CI.ARV)
2025-04-17 02:00:04,227 140713501756288 INFO utils.log_raw(): TIMING:  0.064 secs for loading CCF data
2025-04-17 02:00:04,229 140223277329280 INFO utils.log_raw(): TIMING:  0.048 secs for loading CCF data
2025-04-17 02:00:04,236 140713501756288 INFO utils.log_raw(): TIMING:  0.010 secs for stack/rotate all station pairs (CI.ADO, CI.AVM)
2025-04-17 02:00:04,238 140223277329280 INFO utils.log_raw(): TIMING:  0.009 secs for stack/rotate all station pairs (CI.ADO, CI.ADO)
2025-04-17 02:00:04,262 140223277329280 INFO utils.log_raw(): TIMING:  0.023 secs for writing stack pair (CI.ADO, CI.ADO)
2025-04-17 02:00:04,263 140223277329280 INFO stack.stack_store_pair(): Stacking CI.ALP_CI.ALP/2019-02-01T00:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 02:00:04,280 140344971148160 INFO utils.log_raw(): TIMING:  0.073 secs for writing stack pair (CI.ADO, CI.ALP)
2025-04-17 02:00:04,280 140344971148160 INFO stack.stack_store_pair(): Stacking CI.ALP_CI.ARV/2019-02-01T00:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 02:00:04,288 140598713457536 INFO utils.log_raw(): TIMING:  0.069 secs for writing stack pair (CI.ADO, CI.ARV)
2025-04-17 02:00:04,290 140598713457536 INFO stack.stack_store_pair(): Stacking CI.ALP_CI.AVM/2019-02-01T00:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 02:00:04,305 140713501756288 INFO utils.log_raw(): TIMING:  0.069 secs for writing stack pair (CI.ADO, CI.AVM)
2025-04-17 02:00:04,306 140713501756288 INFO stack.stack_store_pair(): Stacking CI.ARV_CI.ARV/2019-02-01T00:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 02:00:04,319 140223277329280 INFO utils.log_raw(): TIMING:  0.051 secs for loading CCF data
2025-04-17 02:00:04,327 140223277329280 INFO utils.log_raw(): TIMING:  0.008 secs for stack/rotate all station pairs (CI.ALP, CI.ALP)
2025-04-17 02:00:04,346 140344971148160 INFO utils.log_raw(): TIMING:  0.061 secs for loading CCF data
2025-04-17 02:00:04,351 140223277329280 INFO utils.log_raw(): TIMING:  0.024 secs for writing stack pair (CI.ALP, CI.ALP)
2025-04-17 02:00:04,351 140713501756288 INFO utils.log_raw(): TIMING:  0.041 secs for loading CCF data
2025-04-17 02:00:04,351 140223277329280 INFO stack.stack_store_pair(): Stacking CI.ARV_CI.AVM/2019-02-01T00:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 02:00:04,354 140598713457536 INFO utils.log_raw(): TIMING:  0.061 secs for loading CCF data
2025-04-17 02:00:04,356 140344971148160 INFO utils.log_raw(): TIMING:  0.010 secs for stack/rotate all station pairs (CI.ALP, CI.ARV)
2025-04-17 02:00:04,359 140713501756288 INFO utils.log_raw(): TIMING:  0.008 secs for stack/rotate all station pairs (CI.ARV, CI.ARV)
2025-04-17 02:00:04,364 140598713457536 INFO utils.log_raw(): TIMING:  0.010 secs for stack/rotate all station pairs (CI.ALP, CI.AVM)
2025-04-17 02:00:04,382 140713501756288 INFO utils.log_raw(): TIMING:  0.023 secs for writing stack pair (CI.ARV, CI.ARV)
2025-04-17 02:00:04,383 140713501756288 INFO stack.stack_store_pair(): Stacking CI.AVM_CI.AVM/2019-02-01T00:00:00+0000 - 2019-02-02T00:00:00+0000
2025-04-17 02:00:04,419 140223277329280 INFO utils.log_raw(): TIMING:  0.062 secs for loading CCF data
2025-04-17 02:00:04,426 140344971148160 INFO utils.log_raw(): TIMING:  0.070 secs for writing stack pair (CI.ALP, CI.ARV)
2025-04-17 02:00:04,428 140713501756288 INFO utils.log_raw(): TIMING:  0.039 secs for loading CCF data
2025-04-17 02:00:04,430 140223277329280 INFO utils.log_raw(): TIMING:  0.011 secs for stack/rotate all station pairs (CI.ARV, CI.AVM)
2025-04-17 02:00:04,433 140713501756288 INFO utils.log_raw(): TIMING:  0.005 secs for stack/rotate all station pairs (CI.AVM, CI.AVM)
2025-04-17 02:00:04,434 140598713457536 INFO utils.log_raw(): TIMING:  0.070 secs for writing stack pair (CI.ALP, CI.AVM)
2025-04-17 02:00:04,447 140713501756288 INFO utils.log_raw(): TIMING:  0.014 secs for writing stack pair (CI.AVM, CI.AVM)
2025-04-17 02:00:04,474 140223277329280 INFO utils.log_raw(): TIMING:  0.043 secs for writing stack pair (CI.ARV, CI.AVM)
2025-04-17 02:00:05,018 140136010730368 INFO utils.log_raw(): TIMING:  4.330 secs for step 2 in total
pairs = stack_store.get_station_pairs()
print(f"Found {len(pairs)} station pairs")
sta_stacks = stack_store.read_bulk(timerange, pairs) # no timestamp used in ASDFStackStore
Found 10 station pairs
2025-04-17 02:00:05,276 140136010730368 INFO utils.log_raw(): TIMING:  0.250 secs for loading 10 stacks

Plot the stacks

print(os.listdir(cc_data_path))
print(os.listdir(stack_data_path))
['2019_02_01_00_00_00T2019_02_01_12_00_00.h5', '2019_02_01_12_00_00T2019_02_02_00_00_00.h5']
['CI.ALP', 'CI.ARV', 'CI.AVM', 'CI.ADO']
plotting_modules.plot_all_moveout(sta_stacks, 'Allstack_linear', 0.1, 0.2, 'ZZ', 1)
2025-04-17 02:00:05,287 140136010730368 INFO plotting_modules.plot_all_moveout(): Plottting: Allstack_linear, 10 station pairs
200 8001
_images/9208911db553acc936fcd4f7b03acad06e5654a27365dbff6447d6eaebe7cbf4.png