acoular 23.11__py3-none-any.whl → 24.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. acoular/__init__.py +118 -50
  2. acoular/calib.py +29 -38
  3. acoular/configuration.py +116 -73
  4. acoular/demo/__init__.py +10 -4
  5. acoular/demo/acoular_demo.py +78 -53
  6. acoular/environments.py +265 -262
  7. acoular/fastFuncs.py +361 -191
  8. acoular/fbeamform.py +1478 -1407
  9. acoular/grids.py +501 -545
  10. acoular/h5cache.py +50 -59
  11. acoular/h5files.py +154 -137
  12. acoular/internal.py +10 -11
  13. acoular/microphones.py +57 -53
  14. acoular/sdinput.py +47 -52
  15. acoular/signals.py +167 -179
  16. acoular/sources.py +818 -693
  17. acoular/spectra.py +349 -359
  18. acoular/tbeamform.py +414 -413
  19. acoular/tfastfuncs.py +178 -101
  20. acoular/tools/__init__.py +25 -0
  21. acoular/tools/aiaa.py +186 -0
  22. acoular/tools/helpers.py +189 -0
  23. acoular/tools/metrics.py +165 -0
  24. acoular/tprocess.py +1201 -1143
  25. acoular/traitsviews.py +513 -501
  26. acoular/trajectory.py +50 -52
  27. acoular/version.py +5 -6
  28. acoular/xml/minidsp_uma-16.xml +20 -0
  29. acoular/xml/{minidsp_uma16.xml → minidsp_uma-16_mirrored.xml} +3 -0
  30. {acoular-23.11.dist-info → acoular-24.5.dist-info}/METADATA +47 -40
  31. acoular-24.5.dist-info/RECORD +50 -0
  32. {acoular-23.11.dist-info → acoular-24.5.dist-info}/WHEEL +1 -1
  33. acoular-24.5.dist-info/licenses/LICENSE +28 -0
  34. acoular/fileimport.py +0 -380
  35. acoular/nidaqimport.py +0 -273
  36. acoular/tests/reference_data/BeamformerBase.npy +0 -0
  37. acoular/tests/reference_data/BeamformerBaseFalse1.npy +0 -0
  38. acoular/tests/reference_data/BeamformerBaseFalse2.npy +0 -0
  39. acoular/tests/reference_data/BeamformerBaseFalse3.npy +0 -0
  40. acoular/tests/reference_data/BeamformerBaseFalse4.npy +0 -0
  41. acoular/tests/reference_data/BeamformerBaseTrue1.npy +0 -0
  42. acoular/tests/reference_data/BeamformerBaseTrue2.npy +0 -0
  43. acoular/tests/reference_data/BeamformerBaseTrue3.npy +0 -0
  44. acoular/tests/reference_data/BeamformerBaseTrue4.npy +0 -0
  45. acoular/tests/reference_data/BeamformerCMF.npy +0 -0
  46. acoular/tests/reference_data/BeamformerCapon.npy +0 -0
  47. acoular/tests/reference_data/BeamformerClean.npy +0 -0
  48. acoular/tests/reference_data/BeamformerCleansc.npy +0 -0
  49. acoular/tests/reference_data/BeamformerCleant.npy +0 -0
  50. acoular/tests/reference_data/BeamformerCleantSq.npy +0 -0
  51. acoular/tests/reference_data/BeamformerCleantSqTraj.npy +0 -0
  52. acoular/tests/reference_data/BeamformerCleantTraj.npy +0 -0
  53. acoular/tests/reference_data/BeamformerDamas.npy +0 -0
  54. acoular/tests/reference_data/BeamformerDamasPlus.npy +0 -0
  55. acoular/tests/reference_data/BeamformerEig.npy +0 -0
  56. acoular/tests/reference_data/BeamformerEigFalse1.npy +0 -0
  57. acoular/tests/reference_data/BeamformerEigFalse2.npy +0 -0
  58. acoular/tests/reference_data/BeamformerEigFalse3.npy +0 -0
  59. acoular/tests/reference_data/BeamformerEigFalse4.npy +0 -0
  60. acoular/tests/reference_data/BeamformerEigTrue1.npy +0 -0
  61. acoular/tests/reference_data/BeamformerEigTrue2.npy +0 -0
  62. acoular/tests/reference_data/BeamformerEigTrue3.npy +0 -0
  63. acoular/tests/reference_data/BeamformerEigTrue4.npy +0 -0
  64. acoular/tests/reference_data/BeamformerFunctional.npy +0 -0
  65. acoular/tests/reference_data/BeamformerGIB.npy +0 -0
  66. acoular/tests/reference_data/BeamformerGridlessOrth.npy +0 -0
  67. acoular/tests/reference_data/BeamformerMusic.npy +0 -0
  68. acoular/tests/reference_data/BeamformerOrth.npy +0 -0
  69. acoular/tests/reference_data/BeamformerTime.npy +0 -0
  70. acoular/tests/reference_data/BeamformerTimeSq.npy +0 -0
  71. acoular/tests/reference_data/BeamformerTimeSqTraj.npy +0 -0
  72. acoular/tests/reference_data/BeamformerTimeTraj.npy +0 -0
  73. acoular/tests/reference_data/Environment.npy +0 -0
  74. acoular/tests/reference_data/Example1_numerical_values_testsum.h5 +0 -0
  75. acoular/tests/reference_data/FiltFiltOctave__.npy +0 -0
  76. acoular/tests/reference_data/FiltFiltOctave_band_100_0_fraction_Thirdoctave_.npy +0 -0
  77. acoular/tests/reference_data/FiltFreqWeight_weight_A_.npy +0 -0
  78. acoular/tests/reference_data/FiltFreqWeight_weight_C_.npy +0 -0
  79. acoular/tests/reference_data/FiltFreqWeight_weight_Z_.npy +0 -0
  80. acoular/tests/reference_data/FiltOctave__.npy +0 -0
  81. acoular/tests/reference_data/FiltOctave_band_100_0_fraction_Thirdoctave_.npy +0 -0
  82. acoular/tests/reference_data/Filter__.npy +0 -0
  83. acoular/tests/reference_data/GeneralFlowEnvironment.npy +0 -0
  84. acoular/tests/reference_data/OctaveFilterBank__.npy +0 -0
  85. acoular/tests/reference_data/OpenJet.npy +0 -0
  86. acoular/tests/reference_data/PointSource.npy +0 -0
  87. acoular/tests/reference_data/PowerSpectra_csm.npy +0 -0
  88. acoular/tests/reference_data/PowerSpectra_ev.npy +0 -0
  89. acoular/tests/reference_data/RotatingFlow.npy +0 -0
  90. acoular/tests/reference_data/SlotJet.npy +0 -0
  91. acoular/tests/reference_data/TimeAverage__.npy +0 -0
  92. acoular/tests/reference_data/TimeCumAverage__.npy +0 -0
  93. acoular/tests/reference_data/TimeExpAverage_weight_F_.npy +0 -0
  94. acoular/tests/reference_data/TimeExpAverage_weight_I_.npy +0 -0
  95. acoular/tests/reference_data/TimeExpAverage_weight_S_.npy +0 -0
  96. acoular/tests/reference_data/TimeInOut__.npy +0 -0
  97. acoular/tests/reference_data/TimePower__.npy +0 -0
  98. acoular/tests/reference_data/TimeReverse__.npy +0 -0
  99. acoular/tests/reference_data/UniformFlowEnvironment.npy +0 -0
  100. acoular/tests/reference_data/beamformer_traj_time_data.h5 +0 -0
  101. acoular/tests/run_tests.sh +0 -18
  102. acoular/tests/run_tests_osx.sh +0 -16
  103. acoular/tests/test.npy +0 -0
  104. acoular/tests/test_beamformer_results.py +0 -204
  105. acoular/tests/test_classes.py +0 -60
  106. acoular/tests/test_digest.py +0 -125
  107. acoular/tests/test_environments.py +0 -73
  108. acoular/tests/test_example1.py +0 -124
  109. acoular/tests/test_grid.py +0 -92
  110. acoular/tests/test_integrate.py +0 -102
  111. acoular/tests/test_signals.py +0 -60
  112. acoular/tests/test_sources.py +0 -65
  113. acoular/tests/test_spectra.py +0 -38
  114. acoular/tests/test_timecache.py +0 -35
  115. acoular/tests/test_tprocess.py +0 -90
  116. acoular/tests/test_traj_beamformer_results.py +0 -164
  117. acoular/tests/unsupported/SpeedComparison/OvernightTestcasesBeamformer_nMics32_nGridPoints100_nFreqs4_nTrials10.png +0 -0
  118. acoular/tests/unsupported/SpeedComparison/cythonBeamformer.pyx +0 -237
  119. acoular/tests/unsupported/SpeedComparison/mainForCython.py +0 -103
  120. acoular/tests/unsupported/SpeedComparison/mainForParallelJit.py +0 -143
  121. acoular/tests/unsupported/SpeedComparison/setupCythonOpenMP.py +0 -63
  122. acoular/tests/unsupported/SpeedComparison/sharedFunctions.py +0 -153
  123. acoular/tests/unsupported/SpeedComparison/timeOverNMics_AllImportantMethods.png +0 -0
  124. acoular/tests/unsupported/SpeedComparison/timeOverNMics_faverage.png +0 -0
  125. acoular/tests/unsupported/SpeedComparison/vglOptimierungFAverage.py +0 -204
  126. acoular/tests/unsupported/SpeedComparison/vglOptimierungGaussSeidel.py +0 -182
  127. acoular/tests/unsupported/SpeedComparison/vglOptimierungR_BEAMFULL_INVERSE.py +0 -764
  128. acoular/tests/unsupported/SpeedComparison/vglOptimierungR_BEAM_OS.py +0 -231
  129. acoular/tests/unsupported/SpeedComparison/whatsFastestWayFor_absASquared.py +0 -48
  130. acoular/tests/unsupported/functionalBeamformer.py +0 -123
  131. acoular/tests/unsupported/precisionTest.py +0 -153
  132. acoular/tests/unsupported/validationOfBeamformerFuncsPOSTAcoularIntegration.py +0 -254
  133. acoular/tests/unsupported/validationOfBeamformerFuncsPREeAcoularIntegration.py +0 -531
  134. acoular/tools.py +0 -418
  135. acoular-23.11.dist-info/RECORD +0 -146
  136. acoular-23.11.dist-info/licenses/LICENSE +0 -29
  137. {acoular-23.11.dist-info → acoular-24.5.dist-info}/licenses/AUTHORS.rst +0 -0
