openstb-simulator 0.5.0__tar.gz

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 (85) hide show
  1. openstb_simulator-0.5.0/.editorconfig +21 -0
  2. openstb_simulator-0.5.0/.gitignore +26 -0
  3. openstb_simulator-0.5.0/.readthedocs.yaml +21 -0
  4. openstb_simulator-0.5.0/LICENSES/BSD-2-Clause-Patent.txt +19 -0
  5. openstb_simulator-0.5.0/LICENSES/CC0-1.0.txt +121 -0
  6. openstb_simulator-0.5.0/PKG-INFO +42 -0
  7. openstb_simulator-0.5.0/README.md +47 -0
  8. openstb_simulator-0.5.0/docs/examples/simple_points.md +247 -0
  9. openstb_simulator-0.5.0/docs/getting_started/install.md +37 -0
  10. openstb_simulator-0.5.0/docs/included_plugins/index.md +132 -0
  11. openstb_simulator-0.5.0/docs/index.md +10 -0
  12. openstb_simulator-0.5.0/examples/README.md +16 -0
  13. openstb_simulator-0.5.0/examples/cli/simple_points/README.md +28 -0
  14. openstb_simulator-0.5.0/examples/cli/simple_points/plot_results.py +40 -0
  15. openstb_simulator-0.5.0/examples/cli/simple_points/simple_points.toml +218 -0
  16. openstb_simulator-0.5.0/examples/scripts/simple_points/README.md +28 -0
  17. openstb_simulator-0.5.0/examples/scripts/simple_points/plot_results.py +40 -0
  18. openstb_simulator-0.5.0/examples/scripts/simple_points/run_with_mpi.sh +10 -0
  19. openstb_simulator-0.5.0/examples/scripts/simple_points/simulate.py +327 -0
  20. openstb_simulator-0.5.0/extra/typing_stubs/dask_mpi.pyi +18 -0
  21. openstb_simulator-0.5.0/extra/typing_stubs/quaternionic.pyi +35 -0
  22. openstb_simulator-0.5.0/extra/typing_stubs/scipy/interpolate/__init__.pyi +19 -0
  23. openstb_simulator-0.5.0/extra/typing_stubs/scipy/io/__init__.pyi +17 -0
  24. openstb_simulator-0.5.0/mkdocs.yaml +80 -0
  25. openstb_simulator-0.5.0/pyproject.toml +223 -0
  26. openstb_simulator-0.5.0/src/openstb/simulator/__init__.py +15 -0
  27. openstb_simulator-0.5.0/src/openstb/simulator/__main__.py +7 -0
  28. openstb_simulator-0.5.0/src/openstb/simulator/cli/__init__.py +17 -0
  29. openstb_simulator-0.5.0/src/openstb/simulator/cli/run.py +82 -0
  30. openstb_simulator-0.5.0/src/openstb/simulator/cluster/__init__.py +0 -0
  31. openstb_simulator-0.5.0/src/openstb/simulator/cluster/dask_local.py +108 -0
  32. openstb_simulator-0.5.0/src/openstb/simulator/cluster/dask_mpi.py +115 -0
  33. openstb_simulator-0.5.0/src/openstb/simulator/config_loader/__init__.py +0 -0
  34. openstb_simulator-0.5.0/src/openstb/simulator/config_loader/toml.py +182 -0
  35. openstb_simulator-0.5.0/src/openstb/simulator/distortion/__init__.py +0 -0
  36. openstb_simulator-0.5.0/src/openstb/simulator/distortion/beampattern.py +141 -0
  37. openstb_simulator-0.5.0/src/openstb/simulator/distortion/doppler.py +78 -0
  38. openstb_simulator-0.5.0/src/openstb/simulator/distortion/environmental.py +174 -0
  39. openstb_simulator-0.5.0/src/openstb/simulator/environment/__init__.py +0 -0
  40. openstb_simulator-0.5.0/src/openstb/simulator/environment/invariant.py +42 -0
  41. openstb_simulator-0.5.0/src/openstb/simulator/plugin/__init__.py +0 -0
  42. openstb_simulator-0.5.0/src/openstb/simulator/plugin/abc.py +809 -0
  43. openstb_simulator-0.5.0/src/openstb/simulator/plugin/loader.py +334 -0
  44. openstb_simulator-0.5.0/src/openstb/simulator/plugin/util.py +269 -0
  45. openstb_simulator-0.5.0/src/openstb/simulator/py.typed +0 -0
  46. openstb_simulator-0.5.0/src/openstb/simulator/result_converter/__init__.py +0 -0
  47. openstb_simulator-0.5.0/src/openstb/simulator/result_converter/matlab.py +87 -0
  48. openstb_simulator-0.5.0/src/openstb/simulator/result_converter/numpy.py +69 -0
  49. openstb_simulator-0.5.0/src/openstb/simulator/simulation/__init__.py +0 -0
  50. openstb_simulator-0.5.0/src/openstb/simulator/simulation/points.py +502 -0
  51. openstb_simulator-0.5.0/src/openstb/simulator/system/__init__.py +51 -0
  52. openstb_simulator-0.5.0/src/openstb/simulator/system/ping_times.py +112 -0
  53. openstb_simulator-0.5.0/src/openstb/simulator/system/signal.py +92 -0
  54. openstb_simulator-0.5.0/src/openstb/simulator/system/signal_windows.py +201 -0
  55. openstb_simulator-0.5.0/src/openstb/simulator/system/trajectory.py +128 -0
  56. openstb_simulator-0.5.0/src/openstb/simulator/system/transducer.py +63 -0
  57. openstb_simulator-0.5.0/src/openstb/simulator/target/__init__.py +0 -0
  58. openstb_simulator-0.5.0/src/openstb/simulator/target/points.py +169 -0
  59. openstb_simulator-0.5.0/src/openstb/simulator/travel_time/__init__.py +0 -0
  60. openstb_simulator-0.5.0/src/openstb/simulator/travel_time/iterative.py +146 -0
  61. openstb_simulator-0.5.0/src/openstb/simulator/travel_time/stop_and_hop.py +85 -0
  62. openstb_simulator-0.5.0/src/openstb/simulator/types.py +42 -0
  63. openstb_simulator-0.5.0/src/openstb/simulator/util.py +36 -0
  64. openstb_simulator-0.5.0/tests/cluster/test_dask_local.py +117 -0
  65. openstb_simulator-0.5.0/tests/cluster/test_dask_mpi.py +94 -0
  66. openstb_simulator-0.5.0/tests/distortion/test_beampattern.py +185 -0
  67. openstb_simulator-0.5.0/tests/distortion/test_environmental.py +133 -0
  68. openstb_simulator-0.5.0/tests/environment/test_invariant.py +49 -0
  69. openstb_simulator-0.5.0/tests/system/test_ping_times.py +82 -0
  70. openstb_simulator-0.5.0/tests/system/test_signal.py +105 -0
  71. openstb_simulator-0.5.0/tests/system/test_signal_windows.py +69 -0
  72. openstb_simulator-0.5.0/tests/system/test_trajectory.py +183 -0
  73. openstb_simulator-0.5.0/tests/target/test_points.py +141 -0
  74. openstb_simulator-0.5.0/tests/test_plugin.py +282 -0
  75. openstb_simulator-0.5.0/tests/test_plugin_modules/README.md +10 -0
  76. openstb_simulator-0.5.0/tests/test_plugin_modules/installed/plugin_b.py +11 -0
  77. openstb_simulator-0.5.0/tests/test_plugin_modules/local/plugin_double.py +11 -0
  78. openstb_simulator-0.5.0/tests/test_plugin_modules/local/plugin_triple.py +11 -0
  79. openstb_simulator-0.5.0/tests/test_plugin_modules/local/plugin_triple.x +11 -0
  80. openstb_simulator-0.5.0/tests/test_plugin_modules/registered/multi_a.py +15 -0
  81. openstb_simulator-0.5.0/tests/test_plugin_modules/registered/multi_b.py +15 -0
  82. openstb_simulator-0.5.0/tests/test_plugin_modules/registered/plugin_a.py +15 -0
  83. openstb_simulator-0.5.0/tests/test_util.py +74 -0
  84. openstb_simulator-0.5.0/tests/travel_time/test_iterative.py +115 -0
  85. openstb_simulator-0.5.0/tests/travel_time/test_stop_and_hop.py +67 -0
