-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_receiver_placement.py
53 lines (36 loc) · 1.57 KB
/
test_receiver_placement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import fix_dead_command_line
import matplotlib.pyplot as plt
import torch
from current_simulation_description import make_simulation_description
from dataset3d import WaveDataset3d, k_sensor_recordings
from signals_and_geometry import time_of_flight_crop
def main():
# Questions:
# - why does grid_sample appear to be normalizing the input grid to [0, num_samples] or similar rather than [-1, 1]???
# - Are the simulation grid indices correct? Try running a dense simulation and visualizing it. Because of the oblong shape, something will probably be out of bounds if it's wrong
desc = make_simulation_description()
dataset = WaveDataset3d(desc, "dataset_v3.h5")
example = dataset[3]
recordings = example[k_sensor_recordings]
crop_size = 128
for i in range(desc.sensor_count):
x, y, z = desc.sensor_locations[i]
audio_cropped = (
time_of_flight_crop(
recordings=recordings[[i]].unsqueeze(0),
sample_locations=torch.Tensor([[[x, y, z]]]),
emitter_location=torch.Tensor(desc.emitter_location),
receiver_locations=torch.Tensor(desc.sensor_locations[[i]]),
speed_of_sound=desc.air_properties.speed_of_sound,
sampling_frequency=desc.output_sampling_frequency,
crop_length_samples=crop_size,
)
.squeeze(0)
.squeeze(0)
.squeeze(0)
)
audio_cropped += 0.01 * i
plt.plot(audio_cropped.cpu().numpy())
plt.show()
if __name__ == "__main__":
main()