acoular/__init__.py CHANGED
@@ -1,60 +1,128 @@
1
- # coding=UTF-8
2
- #------------------------------------------------------------------------------
1
+ # ------------------------------------------------------------------------------
3
2
  # Copyright (c) Acoular Development Team.
4
- #------------------------------------------------------------------------------
3
+ # ------------------------------------------------------------------------------
5
4
 
6
- """
7
- The Acoular library: several classes for the implemetation of
8
- acoustic beamforming
9
- """
5
+ """The Acoular library: several classes for the implementation of acoustic beamforming."""
10
6
 
11
- from .version import __author__, __date__, __version__
12
-
13
- import os
7
+ import os
14
8
 
15
9
  from .configuration import config
10
+ from .version import __author__, __date__, __version__
16
11
 
17
- from .fileimport import time_data_import, csv_import, td_import, \
18
- bk_mat_import, datx_import
19
- try:
20
- from .nidaqimport import nidaq_import
21
- except:
22
- pass
23
-
24
- try:
12
+ if config.have_sounddevice:
25
13
  from .sdinput import SoundDeviceSamplesGenerator
26
- except:
27
- pass
28
14
 
29
- from .tbeamform import IntegratorSectorTime, \
30
- BeamformerTime, BeamformerTimeSq, BeamformerTimeTraj, BeamformerTimeSqTraj,\
31
- BeamformerCleant, BeamformerCleantSq, BeamformerCleantTraj, BeamformerCleantSqTraj
32
- from .tprocess import SamplesGenerator, TimeInOut, MaskedTimeInOut, ChannelMixer, \
33
- Mixer, TimeAverage, TimeReverse, TimePower, FiltFiltOctave, FiltOctave, TimeCache, \
34
- WriteWAV, WriteH5, SpatialInterpolator, SpatialInterpolatorRotation, Trigger, \
35
- SampleSplitter, AngleTracker, SpatialInterpolatorConstantRotation, Filter, \
36
- TimeExpAverage, FiltFreqWeight, TimeCumAverage, FilterBank, OctaveFilterBank, TimeConvolve
15
+ from . import demo, tools
37
16
  from .calib import Calib
