acoular 24.5__py3-none-any.whl → 24.10__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.
acoular/environments.py CHANGED
@@ -43,9 +43,9 @@ from numpy import (
43
43
  vstack,
44
44
  zeros_like,
45
45
  )
46
- from numpy.linalg.linalg import norm
47
46
  from scipy.integrate import ode
48
47
  from scipy.interpolate import LinearNDInterpolator
48
+ from scipy.linalg import norm
49
49
  from scipy.spatial import ConvexHull
50
50
  from traits.api import CArray, Dict, Float, HasPrivateTraits, Int, Property, Trait, cached_property
51
51
 
@@ -85,7 +85,7 @@ def dist_mat(gpos, mpos):
85
85
  return rm
86
86
 
87
87
 
88
- def cartToCyl(x, Q=None):
88
+ def cartToCyl(x, Q=None): # noqa: N802, N803
89
89
  """Returns the cylindrical coordinate representation of a input position
90
90
  which was before transformed into a modified cartesian coordinate, which
91
91
  has flow into positive z direction.
@@ -111,7 +111,7 @@ def cartToCyl(x, Q=None):
111
111
  return array([arctan2(x[1], x[0]), sqrt(x[0] ** 2 + x[1] ** 2), x[2]])
112
112
 
113
113
 
114
- def cylToCart(x, Q=None):
114
+ def cylToCart(x, Q=None): # noqa: N802, N803
115
115
  """Returns the cartesian coordinate representation of a input position
116
116
  which was before transformed into a cylindrical coordinate, which
117
117
  has flow into positive z direction.
@@ -283,8 +283,9 @@ class FlowField(HasPrivateTraits):
283
283
 
284
284
 
285
285
  class SlotJet(FlowField):
286
- """Provides an analytical approximation of the flow field of a slot jet,
287
- see :ref:`Albertson et al., 1950<Albertson1950>`.
286
+ """Provides an analytical approximation of the flow field of a slot jet.
287
+
288
+ See :cite:`Albertson1950` for details.
288
289
  """
289
290
 
290
291
  #: Exit velocity at jet origin, i.e. the nozzle. Defaults to 0.
@@ -303,9 +304,12 @@ class SlotJet(FlowField):
303
304
  #: Width of the slot, defaults to 0.2 .
304
305
  B = Float(0.2, desc='nozzle diameter')
305
306
 
307
+ #: Nondimensional length of zone of flow establishment (jet core length), defaults to 5.2
308
+ l = Float(5.2, desc='flow establishment length') # noqa: E741
309
+
306
310
  # internal identifier
307
311
  digest = Property(
308
- depends_on=['v0', 'origin', 'flow', 'plane', 'B'],
312
+ depends_on=['v0', 'origin', 'flow', 'plane', 'B', 'l'],
309
313
  )
310
314
 
311
315
  @cached_property
@@ -330,7 +334,6 @@ class SlotJet(FlowField):
330
334
  given location.
331
335
 
332
336
  """
333
- # TODO: better to make sure that self.flow and self.plane are indeed unit vectors before
334
337
  # normalize
335
338
  flow = self.flow / norm(self.flow)
336
339
  plane = self.plane / norm(self.plane)
@@ -342,7 +345,7 @@ class SlotJet(FlowField):
342
345
  # local co-ordinate system
343
346
  x = dot(flow, xx1)
344
347
  y = dot(yy, xx1)
345
- x1 = 0.109 * x
348
+ x1 = 0.5668 / self.l * x # C1 in Albertson1950
346
349
  h1 = abs(y) + sqrt(pi) * 0.5 * x1 - 0.5 * self.B
347
350
  if h1 < 0.0:
348
351
  # core jet
@@ -362,8 +365,9 @@ class SlotJet(FlowField):
362
365
 
363
366
 
364
367
  class OpenJet(FlowField):
365
- """Provides an analytical approximation of the flow field of an open jet,
366
- see :ref:`Albertson et al., 1950<Albertson1950>`.
368
+ """Provides an analytical approximation of the flow field of an open jet.
369
+
370
+ See :cite:`Albertson1950` for details.
367
371
 
368
372
  Notes
369
373
  -----
@@ -382,9 +386,12 @@ class OpenJet(FlowField):
382
386
  #: Diameter of the nozzle, defaults to 0.2 .
