Coverage for kwave/kWaveSimulation_helper/retract_transducer_grid_size.py: 27%

1 from kwave import NotATransducer

2 import numpy as np

3

4

5 def retract_transducer_grid_size(source, sensor, retract_size, pml_inside: bool):

6 # resize the transducer object if the grid has been expanded

7 is_source_kwave_transducer = isinstance(source, NotATransducer)

8 is_sensor_kwave_transducer = isinstance(sensor, NotATransducer)

9 retract_size = np.array(retract_size)

10

11 if not pml_inside and (is_source_kwave_transducer or is_sensor_kwave_transducer):

12

13 # check if the sensor is a transducer

14 if is_sensor_kwave_transducer:

15 # retract the transducer mask

16 sensor.retract_grid(retract_size)

17

18 # check if the source is a transducer, and if so, and different

19 # transducer to the sensor

20 if is_source_kwave_transducer and not (is_sensor_kwave_transducer and sensor == source):

21

22 # retract the transducer mask

23 source.retract_grid(retract_size)