38
- from .trajectory import Trajectory
39
- from .grids import Grid, RectGrid, RectGrid3D, Sector, RectSector, RectSector3D, CircSector,\
40
- PolySector, MultiSector, MergeGrid, LineGrid, ImportGrid, ConvexSector
41
- from .environments import cartToCyl, cylToCart, Environment, UniformFlowEnvironment, RotatingFlow, \
42
- FlowField, OpenJet, SlotJet, GeneralFlowEnvironment
17
+ from .environments import (
18
+ Environment,
19
+ FlowField,
20
+ GeneralFlowEnvironment,
21
+ OpenJet,
22
+ RotatingFlow,
23
+ SlotJet,
24
+ UniformFlowEnvironment,
25
+ cartToCyl,
26
+ cylToCart,
27
+ )
28
+ from .fbeamform import (
29
+ BeamformerAdaptiveGrid,
30
+ BeamformerBase,
31
+ BeamformerCapon,
32
+ BeamformerClean,
33
+ BeamformerCleansc,
34
+ BeamformerCMF,
35
+ BeamformerDamas,
36
+ BeamformerDamasPlus,
37
+ BeamformerEig,
38
+ BeamformerFunctional,
39
+ BeamformerGIB,
40
+ BeamformerGridlessOrth,
41
+ BeamformerMusic,
42
+ BeamformerOrth,
43
+ BeamformerSODIX,
44
+ L_p,
45
+ PointSpreadFunction,
46
+ SteeringVector,
47
+ integrate,
48
+ )
49
+ from .grids import (
50
+ CircSector,
51
+ ConvexSector,
52
+ Grid,
53
+ ImportGrid,
54
+ LineGrid,
55
+ MergeGrid,
56
+ MultiSector,
57
+ PolySector,
58
+ RectGrid,
59
+ RectGrid3D,
60
+ RectSector,
61
+ RectSector3D,
62
+ Sector,
63
+ )
43
64
  from .microphones import MicGeom
