Skip to content

Commit 458c8f5

Browse files
committed
Update of MIRO struct loading to make quadrature weights optional
(also update of adjacent code formatting)
1 parent 9ae1c83 commit 458c8f5

File tree

1 file changed

+25
-19
lines changed
  • sound_field_analysis

1 file changed

+25
-19
lines changed

sound_field_analysis/io.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -181,37 +181,39 @@ def __repr__(self):
181181
return utils.get_named_tuple__repr__(self)
182182

183183

184-
def read_miro_struct(file_name, channel='irChOne', transducer_type='omni', scatter_radius=None,
185-
get_center_signal=False):
184+
def read_miro_struct(file_name, channel='irChOne', transducer_type='omni',
185+
scatter_radius=None, get_center_signal=False):
186186
"""Reads miro matlab files.
187187
188188
Parameters
189189
----------
190190
file_name : filepath
191-
Path to file that has been exported as a struct
191+
Path to file that has been exported as a struct
192192
channel : string, optional
193-
Channel that holds required signals. [Default: 'irChOne']
193+
Channel that holds required signals. [Default: 'irChOne']
194194
transducer_type : {omni, cardioid}, optional
195-
Sets the type of transducer used in the recording. [Default: 'omni']
195+
Sets the type of transducer used in the recording. [Default: 'omni']
196196
scatter_radius : float, option
197-
Radius of the scatterer. [Default: None]
197+
Radius of the scatterer. [Default: None]
198198
get_center_signal : bool, optional
199199
If center signal should be loaded. [Default: False]
200200
201201
Returns
202202
-------
203203
array_signal : ArraySignal
204-
Tuple containing a TimeSignal `signal`, SphericalGrid `grid`, TimeSignal 'center_signal',
205-
ArrayConfiguration `configuration` and the air temperature
204+
Tuple containing a TimeSignal `signal`, SphericalGrid `grid`,
205+
TimeSignal 'center_signal', ArrayConfiguration `configuration` and
206+
the air temperature
206207
207208
Notes
208209
-----
209-
This function expects a slightly modified miro file in that it expects a field `colatitude` instead of
210-
`elevation`. This is for avoiding confusion as may miro file contain colatitude data in the elevation field.
211-
212-
To import center signal measurements the matlab method miro_to_struct has to be extended. Center measurements are
213-
included in every measurement provided at http://audiogroup.web.th-koeln.de/.
210+
This function expects a slightly modified miro file in that it expects a
211+
field `colatitude` instead of `elevation`. This is for avoiding confusion as
212+
may miro file contain colatitude data in the elevation field.
214213
214+
To import center signal measurements the matlab method miro_to_struct has to
215+
be extended. Center measurements are included in every measurement
216+
provided at http://audiogroup.web.th-koeln.de/.
215217
"""
216218
current_data = sio.loadmat(file_name)
217219

@@ -224,25 +226,29 @@ def read_miro_struct(file_name, channel='irChOne', transducer_type='omni', scatt
224226
center_signal = TimeSignal(signal=_np.squeeze(current_data['irCenter']).T,
225227
fs=_np.squeeze(current_data['fs']))
226228
except KeyError:
227-
print('WARNING: Center signal not included in miro struct, use extended miro_to_struct.m!', file=sys.stderr)
229+
print('WARNING: Center signal not included in miro struct, use '
230+
'extended miro_to_struct.m!', file=sys.stderr)
228231
center_signal = None
229232

230233
mic_grid = SphericalGrid(azimuth=_np.squeeze(current_data['azimuth']),
231234
colatitude=_np.squeeze(current_data['colatitude']),
232235
radius=_np.squeeze(current_data['radius']),
233-
weight=_np.squeeze(current_data['quadWeight']))
236+
weight=_np.squeeze(current_data['quadWeight'])
237+
if 'quadWeight' in current_data else None)
234238

235239
if (mic_grid.colatitude < 0).any():
236-
print('WARNING: The "colatitude" data contains negative values, which is an indication that it is actually '
237-
'elevation', file=sys.stderr)
240+
print('WARNING: The "colatitude" data contains negative values, which '
241+
'is an indication that it is actually elevation', file=sys.stderr)
238242

239243
if _np.squeeze(current_data['scatterer']):
240244
sphere_config = 'rigid'
241245
else:
242246
sphere_config = 'open'
243-
array_config = ArrayConfiguration(mic_grid.radius, sphere_config, transducer_type, scatter_radius)
247+
array_config = ArrayConfiguration(mic_grid.radius, sphere_config,
248+
transducer_type, scatter_radius)
244249

245-
return ArraySignal(time_signal, mic_grid, center_signal, array_config, _np.squeeze(current_data['avgAirTemp']))
250+
return ArraySignal(time_signal, mic_grid, center_signal, array_config,
251+
_np.squeeze(current_data['avgAirTemp']))
246252

247253

248254
# noinspection PyPep8Naming

0 commit comments

Comments
 (0)