Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
geojunky committed Oct 25, 2022
1 parent 601249e commit 27d34e4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions seismic/pick_harvester/parametric_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def __init__(self, csv_catalog, auto_pick_files=[], auto_pick_phases=[],
# load events and arrivals
if(1):
self.events, self.arrivals = self._load_catalog()
if(self.rank == 0):
np.save('events.npy', self.events)
np.save('arrivals.npy', self.arrivals)
#if(self.rank == 0):
# np.save('events.npy', self.events)
# np.save('arrivals.npy', self.arrivals)
# end if
else:
self.events = np.load('events.npy')
Expand Down
8 changes: 1 addition & 7 deletions seismic/xcorqc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,7 @@ def increment(self):
# end func
# end class

class SpooledXcorrResults:
"""
Spooled storage for cross-correlations. Stacked cross-correlations computed were previously
gathered in memory, before being written to netCDF4 files at the end. Because we now need to
output all cross-correlations, unstacked, the memory requirements have jumped by a factor of
~26. We now write the CCs to a spooled storage as they are being computed.
"""
class SpooledMatrix:
def __init__(self, ncols, dtype=np.float32, max_size_mb=2048, prefix='', dir=None):
self._prefix = prefix
self._ncols = ncols
Expand Down
10 changes: 8 additions & 2 deletions seismic/xcorqc/xcorqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from seismic.xcorqc.utils import get_stream, fill_gaps
from netCDF4 import Dataset
from functools import reduce
from seismic.xcorqc.utils import SpooledXcorrResults
from seismic.xcorqc.utils import SpooledMatrix
logging.basicConfig()


Expand Down Expand Up @@ -707,7 +707,13 @@ def IntervalStackXCorr(refds, tempds,
# end if

if(spooledXcorr is None):
spooledXcorr = SpooledXcorrResults(xcl.shape[1], dtype=xcl.dtype, max_size_mb=2048, prefix=stationPair, dir=scratch_folder)
"""
Spooled storage for cross-correlations. Stacked cross-correlations computed were previously
gathered in memory, before being written to netCDF4 files at the end. Because we now need to
output all cross-correlations, unstacked, the memory requirements have jumped by a factor of
~26. We now write the CCs to a spooled storage as they are being computed.
"""
spooledXcorr = SpooledMatrix(xcl.shape[1], dtype=xcl.dtype, max_size_mb=2048, prefix=stationPair, dir=scratch_folder)
# end if

# write xcorr results to spooled buffer
Expand Down

0 comments on commit 27d34e4

Please sign in to comment.