44
- from .spectra import BaseSpectra, FFTSpectra, PowerSpectra, PowerSpectraImport, PowerSpectra as EigSpectra, synthetic
45
-
46
- from .fbeamform import BeamformerBase, BeamformerCapon, BeamformerEig, \
47
- BeamformerMusic, BeamformerDamas, BeamformerDamasPlus, BeamformerOrth, BeamformerCleansc, \
48
- BeamformerCMF,BeamformerSODIX, BeamformerClean, BeamformerFunctional, BeamformerGIB, L_p, integrate, \
49
- PointSpreadFunction, SteeringVector, BeamformerAdaptiveGrid, BeamformerGridlessOrth
50
-
51
- from .sources import PointSource, MovingPointSource, \
52
- TimeSamples, MaskedTimeSamples, PointSourceDipole, UncorrelatedNoiseSource, \
53
- SourceMixer, SphericalHarmonicSource, LineSource, MovingPointSourceDipole, \
54
- MovingLineSource, PointSourceConvolve
55
- from .signals import SineGenerator, WNoiseGenerator, SignalGenerator,\
56
- PNoiseGenerator, GenericSignalGenerator, FiltWNoiseGenerator
57
-
58
- from . import tools
59
-
60
- from . import demo
65
+ from .signals import (
66
+ FiltWNoiseGenerator,
67
+ GenericSignalGenerator,
68
+ PNoiseGenerator,
69
+ SignalGenerator,
70
+ SineGenerator,
71
+ WNoiseGenerator,
72
+ )
73
+ from .sources import (
74
+ LineSource,
75
+ MaskedTimeSamples,
76
+ MovingLineSource,
77
+ MovingPointSource,
78
+ MovingPointSourceDipole,
79
+ PointSource,
80
+ PointSourceConvolve,
81
+ PointSourceDipole,
82
+ SourceMixer,
83
+ SphericalHarmonicSource,
84
+ TimeSamples,
85
+ UncorrelatedNoiseSource,
86
+ )
87
+ from .spectra import BaseSpectra, FFTSpectra, PowerSpectra, PowerSpectraImport, synthetic
88
+ from .spectra import PowerSpectra as EigSpectra
89
+ from .tbeamform import (
90
+ BeamformerCleant,
91
+ BeamformerCleantSq,
92
+ BeamformerCleantSqTraj,
93
+ BeamformerCleantTraj,
94
+ BeamformerTime,
95
+ BeamformerTimeSq,
96
+ BeamformerTimeSqTraj,
97
+ BeamformerTimeTraj,
98
+ IntegratorSectorTime,
99
+ )
100
+ from .tprocess import (
101
+ AngleTracker,
102
+ ChannelMixer,
103
+ Filter,
104
+ FilterBank,
105
+ FiltFiltOctave,
106
+ FiltFreqWeight,
107
+ FiltOctave,
108
+ MaskedTimeInOut,
109
+ Mixer,
110
+ OctaveFilterBank,
111
+ SamplesGenerator,
112
+ SampleSplitter,
113
+ SpatialInterpolator,
114
+ SpatialInterpolatorConstantRotation,
115
+ SpatialInterpolatorRotation,
116
+ TimeAverage,
117
+ TimeCache,
118
+ TimeConvolve,
119
+ TimeCumAverage,
120
+ TimeExpAverage,
121
+ TimeInOut,
122
+ TimePower,
123
+ TimeReverse,
124
+ Trigger,
125
+ WriteH5,
126
+ WriteWAV,
127
+ )
128
+ from .trajectory import Trajectory
acoular/calib.py CHANGED
@@ -1,10 +1,7 @@
1
- # -*- coding: utf-8 -*-
2
- #pylint: disable-msg=E0611, E1101, C0103, R0901, R0902, R0903, R0904, W0232
3
- #------------------------------------------------------------------------------
1
+ # ------------------------------------------------------------------------------
4
2
  # Copyright (c) Acoular Development Team.
