Skip to content

Commit 8f5b9d3

Browse files
committed
fix
1 parent 523b458 commit 8f5b9d3

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

logic.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ def get_csdm(spectra:np.ndarray) -> np.ndarray:
3939
"""
4040

4141
# einstein convention version
42-
csdm = np.einsum('ik,jk->ijk', source_spectra, np.conj(source_spectra))
42+
csdm = np.einsum('ik,jk->ijk', spectra, np.conj(spectra))
4343

4444
# # old slow version
45-
# csdm = np.zeros((n_stations, n_stations, len(freqs[freqs_of_interest])), dtype=np.complex)
45+
# csdm = np.zeros((n_stations, n_stations, len(freqs[freqs_of_interest_idx])), dtype=np.complex)
4646
# for i, spec1 in enumerate(source_spectra):
4747
# for j, spec2 in enumerate(source_spectra):
4848
# csdm[i, j] = spec1 * np.conj(spec2)
@@ -83,7 +83,7 @@ def bartlett_processor(csdm, gf_spectra):
8383

8484
return beampower
8585

86-
def get_beampowers(csdm, gf_spectra, gp_dists):
86+
def get_beampowers(csdm, gf_spectra, gp_dists, relevant_dists):
8787
"""
8888
Computes the Beampower for all grid-points.
8989
"""
@@ -113,7 +113,7 @@ def get_beampowers(csdm, gf_spectra, gp_dists):
113113
voxel_confidence = .99
114114

115115
# geometry / structure
116-
# TODO: determine lower bounds for grid geometry
116+
# TODO: determine lower bounds for grid geometry that can be resolved
117117
grid_limits_x = (-2, 2)
118118
grid_limits_y = (-2, 2)
119119
grid_limits_z = (0, 4)
@@ -123,8 +123,7 @@ def get_beampowers(csdm, gf_spectra, gp_dists):
123123
vel = .1
124124

125125
# decimals to round distances to
126-
# TODO: Dynamically determine maximum reasonable accuracy
127-
# should probably be dependent on spatial nyquist?
126+
# TODO: Dynamically determine maximum reasonable accuracy, similar to above
128127
decimal_round = 2
129128

130129
# data
@@ -134,6 +133,7 @@ def get_beampowers(csdm, gf_spectra, gp_dists):
134133

135134
# synth example
136135
n_stations = 30
136+
# place source somewhere in study region and below depth = 2
137137
synth_source_x = np.random.uniform(low=grid_limits_x[0], high=grid_limits_x[1])
138138
synth_source_y = np.random.uniform(low=grid_limits_y[0], high=grid_limits_y[1])
139139
synth_source_z = np.random.uniform(low=2, high=grid_limits_z[1])
@@ -148,11 +148,11 @@ def get_beampowers(csdm, gf_spectra, gp_dists):
148148
# compute fft frequencies
149149
from scipy.fftpack import fftfreq
150150
freqs = fftfreq(n_samples, sampling_rate)
151-
freqs_of_interest = (freqs >= fmin) & (freqs <= fmax)
151+
freqs_of_interest_idx = (freqs >= fmin) & (freqs <= fmax)
152152

153153
# compute synthetic spectra
154154
dists_to_src = get_distances(list_of_locs=station_locations, point=synth_source)
155-
source_spectra = np.array([get_gf_spectrum(freqs, dist, vel)[freqs_of_interest] for dist in dists_to_src])
155+
source_spectra = np.array([get_gf_spectrum(freqs, dist, vel)[freqs_of_interest_idx] for dist in dists_to_src])
156156

157157
grid_points, grid_x_coords, grid_y_coords, grid_z_coords = generate_grid(
158158
grid_limits=(grid_limits_x, grid_limits_y, grid_limits_z),
@@ -173,21 +173,22 @@ def get_beampowers(csdm, gf_spectra, gp_dists):
173173
# extract relevant distances only
174174
relevant_dists = np.unique(gp_dists)
175175

176-
# compute Green's Functions (spectra)
176+
# compute Green's Functions spectra
177177
gf_spectra = get_gf_spectra_for_dists(
178178
freqs=freqs,
179179
vel=vel,
180180
dists=relevant_dists
181181
)
182182

183183
# limit Green's Functions spectra to frequencies of interest
184-
gf_spectra = gf_spectra[:, freqs_of_interest]
184+
gf_spectra = gf_spectra[:, freqs_of_interest_idx]
185185

186186
# compute beampowers
187187
beampowers = get_beampowers(
188188
csdm=csdm,
189189
gf_spectra=gf_spectra,
190-
gp_dists=gp_dists
190+
gp_dists=gp_dists,
191+
relevant_dists=relevant_dists
191192
)
192193

193194
# np.argmax(beampowers)

0 commit comments

Comments
 (0)