-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make MPI an optional dependency (#147)
* Make MPI an optional dependency * Fix list->List * missed one * Add MPI test * Update tests, README and CLI tutorial * Remove duplicate line Co-authored-by: Aniket Fadia <[email protected]> * fix spacing * Support using MPI for CC (#148) * Support using MPI for CC * Fix download retry --------- Co-authored-by: Aniket Fadia <[email protected]>
- Loading branch information
1 parent
e0c94a0
commit ee84cef
Showing
11 changed files
with
229 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,18 +4,30 @@ inputs: | |
python-version: | ||
required: true | ||
description: Python version to install | ||
mpi: | ||
required: false | ||
description: Whether to install with MPI or not | ||
default: 'false' | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: ${{inputs.python-version}} | ||
- name: Setup MPI | ||
uses: mpi4py/setup-mpi@v1 | ||
- name: Install project | ||
- name: Setup pip | ||
shell: sh | ||
run: | | ||
python3 -m ensurepip | ||
pip3 install --upgrade pip | ||
pip install ".[dev]" | ||
- name: Setup MPI | ||
if: ${{ inputs.mpi == 'true' }} | ||
uses: mpi4py/setup-mpi@v1 | ||
- name: Install project no MPI | ||
if: ${{ inputs.mpi == 'false' }} | ||
shell: sh | ||
run: pip install ".[dev]" | ||
- name: Install project MPI | ||
if: ${{ inputs.mpi == 'true' }} | ||
shell: sh | ||
run: pip install ".[dev,mpi]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ jobs: | |
python-version: ${{env.python_version}} | ||
- name: Test Download (S0) | ||
working-directory: ./src | ||
run: noisepy download --start_date 2019-02-01T00:00:00 --end_date 2019-02-01T01:00:00 --stations ARV,BAK --inc_hours 1 --raw_data_path $RUNNER_TEMP/RAW_DATA | ||
run: noisepy download --start_date 2019-02-01T00:00:00 --end_date 2019-02-01T02:00:00 --stations ARV,BAK --inc_hours 1 --raw_data_path $RUNNER_TEMP/RAW_DATA | ||
- name: Cache data | ||
uses: actions/cache/save@v3 | ||
with: | ||
|
@@ -70,6 +70,40 @@ jobs: | |
working-directory: ./src | ||
run: | | ||
noisepy stack --raw_data_path $RUNNER_TEMP/RAW_DATA --ccf_path $RUNNER_TEMP/CCF --stack_path $RUNNER_TEMP/STACK --stack_method ${{matrix.method}} | ||
s1_s2_mpi: | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
python_version: ['3.10'] | ||
method: [linear] | ||
freq_norm: [rma] | ||
runs-on: ubuntu-22.04 | ||
needs: s0_download | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/[email protected] | ||
- name: Setup NoisePy | ||
uses: ./.github/actions/setup | ||
with: | ||
python-version: ${{matrix.python_version}} | ||
mpi: 'true' | ||
- name: Cache data | ||
id: cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
key: download_data-${{ github.sha }} | ||
path: ${{runner.temp}} | ||
- name: Check cache hit | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: exit 1 | ||
- name: Test Cross-Correlation (S1) | ||
working-directory: ./src | ||
run: | | ||
mpiexec -n 2 noisepy cross_correlate --mpi --raw_data_path $RUNNER_TEMP/RAW_DATA --ccf_path $RUNNER_TEMP/CCF --freq_norm ${{matrix.freq_norm}} | ||
- name: Test Stacking (S2) | ||
working-directory: ./src | ||
run: | | ||
mpiexec -n 3 noisepy stack --mpi --raw_data_path $RUNNER_TEMP/RAW_DATA --ccf_path $RUNNER_TEMP/CCF --stack_path $RUNNER_TEMP/STACK --stack_method ${{matrix.method}} | ||
s3_dates: | ||
strategy: | ||
fail-fast: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,9 @@ | |
from datetimerange import DateTimeRange | ||
from scipy.fftpack.helper import next_fast_len | ||
|
||
from noisepy.seis.datatypes import Channel, ChannelData, ConfigParameters, NoiseFFT | ||
|
||
from . import noise_module | ||
from .datatypes import Channel, ChannelData, ConfigParameters, NoiseFFT | ||
from .scheduler import Scheduler, SingleNodeScheduler | ||
from .stores import CrossCorrelationDataStore, RawDataStore | ||
from .utils import TimeLogger, error_if | ||
|
||
|
@@ -35,19 +35,13 @@ | |
Marine Denolle ([email protected]) | ||
NOTE: | ||
0. MOST occasions you just need to change parameters followed with detailed | ||
explanations to run the script. | ||
1. To read SAC/mseed files, we assume the users have sorted the data | ||
by the time chunk they prefer (e.g., 1day) | ||
and store them in folders named after the time chunk (e.g, 2010_10_1). | ||
modify L135 to find your local data; | ||
2. A script of S0B_to_ASDF.py is provided to help clean messy SAC/MSEED data and | ||
1. A script of S0B_to_ASDF.py is provided to help clean messy SAC/MSEED data and | ||
convert them into ASDF format. | ||
the script takes minor time compared to that for cross-correlation. | ||
so we recommend to use S0B script for | ||
better NoisePy performance. the downside is that it duplicates the | ||
continuous noise data on your machine; | ||
3. When "coherency" is preferred, please set "freq_norm" to "rma" and "time_norm" to "no" | ||
2. When "coherency" is preferred, please set "freq_norm" to "rma" and "time_norm" to "no" | ||
for better performance. | ||
""" | ||
|
||
|
@@ -56,28 +50,32 @@ def cross_correlate( | |
raw_store: RawDataStore, | ||
fft_params: ConfigParameters, | ||
cc_store: CrossCorrelationDataStore, | ||
scheduler: Scheduler = SingleNodeScheduler(), | ||
): | ||
""" | ||
Perform the cross-correlation analysis | ||
Parameters: | ||
raw_store: Store to load data from | ||
fft_params: Parameters for the FFT calculations | ||
cc_store: Store for saving cross correlations | ||
Args: | ||
raw_store: Store to load data from | ||
fft_params: Parameters for the FFT calculations | ||
cc_store: Store for saving cross correlations | ||
""" | ||
|
||
executor = ThreadPoolExecutor() | ||
tlog = TimeLogger(logger, logging.INFO) | ||
t_s1_total = tlog.reset() | ||
|
||
# set variables to broadcast | ||
timespans = raw_store.get_timespans() | ||
splits = len(timespans) | ||
if splits == 0: | ||
raise IOError("Abort! no available seismic files for FFT") | ||
def init() -> List: | ||
# set variables to broadcast | ||
timespans = raw_store.get_timespans() | ||
if len(timespans) == 0: | ||
raise IOError("Abort! no available seismic files for FFT") | ||
return [timespans] | ||
|
||
[timespans] = scheduler.initialize(init, 1) | ||
|
||
for ts in timespans: | ||
for its in scheduler.get_indices(timespans): | ||
ts = timespans[its] | ||
if cc_store.is_done(ts): | ||
continue | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.