5
- #------------------------------------------------------------------------------
6
- """
7
- Implements calibration of multichannel time signals.
3
+ # ------------------------------------------------------------------------------
4
+ """Implements calibration of multichannel time signals.
8
5
 
9
6
  .. autosummary::
10
7
  :toctree: generated/
@@ -13,69 +10,64 @@ Implements calibration of multichannel time signals.
13
10
  """
14
11
 
15
12
  # imports from other packages
16
- from numpy import array
17
- from traits.api import HasPrivateTraits, CLong, File, CArray, Property, \
18
- cached_property, on_trait_change
19
13
  from os import path
20
14
 
15
+ from numpy import array
16
+ from traits.api import CArray, CLong, File, HasPrivateTraits, Property, cached_property, on_trait_change
17
+
21
18
  # acoular imports
22
19
  from .internal import digest
23
20
 
24
- class Calib( HasPrivateTraits ):
25
- """
26
- Container for calibration data in `*.xml` format
27
-
21
+
22
+ class Calib(HasPrivateTraits):
23
+ """Container for calibration data in `*.xml` format.
24
+
28
25
  This class serves as interface to load calibration data for the used
29
- microphone array.
26
+ microphone array. The calibration factors are stored as [Pa/unit].
30
27
  """
31
28
 
32
29
  #: Name of the .xml file to be imported.
33
- from_file = File(filter=['*.xml'],
34
- desc="name of the xml file to import")
30
+ from_file = File(filter=['*.xml'], desc='name of the xml file to import')
35
31
 
36
32
  #: Basename of the .xml-file. Readonly / is set automatically.
37
- basename = Property( depends_on = 'from_file',
38
- desc="basename of xml file")
39
-
40
- #: Number of microphones in the calibration data,
33
+ basename = Property(depends_on='from_file', desc='basename of xml file')
34
+
35
+ #: Number of microphones in the calibration data,
41
36
  #: is set automatically / read from file.
42
- num_mics = CLong( 0,
43
- desc="number of microphones in the geometry")
37
+ num_mics = CLong(0, desc='number of microphones in the geometry')
44
38
 
45
- #: Array of calibration factors,
39
+ #: Array of calibration factors,
46
40
  #: is set automatically / read from file.
47
- data = CArray(
48
- desc="calibration data")
41
+ data = CArray(desc='calibration data')
49
42
 
50
43
  # Internal identifier
51
- digest = Property( depends_on = ['basename', ] )
44
+ digest = Property(depends_on=['basename'])
52
45
 
53
46
  @cached_property
54
- def _get_digest( self ):
47
+ def _get_digest(self):
55
48
  return digest(self)
56
-
49
+
57
50
  @cached_property
58
- def _get_basename( self ):
51
+ def _get_basename(self):
59
52
  if not path.isfile(self.from_file):
60
53
  return ''
61
54
  return path.splitext(path.basename(self.from_file))[0]
62
-
55
+
63
56
  @on_trait_change('basename')
64
- def import_data( self ):
65
- """
66
- Loads the calibration data from `*.xml` file .
67
- """
57
+ def import_data(self):
58
+ """Loads the calibration data from `*.xml` file ."""
68
59
  if not path.isfile(self.from_file):
69
60
  # empty calibration
70
- if self.basename=='':
71
- self.data = None
61
+ if self.basename == '':
62
+ self.data = None
72
63
  self.num_mics = 0
73
64
  # no file there
74
65
  else:
75
- self.data = array([1.0, ], 'd')
66
+ self.data = array([1.0], 'd')
76
67
  self.num_mics = 1
77
68
  return
