Skip to content

Commit

Permalink
Merge pull request #400 from GEMScienceTools/fermi_testing
Browse files Browse the repository at this point in the history
Merging major Fermi updates
  • Loading branch information
cossatot authored Mar 6, 2024
2 parents 0899d26 + deb8fb1 commit 9c82d2e
Show file tree
Hide file tree
Showing 22 changed files with 4,489 additions and 2,615 deletions.
15 changes: 9 additions & 6 deletions openquake/aft/rupture_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def get_close_source_pairs(


@njit(fastmath=True, parallel=True)
def calc_pairwise_distances(vec_1: np.ndarray, vec_2: np.ndarray) -> np.ndarray:
def calc_pairwise_distances(
vec_1: np.ndarray, vec_2: np.ndarray
) -> np.ndarray:
"""
Calculates the pairwise Cartesian distance between two 3D vectors. Runs in
parallel over `vec_1`.
Expand Down Expand Up @@ -258,7 +260,8 @@ def split_rows(
split_starts = [split[0] for split in splits]

closest_first_inds = [
np.argmin(np.abs(row_ids - split_start)) for split_start in split_starts
np.argmin(np.abs(row_ids - split_start))
for split_start in split_starts
]

closest_first_inds = np.unique(closest_first_inds)
Expand All @@ -276,7 +279,7 @@ def split_rows(
block_idx = row_ids[start:stop]

this["array_stack"] = stacked_array[
row_ids[start]: row_ids[stop], :
row_ids[start] : row_ids[stop], :
]

this["row_idxs"] = block_idx - block_idx[0]
Expand All @@ -285,7 +288,7 @@ def split_rows(
start = closest_first_inds[i]
block_idx = row_ids[start:]

this["array_stack"] = stacked_array[row_ids[start]:, :]
this["array_stack"] = stacked_array[row_ids[start] :, :]
this["row_idxs"] = block_idx - block_idx[0]

return data_splits
Expand Down Expand Up @@ -376,7 +379,7 @@ def check_dists_by_mag(
return dist <= dist_constant * 10.0 ** (-2.943 + 0.681 * mag)


@jit
@jit(nopython=False)
def filter_dists_by_mag(
min_rup_dists: RupDistType,
mags: Sequence[float],
Expand Down Expand Up @@ -421,7 +424,7 @@ def filter_dists_by_mag(
]


@jit
@jit(nopython=False)
def filter_dists_by_dist(
min_rup_dists: RupDistType,
dist_threshold=4.0,
Expand Down
Loading

0 comments on commit 9c82d2e

Please sign in to comment.