def _spatFT(ir, order_max, kind):
    return spatFT(
        FFT(ir.signal.signal, fs=ir.signal.fs, calculate_freqs=False),
        position_grid=ir.grid,
        order_max=order_max,
        kind=kind,
    )
Пример #2
0
Nrf = Nsft  # Radial filter order
Nviz = Nsft  # Visualization order
krIDX = [15, 23, 29, 39]  # kr-bin for subfigures

quadrature_grid, _ = gen.lebedev(110)

fftData, kr = gen.sampledWave(r=r,
                              gridData=quadrature_grid,
                              ac=ac,
                              FS=FS,
                              NFFT=NFFT,
                              AZ=AZ,
                              EL=EL)

# Spatial Fourier Transform
Pnm = process.spatFT(Nsft, fftData, quadrature_grid)

# Make radial filters
dn, _ = gen.radFilter(Nrf, kr, ac)

# Generate data to visualize
mtxDataLOW = plot.makeMTX(Pnm, dn, krIDX[0], Nviz=Nviz)
mtxDataMID = plot.makeMTX(Pnm, dn, krIDX[1], Nviz=Nviz)
mtxDataHIGH = plot.makeMTX(Pnm, dn, krIDX[2], Nviz=Nviz)
mtxDataVHIGH = plot.makeMTX(Pnm, dn, krIDX[3], Nviz=Nviz)

vizMtx = [
    np.abs(mtxDataLOW),
    np.abs(mtxDataMID),
    np.abs(mtxDataHIGH),
    np.abs(mtxDataVHIGH)
# SFA example 4: Level/Space Resolution
import sys
sys.path.insert(0, '../')
from sound_field_analysis import io, gen, process, plot

matFile = 'data/SOFiA_A2_struct.mat'
Nsft = 5        # Spatial Fourier Transform Order
Nrf = Nsft      # Radial Filter Order
amp_maxdB = 10  # Maximum modal amplification [dB]
ac = 2          # Array configuration: Rigid sphere
Nmtx = Nsft     # Plot Order
krIndex = 128   # kr-bin (frequency) to plot

# Read in .mat struct
timeData = io.readMiroStruct(matFile)

# Transform time domain data to frequency domain and generate kr-vector
fftData, kr, f, _ = process.FFT(timeData)

# Spatial Fourier transform
Pnm = process.spatFT(Nsft, fftData, timeData.quadratureGrid)

# Radial filters
dn, _ = gen.radFilter(Nrf, kr, ac, amp_maxdB=amp_maxdB)

# Plot
vizMTX = plot.makeMTX(Pnm, dn, Nviz=Nmtx, krIndex=krIndex)
fig = plot.plot3D(vizMTX, style='shape', colorize=False)

print("3D visualization opened in browser window, exiting.")
Пример #4
0
# ## Time > Frequency > Spatial domain
# The impulse responses are now read into `array_data.signal`. To bring the time-domain signals to the spatial fourier domain, first the normal Fourier transform (`process.FFT`) has to be applied.
#
# ## Spatial domain & radial filters
# Now the data is ready for the spatial fourier transform (`process.spatFT`); the resulting coefficients hold `order^2 - 1` rows. The radial filters are also calculated, based on the array configuration, the sampling frequency and the number of FFT bins (NFFT) used.
#
# Both the spatial transform and then radial filters are also order-limited to the same order.

# In[ ]:

fftData, f = process.FFT(array_data.signal)
NFFT = fftData.shape[1] * 2 - 1

order = 5
spatial_coefficients = process.spatFT(fftData,
                                      array_data.grid,
                                      order_max=order)
radial_filter = gen.radial_filter_fullspec(
    order,
    NFFT=NFFT,
    fs=array_data.signal.fs,
    array_configuration=array_data.configuration)

# ## Plot
# To visualized the recorded data, the spherical fourier coefficients and the radial filters are passed to plot.makeMTX() along with a specific kr bin. The function returns the sound pressure at a resolution of 1 degree, which then can be visualized using plot.plot3D(). Several styles ('shape', 'sphere', 'flat') exist.
#
# To plot a specific frequency, we use utils.nearest_to_value_IDX() find the index closest to the desired frequency.

# In[ ]:

vizMTX1 = plot.makeMTX(spatial_coefficients,