API reference
This is the API reference for the echoSMs package.
Each type of model is contained in a separate Python class (with name ending in Model
), but with common calling signatures across all model classes, as defined in ScatterModelBase
. There are also classes to provide ready access to the benchmark models and reference model definitions. There are also utility functions.
echosms.ScatterModelBase()
Bases: ABC
Base class for a class that provides a scattering model.
All scattering models should inherit from this class, have a name that ends with 'Model', and provide initialisation and calculate_ts_single() functions.
Initialise.
Attributes:
Name | Type | Description |
---|---|---|
long_name |
str
|
The long name of the model. |
short_name |
str
|
A short version of the model's long name, typically an acronym. |
analytical_type |
str
|
Whether the model implements an |
boundary_types |
list[str]
|
The types of boundary conditions that the model provides, e.g., 'fixed rigid', 'pressure release', 'fluid filled' |
shapes |
list[str]
|
The target shapes that the model can represent. |
max_ka |
float
|
An approximate maximum ka value that will result in accurate target strength results. Note that ka is often not the only parameter that determines the accuracy of the model (e.g., aspect ratio and incident angle can also affect the accuracy). |
no_expand_parameters |
list[str]
|
The model parameters that are not expanded into Pandas DataFrame columns or
Xarray DataArray coordinates. They will instead end up as a dict in the DataFrame or
DataArray |
Source code in src/echosms/scattermodelbase.py
calculate_ts(data, expand=False, inplace=False, multiprocess=False, progress=False)
Calculate the target strength (TS) for many parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Pandas DataFrame, Xarray DataArray or dict
|
Requirements for the different input data types are:
|
required |
multiprocess
|
bool
|
Split the ts calculation across CPU cores. Multiprocessing is currently provided by
mapply with little customisation. For more
sophisticated uses it may be preferred to use a multiprocessing package of your choice
directly on the |
False
|
expand
|
bool
|
Only applicable if |
False
|
inplace
|
bool
|
Only applicable if |
False
|
progress
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
None, list[float], Series, or DataFrame
|
The return type and value are determined by the type of the input variable (
|
Source code in src/echosms/scattermodelbase.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
calculate_ts_single()
abstractmethod
validate_parameters(p)
abstractmethod
Validate the model parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p
|
dict | DataFrame | DataArray
|
The model parameters. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If any of the model parameters are invalid. |
KeyError
|
If any required model parameters are not present. |
Source code in src/echosms/scattermodelbase.py
echosms.DCMModel()
Bases: ScatterModelBase
Modal series deformed cylinder model (DCM).
This class contains methods to calculate acoustic scatter from finite straight cylinders with various boundary conditions.
Source code in src/echosms/dcmmodel.py
calculate_ts(data, expand=False, inplace=False, multiprocess=False, progress=False)
Calculate the target strength (TS) for many parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Pandas DataFrame, Xarray DataArray or dict
|
Requirements for the different input data types are:
|
required |
multiprocess
|
bool
|
Split the ts calculation across CPU cores. Multiprocessing is currently provided by
mapply with little customisation. For more
sophisticated uses it may be preferred to use a multiprocessing package of your choice
directly on the |
False
|
expand
|
bool
|
Only applicable if |
False
|
inplace
|
bool
|
Only applicable if |
False
|
progress
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
None, list[float], Series, or DataFrame
|
The return type and value are determined by the type of the input variable (
|
Source code in src/echosms/scattermodelbase.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
calculate_ts_single(medium_c, medium_rho, a, b, theta, f, boundary_type, target_c=None, target_rho=None, validate_parameters=True, **kwargs)
Calculate the scatter from a finite cylinder using the modal series deformed cylinder model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
medium_c
|
float
|
Sound speed in the fluid medium surrounding the target [m/s]. |
required |
medium_rho
|
float
|
Density of the fluid medium surrounding the target [kg/m³]. |
required |
a
|
float
|
Radius of the cylinderical target [m]. |
required |
b
|
float
|
Length of the cylinderical target [m]. |
required |
theta
|
float
|
Pitch angle to calculate the scattering as per the echoSMs coordinate system [°]. |
required |
f
|
float
|
Frequency to calculate the scattering at [Hz]. |
required |
boundary_type
|
str
|
The model type. Supported model types are given in the |
required |
target_c
|
float
|
Sound speed in the fluid inside the sphere [m/s].
Only required for |
None
|
target_rho
|
float
|
Density of the fluid inside the sphere [kg/m³].
Only required for |
None
|
validate_parameters
|
bool
|
Whether to validate the model parameters. |
True
|
Returns:
Type | Description |
---|---|
float
|
The target strength (re 1 m²) of the target [dB]. |
Notes
The class implements the code in Section B.1 of Jech et al. (2015).
References
Jech, J.M., Horne, J.K., Chu, D., Demer, D.A., Francis, D.T.I., Gorska, N., Jones, B., Lavery, A.C., Stanton, T.K., Macaulay, G.J., Reeder, D.B., Sawada, K., 2015. Comparisons among ten models of acoustic backscattering used in aquatic ecosystem research. Journal of the Acoustical Society of America 138, 3742–3764. https://doi.org/10.1121/1.4937607
Source code in src/echosms/dcmmodel.py
validate_parameters(params)
Validate the model parameters.
See here for calling details.
Source code in src/echosms/dcmmodel.py
DWBA models
There are several models that use the distorted-wave Born approximation, documented below. There are also some functions to make cylinder and spheroid shapes for use in the DWBA models.
echosms.DWBAModel()
Bases: ScatterModelBase
Distorted-wave Born approximation (DWBA) scattering models.
This class calculates acoustic scatter from piecewise cylindical shapes with weakly scattering material contrasts. It can also add a stochastic component to provide the stochastic DWBA (SDWBA) model.
Source code in src/echosms/dwbamodel.py
calculate_ts(data, expand=False, inplace=False, multiprocess=False, progress=False)
Calculate the target strength (TS) for many parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Pandas DataFrame, Xarray DataArray or dict
|
Requirements for the different input data types are:
|
required |
multiprocess
|
bool
|
Split the ts calculation across CPU cores. Multiprocessing is currently provided by
mapply with little customisation. For more
sophisticated uses it may be preferred to use a multiprocessing package of your choice
directly on the |
False
|
expand
|
bool
|
Only applicable if |
False
|
inplace
|
bool
|
Only applicable if |
False
|
progress
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
None, list[float], Series, or DataFrame
|
The return type and value are determined by the type of the input variable (
|
Source code in src/echosms/scattermodelbase.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
calculate_ts_single(medium_c, medium_rho, theta, phi, f, target_c, target_rho, a, rv_pos, rv_tan, phase_sd=0, num_runs=1, validate_parameters=True, **kwargs)
Distorted-wave Born approximation scattering model.
Implements the distorted-wave Born approximation and stochastic DWBA model for calculating the acoustic backscatter from weakly scattering bodies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
medium_c
|
float
|
Sound speed in the fluid medium surrounding the target [m/s]. |
required |
medium_rho
|
float
|
Density of the fluid medium surrounding the target [kg/m³]. |
required |
theta
|
float
|
Pitch angle to calculate the scattering as per the echoSMs coordinate system [°]. |
required |
phi
|
float
|
Roll angle to calculate the scattering as per the echoSMs coordinate system [°]. |
required |
f
|
float
|
Frequency to run the model at [Hz] |
required |
target_c
|
float
|
Sound speed in the fluid inside the target [m/s]. |
required |
target_rho
|
float
|
Density of the fluid inside the target [kg/m³]. |
required |
a
|
iterable
|
The radii of the discs that define the target shape [m]. |
required |
rv_pos
|
iterable[ndarray]
|
An interable of vectors of the 3D positions of the centre of each disc that defines the target shape. Each vector should have three values corresponding to the x, y, and z coordinates [m] of the disc centre. |
required |
rv_tan
|
iterable[ndarray]
|
An interable of unit vectors of the tangent to the target body axis at
the points given in |
required |
phase_sd
|
float
|
If non-zero, this model becomes the SDWBA (stochastic DWBA). A random phase is
applied to each term in the DWBA integral, obtained from a Gaussian distribution
centered on 0 with standard deviation of |
0
|
num_runs
|
int
|
The number of times to run the SDWBA model. The mean TS (calculated in the
linear domain) is returned. Intended to be used in conjunction with |
1
|
validate_parameters
|
bool
|
Whether to validate the model parameters. |
True
|
Returns:
Type | Description |
---|---|
float
|
The target strength (re 1 m²) [dB] of the target. |
Notes
This class implements the method presented in Eqn (5) of Stanton et al. (1998). This caters to objects that are discretised into a set of adjacent discs with potentially offset centres.
The DWBA model density and sound speed values are often specified as ratios of the medium and target values (g & h). However, to maintain compatibility with other echoSMs models this implementation requires actual densities and sound speeds.
The SDWBA component is as per Demer & Conti (2003).
References
Demer, D. A., & Conti, S. G. (2003). Reconciling theoretical versus empirical target strengths of krill: Effects of phase variability on the distorted-wave Born approximation. ICES Journal of Marine Science, 60, 429-434. https://doi.org/10.1016/S1054-3139(03)00002-X
Stanton, T. K., Chu, D., & Wiebe, P. H. (1998). Sound scattering by several zooplankton groups. II. Scattering models. The Journal of the Acoustical Society of America, 103(1), 236-253. https://doi.org/10.1121/1.421110
Source code in src/echosms/dwbamodel.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
validate_parameters(params)
Validate the model parameters.
See here for calling details.
Source code in src/echosms/dwbamodel.py
echosms.PTDWBAModel()
Bases: ScatterModelBase
Phase-tracking distorted-wave Born approximation scattering model.
Source code in src/echosms/ptdwbamodel.py
calculate_ts(data, expand=False, inplace=False, multiprocess=False, progress=False)
Calculate the target strength (TS) for many parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Pandas DataFrame, Xarray DataArray or dict
|
Requirements for the different input data types are:
|
required |
multiprocess
|
bool
|
Split the ts calculation across CPU cores. Multiprocessing is currently provided by
mapply with little customisation. For more
sophisticated uses it may be preferred to use a multiprocessing package of your choice
directly on the |
False
|
expand
|
bool
|
Only applicable if |
False
|
inplace
|
bool
|
Only applicable if |
False
|
progress
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
None, list[float], Series, or DataFrame
|
The return type and value are determined by the type of the input variable (
|
Source code in src/echosms/scattermodelbase.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
calculate_ts_single(volume, theta, phi, f, voxel_size, rho, c, validate_parameters=True, **kwargs)
Phase-tracking distorted-wave Born approximation scattering model.
Implements the phase-tracking distorted-wave Born approximation model for calculating the acoustic backscatter from weakly scattering bodies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
volume
|
Numpy ndarray[int]
|
The object to be modelled as a 3D volume of voxels. Array contents should be 0
for the surrounding medium, then increasing by 1 for each additional material
type (i.e., 1, 2, 3, etc).
Increasing axes indices correspond to increasing x, y, and z values. |
required |
theta
|
float
|
Pitch angle to calculate the scattering as per the echoSMs coordinate system [°]. |
required |
phi
|
float
|
Roll angle to calculate the scattering as per the echoSMs coordinate system [°]. |
required |
f
|
float
|
Frequency to run the model at [Hz] |
required |
voxel_size
|
iterable[float]
|
The size of the voxels in |
required |
rho
|
iterable[float]
|
Densities of each material. Must have at least the same number of entries as unique
integers in |
required |
c
|
iterable[float]
|
Sound speed of each material. Must have at least the same number of entries as unique
integers in |
required |
validate_parameters
|
bool
|
Whether to validate the model parameters. |
True
|
Returns:
Type | Description |
---|---|
float
|
The target strength (re 1 m²) [dB] of the target. |
Notes
This class implements the method presented in Jones et. al. (2009). The code is based closely on the Matlab code in Jones (2006).
References
Jones, B. A. (2006). Acoustic scattering of broadband echolocation signals from prey of Blainville's beaked whales: Modeling and analysis. Master of Science, Massachusetts Institute of Technology. https://doi.org/10.1575/1912/1283
Jones, B. A., Lavery, A. C., & Stanton, T. K. (2009). Use of the distorted wave Born approximation to predict scattering by inhomogeneous objects: Application to squid. The Journal of the Acoustical Society of America, 125(1), 73-88. https://doi.org/10.1121/1.3021298
Source code in src/echosms/ptdwbamodel.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
validate_parameters(params)
echosms.dwbautils
Miscellaneous functions for the DWBA models.
DWBAdata()
Example datasets for the SDWBA and DWBA models.
Source code in src/echosms/dwbautils.py
as_dict()
DWBA model shapes as a dict.
Returns:
Type | Description |
---|---|
dict
|
All the DWBA model shapes. The dataset name is the dict key and the value is an
instance of |
model(name)
DWBA model shape with requested name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of a DWBA model shape. |
required |
Returns:
Type | Description |
---|---|
DWBAorganism
|
An instance of |
Source code in src/echosms/dwbautils.py
DWBAorganism(rv_pos, a, g, h, name, source='', note='', rv_tan=None)
dataclass
DWBA shape and property class to represent an organism.
Attributes:
Name | Type | Description |
---|---|---|
rv_pos |
iterable[ndarray]
|
An interable of vectors of the 3D positions of the centre of each disc that defines the target shape. Each vector should have three values corresponding to the x, y, and z coordinates [m] of the disc centre, as per the echoSMs coordinate system. |
a |
ndarray
|
The radii [m] of each disc. |
g |
ndarray
|
The density contrast between medium and organism (organism divied by medium). |
h |
ndarray
|
The sound speed contrast betwwen medium and organism (organism divied by medium). |
source |
str
|
A link to the source of the data. |
note |
str
|
Information about the data. |
rv_tan |
ndarray
|
An interable of unit vectors of the tangent to the body axis at the points given by (x, y, z). Each vector has three values corresponding to the x, y, and z components of the tangent vector [m]. If not given, unit vectors pointing along the positive x-axis are used. |
plot()
Do a simple plot of the DWBA model data.
Source code in src/echosms/dwbautils.py
create_dwba_cylinder(radius, length, spacing=0.0001)
Create shape description variables for the DWBA model for cylinders.
The shape descriptions are essentially a set of discs and their orientation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius
|
float
|
The radius [m] of the cylinder. |
required |
length
|
float
|
The length [m] of the cylinder. |
required |
spacing
|
float
|
The spacing [m] between successive discs. |
0.0001
|
Returns:
Name | Type | Description |
---|---|---|
rv_pos |
iterable[ndarray]
|
An interable of vectors of the 3D positions of the centre of each disc that defines the cylinder. Each vector has three values corresponding to the x, y, and z coordinates [m] of the disc centre. |
rv_tan |
iterable[ndarray]
|
An interable of unit vectors of the tangent to the cylinder body axis at
the points given in |
a |
iterable
|
The radii [m] of the discs that define the spheroid. |
Source code in src/echosms/dwbautils.py
create_dwba_spheroid(major_radius, minor_radius, spacing=0.0001)
Create shape description variables for the DWBA model for spheres and prolate spheroids.
The shape descriptions are essentially a set of discs and their orientation.
Notes
Currently only supports prolate spheroids and spheres (set major_radius
and minor_radius
to the same value to get a sphere).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
major_radius
|
float
|
The major radius [m] of the spheroid. |
required |
minor_radius
|
float
|
The minor radius [m] of the spheroid. |
required |
spacing
|
float
|
The spacing [m] between successive discs. |
0.0001
|
Returns:
Name | Type | Description |
---|---|---|
rv_pos |
iterable[ndarray]
|
An interable of vectors of the 3D positions of the centre of each disc that defines the spheroid. Each vector has three values corresponding to the x, y, and z coordinates [m] of the disc centre. |
rv_tan |
iterable[ndarray]
|
An interable of unit vectors of the tangent to the target body axis at
the points given in |
a |
iterable
|
The radii [m] of the discs that define the spheroid. |
Source code in src/echosms/dwbautils.py
echosms.ESModel()
Bases: ScatterModelBase
Elastic sphere (ES) scattering model.
This class calculates acoustic backscatter from elastic spheres.
Source code in src/echosms/esmodel.py
calculate_ts(data, expand=False, inplace=False, multiprocess=False, progress=False)
Calculate the target strength (TS) for many parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Pandas DataFrame, Xarray DataArray or dict
|
Requirements for the different input data types are:
|
required |
multiprocess
|
bool
|
Split the ts calculation across CPU cores. Multiprocessing is currently provided by
mapply with little customisation. For more
sophisticated uses it may be preferred to use a multiprocessing package of your choice
directly on the |
False
|
expand
|
bool
|
Only applicable if |
False
|
inplace
|
bool
|
Only applicable if |
False
|
progress
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
None, list[float], Series, or DataFrame
|
The return type and value are determined by the type of the input variable (
|
Source code in src/echosms/scattermodelbase.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
calculate_ts_single(medium_c, medium_rho, a, f, target_longitudinal_c, target_transverse_c, target_rho, validate_parameters=True, **kwargs)
Calculate the backscatter from an elastic sphere for one set of parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
medium_c
|
float
|
Sound speed in the fluid medium surrounding the sphere [m/s]. |
required |
medium_rho
|
float
|
Density of the fluid medium surrounding the sphere [kg/m³]. |
required |
a
|
float
|
Radius of the sphere [m]. |
required |
f
|
float
|
Frequency to calculate the scattering at [Hz]. |
required |
target_longitudinal_c
|
float
|
Longitudinal sound speed in the material inside the sphere [m/s]. |
required |
target_transverse_c
|
float
|
Transverse sound speed in the material inside the sphere [m/s]. |
required |
target_rho
|
float
|
Density of the material inside the sphere [kg/m³]. |
required |
validate_parameters
|
bool
|
Whether to validate the model parameters. |
True
|
Returns:
Type | Description |
---|---|
float
|
The target strength (re 1 m²) of the sphere [dB]. |
Notes
The class implements the code in MacLennan (1981).
References
MacLennan, D. N. (1981). The Theory of Solid Spheres as Sonar Calibration Targets. Scottish Fisheries Research Report Number 22. Department of Agriculture and Fisheries for Scotland.
Source code in src/echosms/esmodel.py
validate_parameters(params)
Validate the model parameters.
See here for calling details.
Source code in src/echosms/esmodel.py
echosms.HPModel()
Bases: ScatterModelBase
High-pass (HP) scattering model.
Source code in src/echosms/hpmodel.py
calculate_ts(data, expand=False, inplace=False, multiprocess=False, progress=False)
Calculate the target strength (TS) for many parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Pandas DataFrame, Xarray DataArray or dict
|
Requirements for the different input data types are:
|
required |
multiprocess
|
bool
|
Split the ts calculation across CPU cores. Multiprocessing is currently provided by
mapply with little customisation. For more
sophisticated uses it may be preferred to use a multiprocessing package of your choice
directly on the |
False
|
expand
|
bool
|
Only applicable if |
False
|
inplace
|
bool
|
Only applicable if |
False
|
progress
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
None, list[float], Series, or DataFrame
|
The return type and value are determined by the type of the input variable (
|
Source code in src/echosms/scattermodelbase.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
calculate_ts_single(shape, medium_c, a, f, boundary_type, medium_rho=None, target_c=None, target_rho=None, theta=None, L=None, rho_c=None, irregular=False, validate_parameters=True, **kwargs)
Calculate the backscatter using the high pass model for one set of parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape
|
str
|
The shape to model. Must be one of the shapes given in the |
required |
medium_c
|
float
|
Sound speed in the fluid medium surrounding the target [m/s]. |
required |
medium_rho
|
float
|
Density of the fluid medium surrounding the target [kg/m³]. Not required when
|
None
|
target_c
|
float
|
Longitudinal sound speed in the material inside the target [m/s]. Not required when
|
None
|
target_rho
|
float
|
Density of the material inside the target [kg/m³]. Not required when
|
None
|
a
|
float
|
Radius of the sphere, length of semi-minor axis of the prolate spheriod, or cylindrical radius of the straight or bent cylinder [m]. |
required |
f
|
float
|
Frequency to calculate the scattering at [Hz]. |
required |
boundary_type
|
str
|
The boundary type for the model. |
required |
theta
|
float
|
Pitch angle to calculate the scattering as per the echoSMs coordinate system [°]. Only required for the straight cylinder shape. |
None
|
L
|
float
|
Total length of the prolate spheroid and straight cylinder, or arc length of the bent cylinder [m]. Only required for prolate spheroid, cylinder, and bent cylinder shapes. |
None
|
rho_c
|
float
|
Radius of curvature of the axis of the bent cylinder [m]. Only required for the bent cylinder shape. |
None
|
irregular
|
Set to |
False
|
|
validate_parameters
|
bool
|
Whether to validate the model parameters. |
True
|
Returns:
Type | Description |
---|---|
float
|
The target strength (re 1 m²) of the sphere [dB]. |
Notes
The class implements the high-pass model in Stanton (1989) for spheres, prolate spheroids, cylinders, and bent cylinders with fluid filled, elastic, and rigid fixed boundary conditions. There are several restrictions on valid input parameters, so a careful reading of Stanton (1989) is recommended.
The theta angle convention used in Stanton (1989) is the same as the echoSMs coordinate system convention.
Stanton (1989) also provides parameters for gas-filled shapes, but more prior knowledge is required about the gas for useful results (e.g., damping characteristics of the gas and medium) and these have not been implemented here. There are many other models available that accurately model gas-filled shapes such that the lack of the high-pass gas-filled model should not be missed.
References
Stanton, T. K. (1989). Simple approximate formulas for backscattering of sound by spherical and elongated objects. The Journal of the Acoustical Society of America, 86(4), 1499-1510. https://doi.org/10.1121/1.398711
Source code in src/echosms/hpmodel.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
validate_parameters(params)
Validate the model parameters.
See here for calling details.
Source code in src/echosms/hpmodel.py
echosms.KAModel()
Bases: ScatterModelBase
Kirchhoff approximation (KA) scattering model.
This class calculates acoustic scatter from arbitrary surfaces.
Source code in src/echosms/kamodel.py
calculate_ts(data, expand=False, inplace=False, multiprocess=False, progress=False)
Calculate the target strength (TS) for many parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Pandas DataFrame, Xarray DataArray or dict
|
Requirements for the different input data types are:
|
required |
multiprocess
|
bool
|
Split the ts calculation across CPU cores. Multiprocessing is currently provided by
mapply with little customisation. For more
sophisticated uses it may be preferred to use a multiprocessing package of your choice
directly on the |
False
|
expand
|
bool
|
Only applicable if |
False
|
inplace
|
bool
|
Only applicable if |
False
|
progress
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
None, list[float], Series, or DataFrame
|
The return type and value are determined by the type of the input variable (
|
Source code in src/echosms/scattermodelbase.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
calculate_ts_single(medium_c, theta, phi, f, mesh, boundary_type, validate_parameters=True, **kwargs)
Calculate the scatter using the ka model for one set of parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
medium_c
|
float
|
Sound speed in the fluid medium surrounding the target [m/s]. |
required |
theta
|
float
|
Pitch angle to calculate the scattering as per the echoSMs coordinate system [°]. |
required |
phi
|
float
|
Roll angle to calculate the scattering as per the echoSMs coordinate system [°]. |
required |
f
|
float
|
Frequency to calculate the scattering at [Hz]. |
required |
mesh
|
Any
|
The triangular mesh that defines the scattering surface. This parameter must provide attributes with names of:
A suitable library for creating and manipulating triangular meshes is trimesh. |
required |
boundary_type
|
str
|
The boundary type. Supported types are given in the |
required |
validate_parameters
|
bool
|
Whether to validate the model parameters. |
True
|
Returns:
Type | Description |
---|---|
float
|
The target strength (re 1 m²) of the target [dB]. |
Notes
The class implements the code in Foote (1985).
References
Foote, K. G. (1985). Rather-high-frequency sound scattering of swimbladdered fish. The Journal of the Acoustical Society of America, 78(2), 688–700. https://doi.org/10.1121/1.392438
Source code in src/echosms/kamodel.py
validate_parameters(params)
KRM model & utilities
echosms.KRMModel()
Bases: ScatterModelBase
Kirchhoff ray mode (KRM) scattering model.
Source code in src/echosms/krmmodel.py
calculate_ts(data, expand=False, inplace=False, multiprocess=False, progress=False)
Calculate the target strength (TS) for many parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Pandas DataFrame, Xarray DataArray or dict
|
Requirements for the different input data types are:
|
required |
multiprocess
|
bool
|
Split the ts calculation across CPU cores. Multiprocessing is currently provided by
mapply with little customisation. For more
sophisticated uses it may be preferred to use a multiprocessing package of your choice
directly on the |
False
|
expand
|
bool
|
Only applicable if |
False
|
inplace
|
bool
|
Only applicable if |
False
|
progress
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
None, list[float], Series, or DataFrame
|
The return type and value are determined by the type of the input variable (
|
Source code in src/echosms/scattermodelbase.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
calculate_ts_single(medium_c, medium_rho, theta, f, organism, validate_parameters=True, **kwargs)
Calculate the scatter using the Kirchhoff ray mode model for one set of parameters.
Warning
The low ka part of this model has not yet been verified to give correct results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
medium_c
|
float
|
Sound speed in the fluid medium surrounding the target [m/s]. |
required |
medium_rho
|
float
|
Density in the fluid medium surrounding the target [kg/m³] |
required |
theta
|
float
|
Pitch angle to calculate the scattering at, as per the echoSMs coordinate system [°]. |
required |
f
|
float
|
Frequency to calculate the scattering at [Hz]. |
required |
organism
|
The shapes that make up the model. This is typically a shape for the body and zero or more enclosed shapes that repesent internal parts of the organism. |
required | |
validate_parameters
|
bool
|
Whether to validate the model parameters. |
True
|
Returns:
Type | Description |
---|---|
float
|
The target strength (re 1 m²) of the target [dB]. |
Notes
The class implements the code in Clay & Horne (1994) and when ka < 0.15 uses Clay (1992).
References
Clay, C. S., & Horne, J. K. (1994). Acoustic models of fish: The Atlantic cod (Gadus morhua). The Journal of the Acoustical Society of America, 96(3), 1661–1668. https://doi.org/10.1121/1.410245
Clay, C. S. (1992). Composite ray-mode approximations for backscattered sound from gas-filled cylinders and swimbladders. The Journal of the Acoustical Society of America, 92(4), 2173–2180. https://doi.org/10.1121/1.405211
Source code in src/echosms/krmmodel.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
validate_parameters(params)
Validate the model parameters.
See here for calling details.
Source code in src/echosms/krmmodel.py
echosms.KRMdata()
Example datasets for the KRM model.
Source code in src/echosms/krmdata.py
as_dict()
KRM model shapes as a dict.
Returns:
Type | Description |
---|---|
dict
|
All the KRM model shapes. The dataset name is the dict key and the value is an instance
of |
model(name)
KRM model shape with requested name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of a KRM model shape. |
required |
Returns:
Type | Description |
---|---|
KRMorganism
|
An instance of |
Source code in src/echosms/krmdata.py
names()
ts(name)
staticmethod
KRM model ts from model name
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of a KRM model shape. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The TS (re 1 m²) for some default model parameters [dB] or None if no TS data are available. |
Source code in src/echosms/krmdata.py
echosms.KRMorganism(name, source, body, inclusions)
dataclass
KRM body and swimbladder model shape.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
A name for the organism. |
source |
str
|
A link to or description of the source of the organism data. |
body |
KRMshape
|
The shape that represents the organism's body. |
inclusions |
List[KRMshape]
|
The shapes that are internal to the organism (e.g., swimbladder, backbone, etc) |
echosms.KRMshape(boundary, x, w, z_U, z_L, c, rho)
dataclass
KRM shape and property class.
Attributes:
Name | Type | Description |
---|---|---|
shape_type |
The shape bounday condition - either |
|
x |
ndarray
|
The x-axis coordinates [m]. |
w |
ndarray
|
Width of the shape [m]. |
z_U |
ndarray
|
Distance from the axis to the upper surface of the shape [m]. |
z_L |
ndarray
|
Distance from the axis to the lower surface of the shape [m]. |
c |
float
|
Sound speed in the shape [m/s]. |
rho |
float
|
Density of the shape material [kg/m³]. |
length()
volume()
Volume of the shape.
Returns:
Type | Description |
---|---|
float
|
The volume of the shape [m³]. |
Source code in src/echosms/krmdata.py
echosms.MSSModel()
Bases: ScatterModelBase
Modal series solution (MSS) scattering model.
This class calculates acoustic scatter from spheres and shells with various
boundary conditions, as listed in the boundary_types
class attribute.
Source code in src/echosms/mssmodel.py
calculate_ts(data, expand=False, inplace=False, multiprocess=False, progress=False)
Calculate the target strength (TS) for many parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Pandas DataFrame, Xarray DataArray or dict
|
Requirements for the different input data types are:
|
required |
multiprocess
|
bool
|
Split the ts calculation across CPU cores. Multiprocessing is currently provided by
mapply with little customisation. For more
sophisticated uses it may be preferred to use a multiprocessing package of your choice
directly on the |
False
|
expand
|
bool
|
Only applicable if |
False
|
inplace
|
bool
|
Only applicable if |
False
|
progress
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
None, list[float], Series, or DataFrame
|
The return type and value are determined by the type of the input variable (
|
Source code in src/echosms/scattermodelbase.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
calculate_ts_single(medium_c, medium_rho, a, f, boundary_type, target_c=None, target_rho=None, shell_c=None, shell_rho=None, shell_thickness=None, validate_parameters=True, **kwargs)
Calculate the scatter using the mss model for one set of parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
medium_c
|
float
|
Sound speed in the fluid medium surrounding the target [m/s]. |
required |
medium_rho
|
float
|
Density of the fluid medium surrounding the target [kg/m³]. |
required |
a
|
float
|
Radius of the spherical target [m]. |
required |
f
|
float
|
Frequency to calculate the scattering at [Hz]. |
required |
boundary_type
|
str
|
The boundary type. Supported types are given in the |
required |
target_c
|
float
|
Sound speed in the fluid inside the sphere [m/s].
Only required for |
None
|
target_rho
|
float
|
Density of the fluid inside the sphere [kg/m³].
Only required for |
None
|
shell_c
|
float
|
Sound speed in the spherical shell [m/s].
Only required for |
None
|
shell_rho
|
float
|
Density in the spherical shell [kg/m³].
Only required for |
None
|
shell_thickness
|
float
|
Thickness of the spherical shell [m]. This value is subtracted from |
None
|
validate_parameters
|
bool
|
Whether to validate the model parameters. |
True
|
Returns:
Type | Description |
---|---|
float
|
The target strength (re 1 m²) of the target [dB]. |
Notes
The class implements the code in Section A.1 of Jech et al. (2015).
References
Jech, J.M., Horne, J.K., Chu, D., Demer, D.A., Francis, D.T.I., Gorska, N., Jones, B., Lavery, A.C., Stanton, T.K., Macaulay, G.J., Reeder, D.B., Sawada, K., 2015. Comparisons among ten models of acoustic backscattering used in aquatic ecosystem research. Journal of the Acoustical Society of America 138, 3742–3764. https://doi.org/10.1121/1.4937607
Source code in src/echosms/mssmodel.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
validate_parameters(params)
Validate the model parameters.
See here for calling details.
Source code in src/echosms/mssmodel.py
echosms.PSMSModel()
Bases: ScatterModelBase
Prolate spheroidal modal series (PSMS) scattering model.
Note
The fluid filled boundary type implementation is under development and is of limited use at the moment.
Source code in src/echosms/psmsmodel.py
calculate_ts(data, expand=False, inplace=False, multiprocess=False, progress=False)
Calculate the target strength (TS) for many parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Pandas DataFrame, Xarray DataArray or dict
|
Requirements for the different input data types are:
|
required |
multiprocess
|
bool
|
Split the ts calculation across CPU cores. Multiprocessing is currently provided by
mapply with little customisation. For more
sophisticated uses it may be preferred to use a multiprocessing package of your choice
directly on the |
False
|
expand
|
bool
|
Only applicable if |
False
|
inplace
|
bool
|
Only applicable if |
False
|
progress
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
None, list[float], Series, or DataFrame
|
The return type and value are determined by the type of the input variable (
|
Source code in src/echosms/scattermodelbase.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
calculate_ts_single(medium_c, medium_rho, a, b, theta, f, boundary_type, target_c=None, target_rho=None, validate_parameters=True)
Prolate spheroid modal series (PSMS) solution model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
medium_c
|
float
|
Sound speed in the fluid medium surrounding the target [m/s]. |
required |
medium_rho
|
float
|
Density of the fluid medium surrounding the target [kg/m³]. |
required |
a
|
float
|
Prolate spheroid major axis radius [m]. |
required |
b
|
float
|
Prolate spheroid minor axis radius [m]. |
required |
theta
|
float
|
Pitch angle to calculate the scattering as per the echoSMs coordinate system [°]. |
required |
f
|
float
|
Frequency to calculate the scattering at [Hz]. |
required |
boundary_type
|
str
|
The model type. Supported model types are given in the |
required |
target_c
|
float
|
Sound speed in the fluid inside the target [m/s].
Only required for |
None
|
target_rho
|
float
|
Density of the fluid inside the target [kg/m³].
Only required for |
None
|
validate_parameters
|
bool
|
Whether to validate the input parameters. |
True
|
Returns:
Type | Description |
---|---|
float
|
The target strength (re 1 m²) of the target [dB]. |
Notes
The backscattered target strength of a pressure release or fluid-filled prolate spheroid is calculated using the PSMS method of Furusawa (1988) and corrections in Furusawa et al. (1994).
References
Furusawa, M. (1988). "Prolate spheroidal models for predicting general trends of fish target strength," J. Acoust. Soc. Jpn. 9, 13-24. Furusawa, M., Miyanohana, Y., Ariji, M., and Sawada, Y. (1994). “Prediction of krill target strength by liquid prolate spheroid model,” Fish. Sci., 60, 261-265.
Source code in src/echosms/psmsmodel.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
validate_parameters(params)
Validate the model parameters.
See here for calling details.
Source code in src/echosms/psmsmodel.py
Utilities
echosms.BenchmarkData()
Convenient interface to the benchmark dataset.
This dataset contains the TS results from Jech et al. (2015).
Attributes:
Name | Type | Description |
---|---|---|
angle_dataset |
Pandas DataFrame
|
The angle dataset from the benchmark model runs. |
freq_dataset |
Pandas DataFrame
|
The frequency dataset from the benchmark model runs. |
Notes
The column names in the source benchmark files have been changed to be the same as those used in the [referencemodels] model definitions.
References
Jech, J.M., Horne, J.K., Chu, D., Demer, D.A., Francis, D.T.I., Gorska, N., Jones, B., Lavery, A.C., Stanton, T.K., Macaulay, G.J., Reeder, D.B., Sawada, K., 2015. Comparisons among ten models of acoustic backscattering used in aquatic ecosystem research. Journal of the Acoustical Society of America 138, 3742-3764. https://doi.org/10.1121/1.4937607
Source code in src/echosms/benchmarkdata.py
echosms.ReferenceModels()
Provide access to reference scattering model parameters.
Reference models are the models and parameters defined in Jech et al. (2015). The parameters are stored in a TOML-formatted file in the echoSMs repository and this class provides easy access to the data in that file. Additional reference models may be defined in the future and added to the TOML file (for example, entries have been added for all known calibration sphere sizes).
Attributes:
Name | Type | Description |
---|---|---|
definitions |
dict
|
A dict representation of the |
Raises:
Type | Description |
---|---|
TOMLDecodeError
|
If the |
KeyError
|
If the |
References
Jech, J.M., Horne, J.K., Chu, D., Demer, D.A., Francis, D.T.I., Gorska, N., Jones, B., Lavery, A.C., Stanton, T.K., Macaulay, G.J., Reeder, D.B., Sawada, K., 2015. Comparisons among ten models of acoustic backscattering used in aquatic ecosystem research. Journal of the Acoustical Society of America 138, 3742–3764. https://doi.org/10.1121/1.4937607
Source code in src/echosms/referencemodels.py
names()
Names of all model definitions.
Returns:
Type | Description |
---|---|
iterable of str
|
All model names in the |
parameters(name)
Model parameters for a particular model.
Model parameters are a subset of the model specification where the metadata items have been removed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of a model in the |
required |
Returns:
Type | Description |
---|---|
dict
|
The model parameters for the requested model or an empty set if no model with that name. |
Source code in src/echosms/referencemodels.py
specification(name)
Model definitions for a particular model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of a model in the |
required |
Returns:
Type | Description |
---|---|
dict
|
The model definitions for the requested model or an empty set if no model with that name. |
Source code in src/echosms/referencemodels.py
echosms.JechEtAlData()
Simple access to all model results in Jech et al (2015).
Attributes:
Name | Type | Description |
---|---|---|
data |
dict[DataFrame]
|
One entry in the dict for each model results file. |
data_directory |
Path
|
The directory containing the model results files. |
References
Jech, J.M., Horne, J.K., Chu, D., Demer, D.A., Francis, D.T.I., Gorska, N., Jones, B., Lavery, A.C., Stanton, T.K., Macaulay, G.J., Reeder, D.B., Sawada, K., 2015. Comparisons among ten models of acoustic backscattering used in aquatic ecosystem research. Journal of the Acoustical Society of America 138, 3742-3764. https://doi.org/10.1121/1.4937607
Source code in src/echosms/jechetaldata.py
echosms.utils
Miscellaneous utility functions.
Neumann(m)
Neumann number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
The input integer. |
required |
Returns:
Type | Description |
---|---|
int
|
The Neumann number. |
as_dataarray(params, no_expand=[])
Convert model parameters from dict form to a Xarray DataArray.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
dict
|
The model parameters. |
required |
no_expand
|
list
|
Key values of the non-expandable model parameters in |
[]
|
Returns:
Type | Description |
---|---|
DataArray
|
Returns a multi-dimensional DataArray generated from the Cartesian product of all
expandable items in the input dict. Non-expandable items are added to the DataArray
attrs property. Expandable items are those that can be sensibly expanded into
DataArray coordinates. Not all models have non-expandable items.
The array is named |
Source code in src/echosms/utils.py
as_dataframe(params, no_expand=[])
Convert model parameters from dict form to a Pandas DataFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
dict
|
The model parameters. |
required |
no_expand
|
list
|
Key values of the non-expandable model parameters in |
[]
|
Returns:
Type | Description |
---|---|
DataFrame
|
Returns a Pandas DataFrame generated from the Cartesian product of all expandable items in the input dict. DataFrame column names are obtained from the dict keys. Non-expandable items are added to the DataFrame attrs property. Expandable items are those that can be sensibly expanded into DataFrame columns. Not all models have non-expandable items. |
Source code in src/echosms/utils.py
as_dict(params)
Convert model parameters from DataFrame or DataArray to dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
dict | DataFrame | DataArray
|
The model parameters |
required |
Raises:
Type | Description |
---|---|
TypeError:
|
If the input data type is not supported. |
Returns:
Type | Description |
---|---|
dict
|
A dict containing the model parameters. |
Source code in src/echosms/utils.py
h1(n, z, derivative=False)
Spherical Hankel function of the first kind or its' derivative.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
int
|
Order (n ≥ 0). |
required |
z
|
float
|
Argument of the Hankel function. |
required |
derivative
|
if True, the value of the derivative (rather than the function itself) is returned. |
False
|
Returns:
Type | Description |
---|---|
complex
|
Value of the spherical Hankel function |
Raises:
Type | Description |
---|---|
ValueError
|
For negative n values. |
Notes
The value of the Hankel function is calculated from spherical Bessel functions [1].
The derivative is computed from spherical Hankel functions [2].
Source code in src/echosms/utils.py
pro_ang1(m, n, c, eta, norm=False)
Prolate spheroidal angular function of the first kind and derivative.
Calculates the prolate spheroidal angular function of the first kind and its'
derivative with respect to eta
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
The order parameter (≥ 0) |
required |
n
|
int
|
The degree parameter (≥ |
required |
c
|
float
|
The size parameter. |
required |
eta
|
float
|
The angular coordinate, η, where |η| ≤ 1. |
required |
norm
|
If |
False
|
Returns:
Type | Description |
---|---|
tuple[float, float]
|
The value of the prolate spheroidal angular function and its' derivative. |
Notes
This method uses the prolate spheroidal wave function code for non complex
arguments (van Buren & Boisvert, 2002, and van Buren & Boisvert, 2024), available on
github. This code is in Fortran90
and was interfaced to Python using numpy.f2py
then wrapped with the current method to
provide a similar calling convention as the Scipy function of the same name.
References
Van Buren, A. L., & Boisvert, J. E. (2002). Accurate calculation of prolate spheroidal radial functions of the first kind and their first derivatives. Quarterly of Applied Mathematics, 60(3), 589-599. https://doi.org/10.1090/qam/1914443
Van Buren, A. L., & Boisvert, J. E. (2004). Improved Calculation of Prolate Spheroidal Radial Functions of the Second Kind and Their First Derivatives. Quarterly of Applied Mathematics, 62(3), 493-507. https://doi.org/10.1090/qam/2086042
Source code in src/echosms/utils.py
pro_rad1(m, n, c, xi)
Prolate spheroidal radial function of the first kind and derivative.
Calculates the prolate spheroidal radial function of the first kind and its'
derivative with respect to xi
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
The order parameter (≥ 0). |
required |
n
|
int
|
The degree parameter (≥ |
required |
c
|
float
|
The size parameter. |
required |
xi
|
float
|
The radial coordinate, ξ, where ξ ≥ 1. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
The value of the prolate spheroidal radial function and its' derivative. |
Notes
This method uses the prolate spheroidal wave function code for non complex
arguments (van Buren & Boisvert, 2002, and van Buren & Boisvert, 2024), available on
github. This code is in Fortran90
and was interfaced to Python using numpy.f2py
then wrapped with the current method to
provide a similar calling convention as the Scipy function of the same name.
References
Van Buren, A. L., & Boisvert, J. E. (2002). Accurate calculation of prolate spheroidal radial functions of the first kind and their first derivatives. Quarterly of Applied Mathematics, 60(3), 589-599. https://doi.org/10.1090/qam/1914443
Van Buren, A. L., & Boisvert, J. E. (2004). Improved Calculation of Prolate Spheroidal Radial Functions of the Second Kind and Their First Derivatives. Quarterly of Applied Mathematics, 62(3), 493-507. https://doi.org/10.1090/qam/2086042
Source code in src/echosms/utils.py
pro_rad2(m, n, c, xi)
Prolate spheroidal radial function of the second kind and derivative.
Calculates the prolate spheroidal radial function of the second kind and its'
derivative with respect to xi
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
The order parameter (≥ 0). |
required |
n
|
int
|
The degree parameter (≥ |
required |
c
|
float
|
The size parameter. |
required |
xi
|
float
|
The radial coordinate, ξ, where ξ ≥ 1. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
The value of the prolate spheroidal radial function and its' derivative. |
Notes
This method uses the prolate spheroidal wave function code for non complex
arguments (van Buren & Boisvert, 2002, and van Buren & Boisvert, 2024), available on
github. This code is in Fortran90
and was interfaced to Python using numpy.f2py
then wrapped with the current method to
provide a similar calling convention as the Scipy function of the same name.
References
Van Buren, A. L., & Boisvert, J. E. (2002). Accurate calculation of prolate spheroidal radial functions of the first kind and their first derivatives. Quarterly of Applied Mathematics, 60(3), 589-599. https://doi.org/10.1090/qam/1914443
Van Buren, A. L., & Boisvert, J. E. (2004). Improved Calculation of Prolate Spheroidal Radial Functions of the Second Kind and Their First Derivatives. Quarterly of Applied Mathematics, 62(3), 493-507. https://doi.org/10.1090/qam/2086042
Source code in src/echosms/utils.py
spherical_jnpp(n, z)
Second derivative of the spherical Bessel function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
int
|
Order (n ≥ 0) |
required |
z
|
float
|
Argument of the Bessel function. |
required |
Returns:
Type | Description |
---|---|
float
|
The second derivative of the spherical Bessel function. |
Source code in src/echosms/utils.py
split_dict(d, s)
Split a dict into two dicts based on a list of keys.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d
|
dict
|
Dict to be split. |
required |
s
|
list
|
List of dict keys to use for splitting |
required |
Returns:
Type | Description |
---|---|
tuple(dict, dict)
|
The |
Source code in src/echosms/utils.py
theoretical_Sa(ts, eba, r, nautical=False)
Theoretical area backscattering strength (Sₐ) of a target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ts
|
float | ndarray
|
The target strength of the object [dB re 1 m²]. |
required |
eba
|
float
|
The equivalent beam angle of the transducer [dB re 1 sr]. |
required |
r
|
float
|
The range from the transducer to the target [m]. Used for acoustic beam spreading. |
required |
nautical
|
If |
False
|
Returns:
Type | Description |
---|---|
float | ndarray
|
The theoretical Sₐ [dB re 1 m² m⁻²] or SA [dB re 1 m² nmi⁻²] of the input |
Raises:
Type | Description |
---|---|
ValueError
|
If an input value is out of bounds. |
Notes
While the calculation is valid for any target, the theoretical area strengths are most relevant when calibrating an echosounder using a sphere. The difference between the theoretical and measured can be used to calculate the calibration gain for an echosounder (when the sphere is on-axis).
Source code in src/echosms/utils.py
wavelength(c, f)
Calculate the acoustic wavelength.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c
|
float
|
Sound speed [m/s] |
required |
f
|
float
|
Frequency [Hz] |
required |
Returns:
Type | Description |
---|---|
float
|
The acoustic wavelength [m]. |
Source code in src/echosms/utils.py
wavenumber(c, f)
Calculate the acoustic wavenumber.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c
|
float
|
Sound speed [m/s] |
required |
f
|
float
|
Frequency [Hz] |
required |
Returns:
Type | Description |
---|---|
float
|
The acoustic wavenumber [m⁻¹]. |