fullwave25 1.4.3.dev0__py3-none-any.whl → 1.5.0.dev0__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.
fullwave/__init__.py CHANGED
@@ -66,7 +66,7 @@ try:
66
66
  __version__ = version("fullwave")
67
67
  except PackageNotFoundError:
68
68
  # Update via bump-my-version, not manually
69
- __version__ = "1.4.3-dev0"
69
+ __version__ = "1.5.0-dev0"
70
70
 
71
71
  VERSION = __version__ # for convenience
72
72
  logger.info("Fullwave version: %s", __version__)
fullwave/medium.py CHANGED
@@ -19,6 +19,7 @@ from fullwave.solver.utils import initialize_relaxation_param_dict
19
19
  from fullwave.utils import check_functions, plot_utils
20
20
  from fullwave.utils.coordinates import coords_to_map, map_to_coords
21
21
  from fullwave.utils.relaxation_parameters import (
22
+ RelaxationParametersGenerator,
22
23
  _array_module,
23
24
  band_scaled_sound_speed,
24
25
  generate_relaxation_params,
@@ -1258,9 +1259,11 @@ class Medium:
1258
1259
  Path to the relaxation parameters database.
1259
1260
  path_invalid_cells : Path, optional
1260
1261
  Path to the JSON record an evaluation wrote, which names every
1261
- invalid cell of the table and why it is invalid. A request that lands
1262
- on one is warned about, and the lookup still serves it. Without it
1263
- nothing is marked and the behaviour is unchanged.
1262
+ invalid cell of the table and why it is invalid. Without it, the
1263
+ record ``<table stem>_invalid_cells.json`` beside the table is read
1264
+ where it exists. A voxel on a ``not_fitted`` cell uses the nearest
1265
+ fitted exponent of the same row, and a voxel on another invalid cell
1266
+ uses that cell and warns.
1264
1267
  n_relaxation_mechanisms : int, optional
1265
1268
  Number of relaxation mechanisms, by default 4
1266
1269
  attenuation_builder : str, optional
@@ -1292,15 +1295,19 @@ class Medium:
1292
1295
  ``MediumRelaxationMaps.sound_speed`` reports the base speed that
1293
1296
  gives it. See ``band_scaled_sound_speed``.
1294
1297
  scale_to_requested_alpha_coeff : bool, optional
1295
- Give the requested attenuation coefficient rather than the
1296
- calibrated level the lookup serves. The coefficient axis holds
1297
- 0.0022 and then 0.01 to 1.00 in absolute steps of 0.01, so a request
1298
- between two levels is served the one above and a request past either
1299
- end is clipped. Setting this True scales the relaxation departure by
1300
- the shortfall instead. It matters most under a band transfer, which
1301
- multiplies the request by a factor and often carries it off the
1302
- axis. False, the default, reproduces every result produced before
1303
- this existed.
1298
+ Give the specified attenuation coefficient rather than the
1299
+ coefficient of the cell used. The coefficient axis holds
1300
+ 0.0022, then 0.01 to 1.00 in steps of 0.01, then 1.1 to 2.0 in
1301
+ steps of 0.1, then 3 to 10 in steps of 1, so a specified value
1302
+ between two nodes maps to the node above and a value past either
1303
+ end maps to the last node. Above 1.0 the table fits only some
1304
+ exponents, so a cell it does not fit maps to the fitted exponent
1305
+ nearest to it in the same coefficient row. The lookup logs a warning
1306
+ that names each specified value and the cell used. Setting this True
1307
+ scales the relaxation departure by the shortfall instead. It matters
1308
+ most under a band transfer, which multiplies the specified
1309
+ coefficient by a factor and often carries it off the axis. False,
1310
+ the default, reproduces every result produced before this existed.
1304
1311
  n_jobs : int, optional
1305
1312
  Number of parallel jobs for relaxation parameter calculation.
1306
1313
  Default is -1, which uses all available CPUs.
@@ -1612,6 +1619,20 @@ class Medium:
1612
1619
  }
1613
1620
  return relaxation_param_dict
1614
1621
 
1622
+ def _exponent_used(
1623
+ self,
1624
+ alpha_coeff: NDArray[np.float64],
1625
+ alpha_power: NDArray[np.float64],
1626
+ ) -> NDArray[np.float64]:
1627
+ """Return the exponent of the cell each voxel uses, which sets the band anchor."""
1628
+ if self.band_scale == 1.0:
1629
+ return alpha_power
1630
+ return RelaxationParametersGenerator(
1631
+ n_relaxation_mechanisms=self.n_relaxation_mechanisms,
1632
+ path_database=self.path_relaxation_parameters_database,
1633
+ path_invalid_cells=self.path_invalid_cells,
1634
+ )._exponent_used(alpha_coeff, alpha_power, band_scale=self.band_scale)
1635
+
1615
1636
  def relaxation_parameters_at(
1616
1637
  self,
1617
1638
  coords: NDArray[np.int64],
@@ -1636,7 +1657,7 @@ class Medium:
1636
1657
  sound_speed = band_scaled_sound_speed(
1637
1658
  self._to_numpy(self.sound_speed[index]),
1638
1659
  alpha_coeff,
1639
- alpha_power,
1660
+ self._exponent_used(alpha_coeff, alpha_power),
1640
1661
  self.band_scale,
1641
1662
  )
1642
1663
  parameters = self._relaxation_parameters_of(sound_speed, alpha_coeff, alpha_power)
@@ -1668,7 +1689,7 @@ class Medium:
1668
1689
  sound_speed = band_scaled_sound_speed(
1669
1690
  self.sound_speed,
1670
1691
  self.alpha_coeff,
1671
- self.alpha_power,
1692
+ self._exponent_used(self.alpha_coeff, self.alpha_power),
1672
1693
  self.band_scale,
1673
1694
  )
1674
1695
  relaxation_param_dict = self._relaxation_parameters_of(