78
69
  import xml.dom.minidom
70
+
79
71
  doc = xml.dom.minidom.parse(self.from_file)
80
72
  names = []
81
73
  data = []
@@ -84,4 +76,3 @@ class Calib( HasPrivateTraits ):
84
76
  data.append(float(element.getAttribute('factor')))
85
77
  self.data = array(data, 'd')
86
78
  self.num_mics = self.data.shape[0]
87
-
acoular/configuration.py CHANGED
@@ -1,8 +1,6 @@
1
- # -*- coding: utf-8 -*-
2
- #pylint: disable-msg=E0611, E1101, C0103, R0901, R0902, R0903, R0904, W0232
3
- #------------------------------------------------------------------------------
1
+ # ------------------------------------------------------------------------------
4
2
  # Copyright (c) Acoular Development Team.
5
- #------------------------------------------------------------------------------
3
+ # ------------------------------------------------------------------------------
6
4
  """Implements global configuration of Acoular.
7
5
 
8
6
  .. autosummary::
@@ -12,9 +10,10 @@
12
10
  config
13
11
  """
14
12
 
15
- from os import path, mkdir, environ
13
+ import importlib.util
14
+ import sys
15
+ from os import environ, mkdir, path
16
16
  from warnings import warn
17
- import sys
18
17
 
19
18
  # When numpy is using OpenBLAS then it runs with OPENBLAS_NUM_THREADS which may lead to
20
19
  # overcommittment when called from within numba jitted function that run on
@@ -23,56 +22,64 @@ import sys
23
22
  # only respected once numpy starts. Later on, it cannot be changed.
24
23
 
25
24
  # we check if numpy already loaded
26
- if 'numpy' in sys.modules:
27
- # numpy is loaded
25
+ if 'numpy' in sys.modules:
26
+ # numpy is loaded
28
27
  # temporarily route stdout to string
29
28
  import io
30
- import numpy
29
+
30
+ import numpy as np
31
+
31
32
  orig_stdout = sys.stdout
32
33
  temp_stdout = io.StringIO()
33
34
  sys.stdout = temp_stdout
34
- numpy.show_config()
35
+ np.show_config()
35
36
  sys.stdout = orig_stdout
36
37
  # check if it uses OpenBLAS or another library
37
38
  if 'openblas' in temp_stdout.getvalue().lower():
38
39
  # it's OpenBLAS, set numba threads=1 to avoid overcommittment
39
40
  import numba
41
+
40
42
  numba.set_num_threads(1)
41
- warn("We detected that Numpy is already loaded and uses OpenBLAS. Because "
42
- "this conflicts with Numba parallel execution, we disable parallel "
43
- "execution for now and processing might be slower. To speed up, "
44
- "either import Numpy after Acoular or set environment variable "
45
- "OPENBLAS_NUM_THREADS=1 before start of the program.",
46
- UserWarning, stacklevel = 2)
43
+ warn(
44
+ 'We detected that Numpy is already loaded and uses OpenBLAS. Because '
45
+ 'this conflicts with Numba parallel execution, we disable parallel '
46
+ 'execution for now and processing might be slower. To speed up, '
47
+ 'either import Numpy after Acoular or set environment variable '
48
+ 'OPENBLAS_NUM_THREADS=1 before start of the program.',
49
+ UserWarning,
50
+ stacklevel=2,
51
+ )
47
52
  else:
48
53
  # numpy is not loaded
49
- environ['OPENBLAS_NUM_THREADS'] = "1"
54
+ environ['OPENBLAS_NUM_THREADS'] = '1'
50
55
 
51
56
  # this loads numpy, so we have to defer loading until OpenBLAS check is done
52
- from traits.api import Trait, Bool, Str, Property, HasStrictTraits
57
+ from traits.api import Bool, Either, HasStrictTraits, Property, Str, Trait, cached_property
58
+
53
59
 
54
60
  class Config(HasStrictTraits):
55
- """
56
- This class implements the global configuration of the Acoular package.
61
+ """Implements the global configuration of the Acoular package.
57
62
 
58
- An instance of this class can be accessed for adjustment of the following
63
+ An instance of this class can be accessed for adjustment of the following
59
64
  properties.
60
65
  General caching behaviour can be controlled by :attr:`global_caching`.
61
- The package used to read and write .h5 files can be specified
62
- by :attr:`h5library`.
66
+ The package used to read and write .h5 files can be specified
67
+ by :attr:`h5library`.
63
68
 