@@ -0,0 +1,21 @@
1
+ # SPDX-FileCopyrightText: openSTB contributors
2
+ # SPDX-License-Identifier: CC0-1.0
3
+
4
+ # Editor configuration settings.
5
+ #
6
+ # https://editorconfig.org/
7
+ #
8
+ # See the documentation for details on plugins for your editor.
9
+
10
+ root = true
11
+
12
+ [*]
13
+ charset = utf-8
14
+ indent_size = 4
15
+ indent_style = space
16
+ insert_final_newline = false
17
+ max_line_length = 88
18
+ trim_trailing_whitespace = true
19
+
20
+ [*.yaml]
21
+ indent_size = 2
@@ -0,0 +1,26 @@
1
+ # SPDX-FileCopyrightText: openSTB contributors
2
+ # SPDX-License-Identifier: CC0-1.0
3
+
4
+ # Compiled Python files.
5
+ __pycache__/
6
+ *.py[cod]
7
+
8
+ # Packaging artifacts.
9
+ build/
10
+ dist/
11
+ src/openstb/locale
12
+
13
+ # mypy cache of type information.
14
+ .mypy_cache/
15
+
16
+ # Test coverage reports.
17
+ .coverage*
18
+ tests/coverage
19
+
20
+ # Scratch space which Dask may create during testing or running examples.
21
+ dask-scratch-space/
22
+
23
+ # Output of example simulations.
24
+ *.mat
25
+ *.npz
26
+ *.zarr
@@ -0,0 +1,21 @@
1
+ # Read the Docs configuration file for MkDocs projects
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Set the version of Python and other tools you might need
8
+ build:
9
+ os: ubuntu-22.04
10
+ tools:
11
+ python: "3.12"
12
+
13
+ mkdocs:
14
+ configuration: mkdocs.yaml
15
+
16
+ python:
17
+ install:
18
+ - method: pip
19
+ path: .
20
+ extra_requirements:
21
+ - doc
@@ -0,0 +1,19 @@
1
+ Copyright (c) <YEAR> <COPYRIGHT HOLDERS>
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ Subject to the terms and conditions of this license, each copyright holder and contributor hereby grants to those receiving rights under this license a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except for failure to satisfy the conditions of this license) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer this software, where such license applies only to those patent claims, already acquired or hereafter acquired, licensable by such copyright holder or contributor that are necessarily infringed by:
10
+
11
+ (a) their Contribution(s) (the licensed copyrights of copyright holders and non-copyrightable additions of contributors, in source or binary form) alone; or
12
+
13
+ (b) combination of their Contribution(s) with the work of authorship to which such Contribution(s) was added by such copyright holder or contributor, if, at the time the Contribution is added, such addition causes such combination to be necessarily infringed. The patent license shall not apply to any other combinations which include the Contribution.
14
+
15
+ Except as expressly stated above, no rights or licenses from any copyright holder or contributor is granted under this license, whether expressly, by implication, estoppel or otherwise.
16
+
17
+ DISCLAIMER
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
@@ -0,0 +1,42 @@
1
+ Metadata-Version: 2.4
2
+ Name: openstb-simulator
3
+ Version: 0.5.0
4
+ Summary: SONAR simulator
5
+ Project-URL: Homepage, https://openstb.dev
6
+ Project-URL: Documentation, https://docs.openstb.dev
7
+ Project-URL: Repository, https://github.com/openstb/simulator.git
8
+ Project-URL: Issues, https://github.com/openstb/simulator/issues
9
+ Requires-Python: >=3.11
10
+ Requires-Dist: click
11
+ Requires-Dist: cryptography
12
+ Requires-Dist: dask[distributed]
13
+ Requires-Dist: numpy
14
+ Requires-Dist: openstb-i18n
15
+ Requires-Dist: quaternionic
16
+ Requires-Dist: scipy
17
+ Requires-Dist: zarr<4,>=3
18
+ Provides-Extra: dask-diagnostics
19
+ Requires-Dist: dask[diagnostics]; extra == 'dask-diagnostics'
20
+ Provides-Extra: dev
21
+ Requires-Dist: dask[diagnostics]; extra == 'dev'
22
+ Requires-Dist: mkdocs; extra == 'dev'
23
+ Requires-Dist: mkdocs-api-autonav; extra == 'dev'
24
+ Requires-Dist: mkdocs-material; extra == 'dev'
25
+ Requires-Dist: mkdocstrings[python]; extra == 'dev'
26
+ Requires-Dist: mypy; extra == 'dev'
27
+ Requires-Dist: pytest; extra == 'dev'
28
+ Requires-Dist: pytest-cov; extra == 'dev'
29
+ Requires-Dist: requests; extra == 'dev'
30
+ Requires-Dist: ruff; extra == 'dev'
31
+ Provides-Extra: doc
32
+ Requires-Dist: mkdocs; extra == 'doc'
33
+ Requires-Dist: mkdocs-api-autonav; extra == 'doc'
34
+ Requires-Dist: mkdocs-material; extra == 'doc'
35
+ Requires-Dist: mkdocstrings[python]; extra == 'doc'
36
+ Provides-Extra: mpi
37
+ Requires-Dist: dask-mpi; extra == 'mpi'
38
+ Requires-Dist: mpi4py; extra == 'mpi'
39
+ Provides-Extra: tests
40
+ Requires-Dist: pytest; extra == 'tests'
41
+ Requires-Dist: pytest-cov; extra == 'tests'
42
+ Requires-Dist: requests; extra == 'tests'
@@ -0,0 +1,47 @@
1
+ <!--
2
+
3
+ SPDX-FileCopyrightText: openSTB contributors
4
+ SPDX-License-Identifier: BSD-2-Clause-Patent
5
+
6
+ -->
7
+
8
+ openSTB sonar simulation framework
9
+ ==================================
10
+
11
+ The openSTB sonar simulation is a modular framework for simulating the signals received
12
+ by a sonar system. It is currently in the early stages of development, so bugs are to be
13
+ expected.
14
+
15
+
16
+ License
17
+ -------
18
+
19
+ The simulator is available under the BSD-2-Clause plus patent license, the text of which
20
+ can be found in the `LICENSES/` directory or
21
+ [online](https://spdx.org/licenses/BSD-2-Clause-Patent.html). Some of the supporting
22
+ files are under the Creative Commons Zero v1.0 Universal license (effectively public
23
+ domain). Again, the license is available in the `LICENSES/` directory or
24
+ [online](https://spdx.org/licenses/CC0-1.0.html).
25
+
26
+
27
+ Installation
28
+ ------------
29
+
30
+ The openSTB tools are not yet published on PyPI (but will be in the near future). Before
31
+ installing the simulator, you will need to have the companion [internationalisation
32
+ support package](https://github.com/openSTB/i18n) installed in your environment, as well
33
+ as the [hatchling build backend](https://pypi.org/project/hatchling/). You can then run
34
+ `python -m pip install --no-build-isolation .` from the top level of a clone of this
35
+ repository (the `--no-build-isolation` prevents pip trying to build it in a clean
36
+ environment without access to the support packages). Some optional packages may also
37
+ need to be installed for your use case. If you want to use MPI-based parallelisation,
38
+ add the `MPI` option to the install: `python -m pip install --no-build-isolation
39
+ ".[MPI]"`. To also install tools to help develop code for the framework, add the `dev`
40
+ option: `python -m pip install --no-build-isolation ".[dev]"`. You can give both options
41
+ separated by a comma, i.e., `python -m pip install --no-build-isolation ".[MPI,dev]"`.
42
+
43
+
44
+ Running the simulator
45
+ ---------------------
46
+
47
+ See the `examples/` directory for various examples of how to run the simulator.
@@ -0,0 +1,247 @@
1
+ # Simple point simulation
2
+
3
+ For this example, we will configure a simple simulation of some point targets. The
4
+ first part of the configuration needs to specify the type of simulation to run. Here we
5
+ want a point target simulation. We will divide the scene into chunks of 500 targets
6
+ each, allowing us to split the work across multiple CPUs. We set the sampling rate and
7
+ frequency used for basebanding, and finally set a filename for the simulator to store
8
+ its results under.
9
+
10
+ ```toml
11
+ [simulation]
12
+ name = "points"
13
+ result_filename = "simple_points.zarr"
14
+ targets_per_chunk = 500
15
+ sample_rate = 30e3
16
+ baseband_frequency = 110e3
17
+ ```
18
+
19
+ We want to convert the results into a more familiar format for us to use. The simulator
20
+ will store the results in the file named above, but we can configure a result converter
21
+ plugin which is run at the end of the simulation to convert to our desired format (the
22
+ original results file the simulator used will then be removed). We could ask for the
23
+ results to be stored in a NumPy `.npz` file:
24
+
25
+ ``` toml
26
+ [result_converter]
27
+ name = "numpy"
28
+ filename = "simple_points.npz"
29
+ compress = false
30
+ ```
31
+
32
+ Or we could store them in a MATLAB file.
33
+
34
+ ``` toml
35
+ [result_converter]
36
+ name = "matlab"
37
+ filename = "simple_points.mat"
38
+ ```
39
+
40
+ We then need to tell the simulator to use an ad-hoc Dask cluster on our local computer.
41
+ Here we want to use a maximum of 8 workers and up to 40% of the total system memory
42
+ (note that the memory limit is best-effort, not strictly enforced). By default,
43
+ the Dask dashboard is not started, so we have to explicitly state an address it will
44
+ listen on -- in this case port 8787 on the local computer, i.e., http://127.0.0.1:8787.
45
+
46
+ ```toml
47
+ [dask_cluster]
48
+ name = "local"
49
+ workers = 8
50
+ total_memory = 0.4
51
+ dashboard_address = ":8787"
52
+ ```
53
+
54
+ Next, lets specify the details of the transmitter. The coordinate system is x forwards,
55
+ y starboard and z down. The orientation is a quaternion defining how to rotate the
56
+ transducer from its original pose of pointing along the x axis. The value here results
57
+ in it pointing to starboard and 15 degrees below horizontal. We can also specify the
58
+ beampattern of the transducer via a signal distorting plugin.
59
+
60
+ ```toml
61
+ [transmitter]
62
+ name = "generic"
63
+ position = [0, 1.2, 0.3]
64
+ orientation = [0.70105738, 0.09229596, -0.09229596, 0.70105738]
65
+
66
+ [transmitter.beampattern]
67
+ name = "rectangular_beampattern"
68
+ width = 0.015
69
+ height = 0.03
70
+ transmit = true
71
+ receive = false
72
+ frequency = "centre" # only calculate the scale factor at the centre frequency
73
+ ```
74
+
75
+ The transmitter will also need a signal to send, in this case an LFM up-chirp.
76
+
77
+ ```toml
78
+ [signal]
79
+ name = "lfm_chirp"
80
+ f_start = 100e3
81
+ f_stop = 120e3
82
+ duration = 0.015
83
+ rms_spl = 190
84
+ window = {name="tukey", alpha=0.2}
85
+ ```
86
+
87
+ We want to use multiple receivers to form a linear array. These are specified with the
88
+ same options as the transmitter, but we use double square brackets around the header to
89
+ indicate there are multiple values (an *array of tables* in TOML terms). Channel 0 of
90
+ the results will correspond to the first receiver defined in the configuration file and
91
+ so forth.
92
+
93
+ Here we use a 5-element receiver array positioned above the transmitter (remember z is
94
+ down) and with the same orientation.
95
+
96
+ ```toml
97
+ [[receivers]]
98
+ name = "generic"
99
+ position = [-0.1, 1.2, 0.0]
100
+ orientation = [0.70105738, 0.09229596, -0.09229596, 0.70105738]
101
+
102
+ [[receivers]]
103
+ name = "generic"
104
+ position = [-0.05, 1.2, 0.0]
105
+ orientation = [0.70105738, 0.09229596, -0.09229596, 0.70105738]
106
+
107
+ [[receivers]]
108
+ name = "generic"
109
+ position = [0, 1.2, 0.0]
110
+ orientation = [0.70105738, 0.09229596, -0.09229596, 0.70105738]
111
+
112
+ [[receivers]]
113
+ name = "generic"
114
+ position = [0.05, 1.2, 0.0]
115
+ orientation = [0.70105738, 0.09229596, -0.09229596, 0.70105738]
116
+
117
+ [[receivers]]
118
+ name = "generic"
119
+ position = [0.1, 1.2, 0.0]
120
+ orientation = [0.70105738, 0.09229596, -0.09229596, 0.70105738]
121
+ ```
122
+
123
+ The simulator also needs to know the trajectory the system followed. For our purposes,
124
+ an ideal linear trajectory is sufficient.
125
+
126
+ ```toml
127
+ [trajectory]
128
+ name = "linear"
129
+ start_position = [0, 0, 0]
130
+ end_position = [10, 0, 0]
131
+ speed = 1.5
132
+ ```
133
+
134
+ Next we have to specify when the sonar emits pings. Here, we say it will ping every
135
+ 0.2s, starting at the start of the trajectory and with the final ping being at least
136
+ 0.5s before the end of the trajectory.
137
+
138
+ ```toml
139
+ [ping_times]
140
+ name = "constant_interval"
141
+ interval = 0.2
142
+ start_delay = 0
143
+ end_delay = 0.5
144
+ ```
145
+
146
+ Some environmental parameters are needed to perform the simulation. For simplicity, we
147
+ use an invariant (constant) environment with fixed values.
148
+
149
+ ```toml
150
+ [environment]
151
+ name = "invariant"
152
+ salinity = 14.5
153
+ sound_speed = 1480
154
+ temperature = 11.2
155
+ ```
156
+
157
+ Now lets define some targets to simulate. Like with the receivers, this is an array of
158
+ tables.
159
+
160
+ First, a rectangle with points randomly scattered within it to achieve a desired
161
+ density. Remember that z is down, so a normal with a negative z component means the
162
+ normal is pointing up. The reflectivity is the fraction of the incident amplitude that
163
+ is reflected back to the sonar.
164
+
165
+ ```toml
166
+ [[targets]]
167
+ name = "random_point_rectangle"
168
+ seed = 10671
169
+ Dx = 5
170
+ Dy = 120
171
+ centre = [5, 75, 10]
172
+ normal = [0, 0, -1]
173
+ point_density = 10
174
+ reflectivity = 0.06
175
+ ```
176
+
177
+ And then lets add a single target at a specific position with a much stronger echo.
178
+
179
+ ```toml
180
+ [[targets]]
181
+ name = "single_point"
182
+ position = [5, 40, 10]
183
+ reflectivity = 10
184
+ ```
185
+
186
+ One of the key parts of a simulation is to calculate the two-way travel times, i.e., the
187
+ time it takes the acoustic wave to reach a target and scatter back to a receiver. Here,
188
+ we want to use the stop-and-hop approximation to simplify the calculation.
189
+
190
+ ```toml
191
+ [travel_time]
192
+ name = "stop_and_hop"
193
+ ```
194
+
195
+ Various distortions can be applied to the acoustic waves. This is also an array of
196
+ plugins. Lets start by adding some energy loss due to geometric spreading (here we set
197
+ the power parameter for spherical spreading) and also due to acoustic attenuation.
198
+
199
+ ```toml
200
+ [[distortion]]
201
+ name = "geometric_spreading"
202
+ power = 1
203
+
204
+ [[distortion]]
205
+ name = "anslie_mccolm_attenuation"
206
+ frequency = "centre"
207
+ ```
208
+
209
+ Finally, lets configure the beampattern of the receivers. We could have included this
210
+ with each receiver definition above, but since we want the same for all receivers it is
211
+ easier to define this as a general plugin.
212
+
213
+ ```toml
214
+ [[distortion]]
215
+ name = "rectangular_beampattern"
216
+ width = 0.015
217
+ height = 0.03
218
+ transmit = false
219
+ receive = true
220
+ frequency = "centre"
221
+ ```
222
+
223
+ ## Running the simulation
224
+
225
+ !!! Note
226
+ The full configuration file described above can be found in the
227
+ `examples/cli/simple_points` directory of the source code ([or viewed on
228
+ GitHub](https://github.com/openSTB/simulator/tree/main/examples/cli/simple_points)).
229
+
230
+ This configuration file can now be passed to the simulator CLI to perform the
231
+ simulation. This is a simple CLI to use:
232
+
233
+ ```console
234
+ openstb-sim run simple_points.toml
235
+ ```
236
+
237
+ While the simulation is in progress, you can view the Dask diagnostic dashboard to view
238
+ the progress (assuming you added the `dask-diagnostics` set of optional dependencies
239
+ when installing) by going to [http://127.0.0.1:8787](http://127.0.0.1:8787).
240
+
241
+
242
+ ## Viewing the results
243
+
244
+ When the simulation is complete, a NumPy file (or MATLAB file if you picked that option)
245
+ with the results will be in the same directory as the configuration file. For the NumPy
246
+ option, a simple Python script can be found in the `examples/cli/simple_points`
247
+ directory of the source code to plot the results.
@@ -0,0 +1,37 @@
1
+ # Installation
2
+
3
+
4
+ ## From PyPI
5
+
6
+ The simulator is published on [PyPI](https://pypi.org) as
7
+ [`openstb-simulator`](https://pypi.org/project/openstb-simulator). You can use your
8
+ preferred Python environment management tool to install it. For example, with pip:
9
+
10
+ ```console
11
+ pip install openstb-simulator
12
+ ```
13
+
14
+ ## Optional dependencies
15
+
16
+ There are a number of sets of optional dependencies you may wish to add to the
17
+ installation:
18
+
19
+ * `dask-diagnostics`: support for Dask's [interactice diagnostic
20
+ dashboard](https://docs.dask.org/en/stable/dashboard.html) to visualise performance.
21
+
22
+ * `mpi`: required for using the simulator on an MPI-based cluster
23
+
24
+ * `doc`: tools for building the documentation
25
+
26
+ * `tests`: tools for running the unit tests in the source repository
27
+
28
+ * `dev`: tools useful for helping to develop the simulator. This automatically includes
29
+ the `dask-diagnotics`, `doc` and `tests` dependencies.
30
+
31
+ These options can be specified when installing the simulator. For example, if you use
32
+ pip to install from PyPI, you can just add your desired set of dependencies in square
33
+ brackets:
34
+
35
+ ```console
36
+ pip install openstb-simulator[dask-diagnostics,mpi]
37
+ ```