%%{init: { 'logLevel': 'debug', 'theme': 'base' } }%% graph LR waveform[Get Data] --> correlate(Correlation) correlate:::active -->|save| corrdb[(CorrDB/hdf5)] corrdb --> monitor monitor[Measure dv] -->|save| dv{{DV}} click waveform "../trace_data.html" "trace_data" click correlate "../correlate.html" "correlate" click monitor "../monitor.html" "monitor" click corrdb "../corrdb.html" "CorrDB" click dv "../monitor/dv.html" "DV" classDef active fill:#f666, stroke-width:4px, stroke:#f06;
The Correlator Object#
The Object governing the actual computation is Correlator
.
It takes only two input arguments and the most important is the dictionary / yml file that we created in the preceding step.
The second input argument is the Store_Client
we used to download our data.
As Computing Ambient Noise Correlations is computationally very expensive, SeisMIC can be used in conjuction with MPI (e.g., openMPI) to enable processing with several cores or on HPCs.
A script to start your correlation could look like this:
1from time import time
2import os
3# This tells numpy to only use one thread
4# As we use MPI this is necessary to avoid overascribing threads
5os.environ['OPENBLAS_NUM_THREADS'] = '1'
6
7from obspy.clients.fdsn import Client
8
9from seismic.correlate.correlate import Correlator
10from seismic.trace_data.waveform import Store_Client
11
12# Path to the paramter file we created in the step before
13params = '/path/to/my/params.yaml'
14# You don't have to set this (could be None)
15client = Client('MYFDSN')
16client.set_eida_token('/I/want/embargoed/data.txt)
17# root is the same as proj_dir in params.yaml
18root = '/path/to/project/'
19sc = Store_Client(client, root)
20
21c = Correlator(sc, options=params)
22print('Correlator initiated')
23x = time()
24st = c.pxcorr()
25print('Correlation finished after', time()-x, 'seconds')
This script can be iniated in bash using:
mpirun -n $number_cores python mycorrelation.py
where $number_cores
is the number of cores you want to initialise. The only method of Correlator
that you will want to use is pxcorr()
, which does not require any (additional) input.
Note
On some MPI versions, the parameters are named differently. For example (-n could correspond to -c). When in doubt, refer to the help or man page of your mpirun mpiexec command.