64
- Example:
69
+ Example:
70
+ --------
65
71
  For using Acoular with h5py package and overwrite existing cache:
66
-
72
+
67
73
  >>> import acoular
68
74
  >>> acoular.config.h5library = "h5py"
69
75
  >>> acoular.config.global_caching = "overwrite"
76
+
70
77
  """
71
-
78
+
72
79
  def __init__(self):
73
80
  HasStrictTraits.__init__(self)
74
81
  self._assert_h5library()
75
-
82
+
76
83
  #: Flag that globally defines caching behaviour of Acoular classes
77
84
  #: defaults to 'individual'.
78
85
  #:
@@ -82,25 +89,26 @@ class Config(HasStrictTraits):
82
89
  #: * 'readonly': Acoular classes do not actively cache, but read from cache if existing.
83
90
  #: * 'overwrite': Acoular classes replace existing cachefile content with new data.
84
91
  global_caching = Property()
85
-
86
- _global_caching = Trait('individual','all','none','readonly','overwrite')
87
92
 
88
- #: Flag that globally defines package used to read and write .h5 files
89
- #: defaults to 'pytables'. If 'pytables' can not be imported, 'h5py' is used
93
+ _global_caching = Trait('individual', 'all', 'none', 'readonly', 'overwrite')
94
+
95
+ #: Flag that globally defines package used to read and write .h5 files
96
+ #: defaults to 'pytables'. It is also possible to set it to 'tables', which is an alias for 'pytables'.
97
+ #: If 'pytables' can not be imported, 'h5py' is used.
90
98
  h5library = Property()
91
-
92
- _h5library = Trait('pytables','h5py')
93
-
99
+
100
+ _h5library = Either('pytables', 'tables', 'h5py', default='pytables')
101
+
94
102
  #: Defines the path to the directory containing Acoulars cache files.
95
103
  #: If the specified :attr:`cache_dir` directory does not exist,
96
- #: it will be created. attr:`cache_dir` defaults to current session path.
104
+ #: it will be created. :attr:`cache_dir` defaults to current session path.
97
105
  cache_dir = Property()
98
106
 
99
- _cache_dir = Str("")
107
+ _cache_dir = Str('')
100
108
 
101
- #: Defines the working directory containing files that can be loaded by the
102
- #: fileimport.py module.
103
- #: Defaults to current session path.
109
+ #: Defines the working directory containing data files. Used only by
110
+ #: :class:`~acoular.tprocess.WriteH5` class.
111
+ #: Defaults to current session path.
104
112
  td_dir = Property()
105
113
 
106
114
  _td_dir = Str(path.curdir)
@@ -108,61 +116,96 @@ class Config(HasStrictTraits):
108
116
  #: Boolean Flag that determines whether user has access to traitsui features.
109
117
  #: Defaults to False.
110
118
  use_traitsui = Property()
111
-
119
+
112
120
  _use_traitsui = Bool(False)
113
-
114
-
121
+
122
+ #: Boolean Flag that determines whether tables is installed.
123
+ have_tables = Property()
124
+
125
+ #: Boolean Flag that determines whether h5py is installed.
126
+ have_h5py = Property()
127
+
128
+ #: Boolean Flag that determines whether matplotlib is installed.
129
+ have_matplotlib = Property()
130
+
131
+ #: Boolean Flag that determines whether pylops is installed.
132
+ have_pylops = Property()
133
+
134
+ #: Boolean Flag that determines whether sounddevice is installed.
135
+ have_sounddevice = Property()
136
+
115
137
  def _get_global_caching(self):
116
138
  return self._global_caching
117
139
 
118
- def _set_global_caching(self,globalCachingValue):
140
+ def _set_global_caching(self, globalCachingValue):
119
141
  self._global_caching = globalCachingValue
120
-
142
+
121
143
  def _get_h5library(self):
122
144
  return self._h5library
123
-
124
- def _set_h5library(self,libraryName):
125
- self._h5library = libraryName
126
-
145
+
146
+ def _set_h5library(self, libraryName):
147
+ self._h5library = libraryName
148
+
127
149
  def _get_use_traitsui(self):
128
150
  return self._use_traitsui
129
-
151
+
130
152
  def _set_use_traitsui(self, use_tui):
131
153
  if use_tui:
132
- from . import traitsviews
154
+ from . import traitsviews
133
155
  # If user tries to use traitsuis and it's not installed, this will throw an error.
134
- self._use_traitsui = use_tui
135
-
156
+ self._use_traitsui = use_tui
157
+
136
158
  def _assert_h5library(self):
137
- try:
138
- import tables
139
- self.h5library = 'pytables'
140
- except:
141
- try:
142
- import h5py
143
- self.h5library = 'h5py'
144
- except:
145
- raise ImportError("packages h5py and pytables are missing!")
159
+ if not self.have_tables and not self.have_h5py:
160
+ msg = 'Packages H5py and PyTables are missing! At least one of them is required for Acoular to work.'
161
+ raise ImportError(msg)
162
+ if not self.have_tables:
163
+ self.h5library = 'h5py'
146
164
 
147
165
  def _get_cache_dir(self):
148
- if self._cache_dir == "":
149
- cache_dir = path.join(path.curdir,'cache')
166
+ if self._cache_dir == '':
167
+ cache_dir = path.join(path.curdir, 'cache')
150
168
  if not path.exists(cache_dir):
151
169
  mkdir(cache_dir)
152
170
  self._cache_dir = cache_dir
153
171
  return self._cache_dir
154
-
155
- def _set_cache_dir(self,cdir):
172
+
173
+ def _set_cache_dir(self, cdir):
156
174
  if not path.exists(cdir):
157
175
  mkdir(cdir)
158
176
  self._cache_dir = cdir
159
177
 
160
178
  def _get_td_dir(self):
161
179
  return self._td_dir
162
-
163
- def _set_td_dir(self,tddir):
180
+
181
+ def _set_td_dir(self, tddir):
164
182
  self._td_dir = tddir
165
183
 
184
+ def _have_module(self, module_name):
185
+ spec = importlib.util.find_spec(module_name)
186
+ return spec is not None
187
+
188
+ @cached_property
189
+ def _get_have_matplotlib(self):
190
+ return self._have_module('matplotlib')
191
+
192
+ @cached_property
193
+ def _get_have_pylops(self):
194
+ return self._have_module('pylops')
195
+
196
+ @cached_property
197
+ def _get_have_sounddevice(self):
198
+ return self._have_module('sounddevice')
199
+
200
+ @cached_property
201
+ def _get_have_tables(self):
202
+ return self._have_module('tables')
203
+
204
+ @cached_property
205
+ def _get_have_h5py(self):
206
+ return self._have_module('h5py')
207
+
208
+
166
209
  config = Config()
167
210
  """
