Skip to content

Commit

Permalink
Updated order in which the array is read. Should potentially increase…
Browse files Browse the repository at this point in the history
… reading speed for larger wueries
  • Loading branch information
lsawade committed Jul 19, 2023
1 parent f0059a2 commit 22bb742
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/gf3d/bin/gf3d_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ def plot_station_seismogram(subsetfilename, cmtsolutionfilename, network, statio

# CMTSOLUTION
cmt = CMTSOLUTION.read(cmtsolutionfilename)
print(cmt)

# %%
# Loading the subset database
Expand Down
14 changes: 9 additions & 5 deletions src/gf3d/seismograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,8 @@ def get_elements(self, lat, lon, depth, dist_in_km=125.0, NGLL=5, threading: boo
# sort the globs, and after we retreive the array unsort it and
# reshape it
# For later I'll need to test this before I can implement it.
# sglob = np.argsort(self.nglob2sub)
# rsglob = np.argsort(sglob)
sglob = np.argsort(self.nglob2sub)
rsglob = np.argsort(sglob)

# Get new index array of length of the unique values
indeces = np.arange(len(self.nglob2sub))
Expand Down Expand Up @@ -951,9 +951,13 @@ def read_stuff(args):
# Get norm and displacement
norm = db[f'displacement/{comp}/norm'][()]

# Get displacement
self.displacement[_i, _j, :, :, :] = db[f'displacement/{comp}/array'][:, self.nglob2sub, :].astype(
np.float32) * norm / factor
# Get displacement getting the output in ascending order
self.displacement[_i, _j, :, :, :] = \
db[f'displacement/{comp}/array'][:, self.nglob2sub[sglob], :].astype(
np.float32)[:, rsglob, :] * norm / factor

# displacementd[comp] = db[f'displacement/{comp}/array'][
# :, iglob[sglob], :].astype(np.float64)[:, rsglob, :].reshape(3, NGLLX, NGLLY, NGLLZ, NT) * norm_disp / factor

if threading:
with parallel_backend('threading', n_jobs=self.Ndb):
Expand Down

0 comments on commit 22bb742

Please sign in to comment.