383
387
  D = Float(0.2, desc='nozzle diameter')
384
388
 
389
+ #: Nondimensional length of zone of flow establishment (jet core length), defaults to 6.2
390
+ l = Float(6.2, desc='flow establishment length') # noqa: E741
391
+
385
392
  # internal identifier
386
393
  digest = Property(
387
- depends_on=['v0', 'origin', 'D'],
394
+ depends_on=['v0', 'origin', 'D', 'l'],
388
395
  )
389
396
 
390
397
  @cached_property
@@ -411,7 +418,7 @@ class OpenJet(FlowField):
411
418
  """
412
419
  x, y, z = xx - self.origin
413
420
  r = sqrt(y * y + z * z)
414
- x1 = 0.081 * x
421
+ x1 = 0.5022 / self.l * x # C2 in Albertson1950
415
422
  h1 = r + x1 - 0.5 * self.D
416
423
  U = self.v0 * exp(-h1 * h1 / (2 * x1 * x1))
417
424
  if h1 < 0.0:
@@ -497,7 +504,7 @@ class RotatingFlow(FlowField):
497
504
  return v, dv
498
505
 
499
506
 
500
- def spiral_sphere(N, Om=None, b=None): # change to 4*pi
507
+ def spiral_sphere(N, Om=None, b=None): # noqa: N803 # change to 4*pi
501
508
  """Internal helper function for the raycasting that returns an array of
502
509
  unit vectors (N, 3) giving equally distributed directions on a part of
503
510
  sphere given by the center direction b and the solid angle Om.
@@ -589,8 +596,6 @@ class GeneralFlowEnvironment(Environment):
589
596
  gt = empty((gpos.shape[-1], mpos.shape[-1]))
590
597
  for micnum, x0 in enumerate(mpos.T):
591
598
  key = x0.tobytes() # make array hashable
592
- # TODO: the interpolator also depends the roi, so idict keys should also depend on roi
593
- # OR the idict should be cleaned if roi changes
594
599
  try:
595
600
  li = self.idict[key] # fetch stored interpolator
596
601
  except KeyError:
acoular/fastFuncs.py CHANGED
@@ -8,9 +8,9 @@ computational costs. All functionalities are optimized via NUMBA.
8
8
  import numba as nb
9
9
  import numpy as np
10
10
 
11
- cachedOption = True # if True: saves the numba func as compiled func in sub directory
12
- parallelOption = 'parallel' # if numba.guvectorize is used: 'CPU' for single threading; 'parallel' for multithreading; 'cuda' for calculating on GPU
13
- fastOption = True # fastmath options
11
+ CACHED_OPTION = True # if True: saves the numba func as compiled func in sub directory
12
+ PARALLEL_OPTION = 'parallel' # if numba.guvectorize is used: 'CPU' for single threading; 'parallel' for multithreading; 'cuda' for calculating on GPU
13
+ FAST_OPTION = True # fastmath options
14
14
 
15
15
 
16
16
  # Formerly known as 'faverage'
@@ -19,9 +19,9 @@ fastOption = True # fastmath options
19
19
  nb.complex128[:, :, ::1](nb.complex128[:, :, ::1], nb.complex128[:, ::1]),
20
20
  nb.complex64[:, :, ::1](nb.complex64[:, :, ::1], nb.complex64[:, ::1]),
21
21
  ],
22
- cache=cachedOption,
22
+ cache=CACHED_OPTION,
23
23
  parallel=True,
24
- fastmath=fastOption,
24
+ fastmath=FAST_OPTION,
25
25
  )
26
26
  def calcCSM(csm, SpecAllMics):