168
211
  This instance implements the global configuration of the Acoular package.
@@ -174,10 +217,10 @@ General caching behaviour can be controlled by the :attr:`global_caching` attrib
174
217
  * 'readonly': Acoular classes do not actively cache, but read from cache if existing.
175
218
  * 'overwrite': Acoular classes replace existing cachefile content with new data.
176
219
 
177
- The package used to read and write .h5 files can be specified
178
- by :attr:`h5library`:
179
- * 'pytables': Use 'tables' (or 'pytables', depending on python distribution).
180
- * 'h5py': Use 'h5py'.
220
+ The package used to read and write .h5 files can be specified
221
+ by :attr:`h5library`:
222
+ * 'PyTables': Use 'tables' (or 'pytables', depending on python distribution).
223
+ * 'H5py': Use 'h5py'.
181
224
 
182
225
  Some Acoular classes support GUI elements for usage with tools from the TraitsUI package.
183
226
  If desired, this package has to be installed manually, as it is not a prerequisite for
@@ -186,9 +229,9 @@ To enable the functionality, the flag attribute :attr:`use_traitsui` has to be s
186
229
  Note: this is independent from the GUI tools implemented in the spectAcoular package.
187
230
 
188
231
 
189
- Example:
232
+ Example:
190
233
  For using Acoular with h5py package and overwrite existing cache:
191
-
234
+
192
235
  >>> import acoular
193
236
  >>> acoular.config.h5library = "h5py"
194
237
  >>> acoular.config.global_caching = "overwrite"
acoular/demo/__init__.py CHANGED
@@ -1,7 +1,13 @@
1
- # coding=UTF-8
2
- #------------------------------------------------------------------------------
1
+ # ------------------------------------------------------------------------------
3
2
  # Copyright (c) Acoular Development Team.
4
- #------------------------------------------------------------------------------
3
+ # ------------------------------------------------------------------------------
4
+ """The Acoular demo.
5
5
 
6
+ .. autosummary::
7
+ :toctree: generated/
6
8
 
7
- from . import acoular_demo
9
+ acoular_demo
10
+
11
+ """
12
+
13
+ from . import acoular_demo