Skip to content

Commit

Permalink
Adding Support for Windows Executables
Browse files Browse the repository at this point in the history
* Added support for parallel processing through a .exe file on windows
* Swapped out joblib/multiprocessing for 'multiprocess' module in Pathos package
  • Loading branch information
geojunky committed Nov 5, 2024
1 parent ad4daee commit a922e70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion seismic/ASDFdatabase/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def __init__(self, mseed_folder, pattern):
# if (i > 0): break
# end for

print('\nCreating metadata index for {} mseed files..'.format(len(self.meta_list)))
print('\nCreating metadata index for a total of {} traces found..'.format(len(self.meta_list)))

for row in tqdm(self.meta_list):
idx, nc, sc, lc, cc, st, et = row
Expand Down
18 changes: 11 additions & 7 deletions seismic/ASDFdatabase/waveform_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import matplotlib
from collections import defaultdict
from obspy.core.inventory.response import Response
import matplotlib
from matplotlib import mlab
from obspy.signal.invsim import cosine_taper
from obspy.signal.spectral_estimation import get_nlnm, get_nhnm
Expand All @@ -33,11 +34,14 @@
from seismic.inventory.response import ResponseFactory
from tqdm import tqdm
from matplotlib.colors import LinearSegmentedColormap
from multiprocessing import Manager
from matplotlib.backends.backend_pdf import PdfPages
from joblib import Parallel, delayed
import psutil

from pathos.multiprocessing import ProcessingPool as Pool
from multiprocess import Manager, freeze_support

matplotlib.use('TKAgg')

is_windows = sys.platform.startswith('win')

class ProgressTracker(object):
Expand Down Expand Up @@ -165,11 +169,9 @@ def __init__(self,

# launch parallel computations
if (1):
Parallel(n_jobs=self.nproc) \
(delayed(self._generate_psds)(cst_list, cet_list) \
for cst_list, cet_list in zip(proc_st_list, proc_et_list))
p = Pool(ncpus=self.nproc)
p.map(self._generate_psds, proc_st_list, proc_et_list)
# end if

# end func

def _setup_period_bins(self):
Expand Down Expand Up @@ -225,7 +227,6 @@ def fft_taper(data):
"""
data *= cosine_taper(len(data), 0.2)
return data

# end func

for start_time, end_time in zip(start_time_list, end_time_list):
Expand Down Expand Up @@ -801,5 +802,8 @@ def get_time_range_func(net, sta, loc, cha):
groups.add_command(process_asdf)

if __name__ == "__main__":
# add support for process-based multiprocessing for a Windows .exe
if(is_windows): freeze_support()

groups()
# end func

0 comments on commit a922e70

Please sign in to comment.