27
27
  """Adds a given spectrum to the Cross-Spectral-Matrix (CSM).
@@ -216,7 +216,7 @@ def beamformerFreq(steerVecType, boolRemovedDiagOfCSM, normFactor, inputTupleSte
216
216
  nb.float64[::1],
217
217
  ),
218
218
  ],
219
- cache=cachedOption,
219
+ cache=CACHED_OPTION,
220
220
  parallel=True,
221
221
  error_model='numpy',
222
222
  )
@@ -306,7 +306,7 @@ def _freqBeamformer_FullCSM(
306
306
  nb.float64[::1],
307
307
  ),
308
308
  ],
309
- cache=cachedOption,
309
+ cache=CACHED_OPTION,
310
310
  parallel=True,
311
311
  error_model='numpy',
312
312
  )
@@ -389,9 +389,9 @@ def _freqBeamformer_EigValues(
389
389
  [(nb.complex128[:, :], nb.complex128[:], nb.float64[:], nb.float64[:], nb.float64[:])],
390
390
  '(m,m),(m),()->(),()',
391
391
  nopython=True,
392
- target=parallelOption,
393
- cache=cachedOption,
394
- fastmath=fastOption,
392
+ target=PARALLEL_OPTION,
393
+ cache=CACHED_OPTION,
394
+ fastmath=FAST_OPTION,
395
395
  )
396
396
  def _freqBeamformer_SpecificSteerVec_FullCSM(csm, steerVec, signalLossNormalization, result, normalizeSteer):
397
397
  # see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
@@ -419,9 +419,9 @@ def _freqBeamformer_SpecificSteerVec_FullCSM(csm, steerVec, signalLossNormalizat
419
419
  [(nb.complex128[:, :], nb.complex128[:], nb.float64[:], nb.float64[:], nb.float64[:])],
420
420
  '(m,m),(m),()->(),()',
421
421
  nopython=True,
422
- target=parallelOption,
423
- cache=cachedOption,
424
- fastmath=fastOption,
422
+ target=PARALLEL_OPTION,
423
+ cache=CACHED_OPTION,
424
+ fastmath=FAST_OPTION,
425
425
  )
426
426
  def _freqBeamformer_SpecificSteerVec_CsmRemovedDiag(csm, steerVec, signalLossNormalization, result, normalizeSteer):
427
427
  # see bottom of information header of 'beamformerFreq' for information on which steps are taken, in order to gain speed improvements.
@@ -446,9 +446,9 @@ def _freqBeamformer_SpecificSteerVec_CsmRemovedDiag(csm, steerVec, signalLossNor
446
446
  [(nb.float64[:], nb.complex128[:, :], nb.complex128[:], nb.float64[:], nb.float64[:], nb.float64[:])],
447
447
  '(e),(m,e),(m),()->(),()',
448
448
  nopython=True,
449
- target=parallelOption,
450
- cache=cachedOption,
451
- fastmath=fastOption,
449
+ target=PARALLEL_OPTION,
450
+ cache=CACHED_OPTION,
451
+ fastmath=FAST_OPTION,
452
452
  )
453
453
  def _freqBeamformer_EigValProb_SpecificSteerVec_FullCSM(
454
454
  eigVal,
@@ -482,9 +482,9 @@ def _freqBeamformer_EigValProb_SpecificSteerVec_FullCSM(
482
482
  [(nb.float64[:], nb.complex128[:, :], nb.complex128[:], nb.float64[:], nb.float64[:], nb.float64[:])],
483
483
  '(e),(m,e),(m),()->(),()',
484
484
  nopython=True,
485
- target=parallelOption,
486
- cache=cachedOption,
487
- fastmath=fastOption,
485
+ target=PARALLEL_OPTION,
486
+ cache=CACHED_OPTION,
487
+ fastmath=FAST_OPTION,
488
488
  )
489
489
  def _freqBeamformer_EigValProb_SpecificSteerVec_CsmRemovedDiag(
490
490
  eigVal,
@@ -599,12 +599,12 @@ def calcPointSpreadFunction(steerVecType, distGridToArrayCenter, distGridToAllMi
599
599
  ],
600
600
  '(),(m),(s),(s,m),()->(s)',
601
601
  nopython=True,
602
- target=parallelOption,
603
- cache=cachedOption,
604
- fastmath=fastOption,
602
+ target=PARALLEL_OPTION,
603
+ cache=CACHED_OPTION,
604
+ fastmath=FAST_OPTION,
605
605
  )
606
606
  def _psf_Formulation1AkaClassic(
607
- distGridToArrayCenter,
607
+ distGridToArrayCenter, # noqa ARG001
608
608
  distGridToAllMics,
609
609
  distSourcesToArrayCenter,
610
610
  distSourcesToAllMics,
@@ -632,9 +632,9 @@ def _psf_Formulation1AkaClassic(
632
632
  ],
633
633
  '(),(m),(s),(s,m),()->(s)',
634
634
  nopython=True,
635
- target=parallelOption,
636
- cache=cachedOption,
637
- fastmath=fastOption,
635
+ target=PARALLEL_OPTION,
636
+ cache=CACHED_OPTION,
637
+ fastmath=FAST_OPTION,
638
638
  )
639
639
  def _psf_Formulation2AkaInverse(
640
640
  distGridToArrayCenter,
@@ -669,9 +669,9 @@ def _psf_Formulation2AkaInverse(
669
669
  ],
670
670
  '(),(m),(s),(s,m),()->(s)',
671
671
  nopython=True,
672
- target=parallelOption,
673
- cache=cachedOption,
674
- fastmath=fastOption,
672
+ target=PARALLEL_OPTION,
673
+ cache=CACHED_OPTION,
674
+ fastmath=FAST_OPTION,
675
675
  )
676
676
  def _psf_Formulation3AkaTrueLevel(
677
677
  distGridToArrayCenter,
@@ -708,12 +708,12 @@ def _psf_Formulation3AkaTrueLevel(
708
708
  ],
709
709
  '(),(m),(s),(s,m),()->(s)',
710
710
  nopython=True,
711
- target=parallelOption,
712
- cache=cachedOption,
713
- fastmath=fastOption,
711
+ target=PARALLEL_OPTION,
712
+ cache=CACHED_OPTION,
713
+ fastmath=FAST_OPTION,
714
714
  )
715
715
  def _psf_Formulation4AkaTrueLocation(
716
- distGridToArrayCenter,
716
+ distGridToArrayCenter, # noqa ARG001
717
717
  distGridToAllMics,
718
718
  distSourcesToArrayCenter,
719
719
  distSourcesToAllMics,
@@ -743,7 +743,7 @@ def _psf_Formulation4AkaTrueLocation(
743
743
  # CURRENTLY NOT NEEDED, AS CUSTOM PSF WILL BE CALCULATED IN fbeamform.SteeringVector WITH THE USE OF Trait transfer
744
744
  # @nb.guvectorize([(nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:,:], nb.float64[:], nb.float64[:]),
745
745
  # (nb.float64[:], nb.float64[:], nb.float64[:], nb.float64[:,:], nb.float64[:], nb.float32[:])],
746
- # '(),(m),(s),(s,m),()->(s)', nopython=True, target=parallelOption, cache=cachedOption)
746
+ # '(),(m),(s),(s,m),()->(s)', nopython=True, target=PARALLEL_OPTION, cache=CACHED_OPTION)
747
747
  # def _psf_SpecificSteerVec(steerVec, steerVecSources, result):
748
748
  # nMics = len(steerVec)
749
749
  # for cntSources in range(steerVecSources.shape[0]):
@@ -765,9 +765,9 @@ def _psf_Formulation4AkaTrueLocation(
765
765
  ],
766
766
  '(g,g),(g),(),()->(g)',
767
767
  nopython=True,
768
- target=parallelOption,
769
- cache=cachedOption,
770
- fastmath=fastOption,
768
+ target=PARALLEL_OPTION,
769
+ cache=CACHED_OPTION,
770
+ fastmath=FAST_OPTION,
771
771
  )
772
772
  def damasSolverGaussSeidel(A, dirtyMap, nIterations, relax, damasSolution):
773
773
  """Solves the DAMAS inverse problem via modified gauss seidel.
@@ -847,9 +847,9 @@ def calcTransfer(distGridToArrayCenter, distGridToAllMics, waveNumber):
847
847
  [(nb.float64[:], nb.float64[:], nb.float64[:], nb.complex128[:])],
848
848
  '(),(m),()->(m)',
849
849
  nopython=True,
850
- target=parallelOption,
851
- cache=cachedOption,
852
- fastmath=fastOption,
850
+ target=PARALLEL_OPTION,
851
+ cache=CACHED_OPTION,
852
+ fastmath=FAST_OPTION,
853
853
  )
854
854
  def _transferCoreFunc(distGridToArrayCenter, distGridToAllMics, waveNumber, result):
855
855
  nMics = distGridToAllMics.shape[0]