sofar 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. docs/Makefile +20 -0
  2. docs/api_reference.rst +20 -0
  3. docs/conf.py +167 -0
  4. docs/contributing.rst +1 -0
  5. docs/history.rst +1 -0
  6. docs/index.rst +4 -0
  7. docs/make.bat +36 -0
  8. docs/readme.rst +1 -0
  9. docs/resources/conventions.py +162 -0
  10. docs/resources/working_with_sofa_HRIR_lateral.png +0 -0
  11. docs/resources/working_with_sofa_source_horizontal.png +0 -0
  12. docs/resources/working_with_sofa_source_lateral.png +0 -0
  13. docs/sofar.rst +82 -0
  14. sofar/__init__.py +28 -0
  15. sofar/io.py +427 -0
  16. sofar/sofa.py +1835 -0
  17. sofar/sofa_conventions/VERSION +1 -0
  18. sofar/sofa_conventions/conventions/AnnotatedEmitterAudio_0.2.csv +46 -0
  19. sofar/sofa_conventions/conventions/AnnotatedEmitterAudio_0.2.json +353 -0
  20. sofar/sofa_conventions/conventions/AnnotatedReceiverAudio_0.2.csv +46 -0
  21. sofar/sofa_conventions/conventions/AnnotatedReceiverAudio_0.2.json +353 -0
  22. sofar/sofa_conventions/conventions/FreeFieldDirectivityTF_1.1.csv +59 -0
  23. sofar/sofa_conventions/conventions/FreeFieldDirectivityTF_1.1.json +444 -0
  24. sofar/sofa_conventions/conventions/FreeFieldHRIR_1.0.csv +43 -0
  25. sofar/sofa_conventions/conventions/FreeFieldHRIR_1.0.json +333 -0
  26. sofar/sofa_conventions/conventions/FreeFieldHRTF_1.0.csv +44 -0
  27. sofar/sofa_conventions/conventions/FreeFieldHRTF_1.0.json +340 -0
  28. sofar/sofa_conventions/conventions/GeneralFIR-E_2.0.csv +37 -0
  29. sofar/sofa_conventions/conventions/GeneralFIR-E_2.0.json +270 -0
  30. sofar/sofa_conventions/conventions/GeneralFIR_1.0.csv +40 -0
  31. sofar/sofa_conventions/conventions/GeneralFIR_1.0.json +295 -0
  32. sofar/sofa_conventions/conventions/GeneralSOS_1.0.csv +40 -0
  33. sofar/sofa_conventions/conventions/GeneralSOS_1.0.json +306 -0
  34. sofar/sofa_conventions/conventions/GeneralTF-E_1.0.csv +38 -0
  35. sofar/sofa_conventions/conventions/GeneralTF-E_1.0.json +277 -0
  36. sofar/sofa_conventions/conventions/GeneralTF_1.0.csv +38 -0
  37. sofar/sofa_conventions/conventions/GeneralTF_1.0.json +277 -0
  38. sofar/sofa_conventions/conventions/GeneralTF_2.0.csv +38 -0
  39. sofar/sofa_conventions/conventions/GeneralTF_2.0.json +277 -0
  40. sofar/sofa_conventions/conventions/SimpleFreeFieldHRIR_1.0.csv +47 -0
  41. sofar/sofa_conventions/conventions/SimpleFreeFieldHRIR_1.0.json +369 -0
  42. sofar/sofa_conventions/conventions/SimpleFreeFieldHRSOS_1.0.csv +43 -0
  43. sofar/sofa_conventions/conventions/SimpleFreeFieldHRSOS_1.0.json +349 -0
  44. sofar/sofa_conventions/conventions/SimpleFreeFieldHRTF_1.0.csv +44 -0
  45. sofar/sofa_conventions/conventions/SimpleFreeFieldHRTF_1.0.json +340 -0
  46. sofar/sofa_conventions/conventions/SimpleFreeFieldSOS_1.0.csv +43 -0
  47. sofar/sofa_conventions/conventions/SimpleFreeFieldSOS_1.0.json +349 -0
  48. sofar/sofa_conventions/conventions/SimpleHeadphoneIR_1.0.csv +51 -0
  49. sofar/sofa_conventions/conventions/SimpleHeadphoneIR_1.0.json +396 -0
  50. sofar/sofa_conventions/conventions/SingleRoomMIMOSRIR_1.0.csv +78 -0
  51. sofar/sofa_conventions/conventions/SingleRoomMIMOSRIR_1.0.json +601 -0
  52. sofar/sofa_conventions/conventions/SingleRoomSRIR_1.0.csv +78 -0
  53. sofar/sofa_conventions/conventions/SingleRoomSRIR_1.0.json +601 -0
  54. sofar/sofa_conventions/conventions/deprecated/AnnotatedEmitterAudio_0.1.csv +46 -0
  55. sofar/sofa_conventions/conventions/deprecated/AnnotatedEmitterAudio_0.1.json +351 -0
  56. sofar/sofa_conventions/conventions/deprecated/AnnotatedReceiverAudio_0.1.csv +46 -0
  57. sofar/sofa_conventions/conventions/deprecated/AnnotatedReceiverAudio_0.1.json +351 -0
  58. sofar/sofa_conventions/conventions/deprecated/FreeFieldDirectivityTF_1.0.csv +58 -0
  59. sofar/sofa_conventions/conventions/deprecated/FreeFieldDirectivityTF_1.0.json +437 -0
  60. sofar/sofa_conventions/conventions/deprecated/GeneralFIRE_1.0.csv +37 -0
  61. sofar/sofa_conventions/conventions/deprecated/GeneralFIRE_1.0.json +270 -0
  62. sofar/sofa_conventions/conventions/deprecated/MultiSpeakerBRIR_0.3.csv +48 -0
  63. sofar/sofa_conventions/conventions/deprecated/MultiSpeakerBRIR_0.3.json +376 -0
  64. sofar/sofa_conventions/conventions/deprecated/SimpleFreeFieldHRIR_0.4.csv +43 -0
  65. sofar/sofa_conventions/conventions/deprecated/SimpleFreeFieldHRIR_0.4.json +333 -0
  66. sofar/sofa_conventions/conventions/deprecated/SimpleFreeFieldTF_0.4.csv +44 -0
  67. sofar/sofa_conventions/conventions/deprecated/SimpleFreeFieldTF_0.4.json +340 -0
  68. sofar/sofa_conventions/conventions/deprecated/SimpleFreeFieldTF_1.0.csv +44 -0
  69. sofar/sofa_conventions/conventions/deprecated/SimpleFreeFieldTF_1.0.json +340 -0
  70. sofar/sofa_conventions/conventions/deprecated/SimpleHeadphoneIR_0.1.csv +51 -0
  71. sofar/sofa_conventions/conventions/deprecated/SimpleHeadphoneIR_0.1.json +396 -0
  72. sofar/sofa_conventions/conventions/deprecated/SimpleHeadphoneIR_0.2.csv +51 -0
  73. sofar/sofa_conventions/conventions/deprecated/SimpleHeadphoneIR_0.2.json +396 -0
  74. sofar/sofa_conventions/conventions/deprecated/SingleRoomDRIR_0.2.csv +47 -0
  75. sofar/sofa_conventions/conventions/deprecated/SingleRoomDRIR_0.2.json +360 -0
  76. sofar/sofa_conventions/conventions/deprecated/SingleRoomDRIR_0.3.csv +47 -0
  77. sofar/sofa_conventions/conventions/deprecated/SingleRoomDRIR_0.3.json +360 -0
  78. sofar/sofa_conventions/conventions/deprecated/SingleTrackedAudio_0.1.csv +47 -0
  79. sofar/sofa_conventions/conventions/deprecated/SingleTrackedAudio_0.1.json +366 -0
  80. sofar/sofa_conventions/conventions/deprecated/SingleTrackedAudio_0.2.csv +51 -0
  81. sofar/sofa_conventions/conventions/deprecated/SingleTrackedAudio_0.2.json +397 -0
  82. sofar/sofa_conventions/rules/deprecations.json +13 -0
  83. sofar/sofa_conventions/rules/rules.json +819 -0
  84. sofar/sofa_conventions/rules/unit_aliases.json +11 -0
  85. sofar/sofa_conventions/rules/upgrade.json +226 -0
  86. sofar/sofa_conventions/write_upgrade_rules.py +139 -0
  87. sofar/sofa_conventions/write_verification_data.py +313 -0
  88. sofar/sofa_conventions/write_verification_rules.py +356 -0
  89. sofar/sofastream.py +301 -0
  90. sofar/update_conventions.py +449 -0
  91. sofar/utils.py +316 -0
  92. sofar-1.2.1.dist-info/LICENSE +22 -0
  93. sofar-1.2.1.dist-info/METADATA +136 -0
  94. sofar-1.2.1.dist-info/RECORD +105 -0
  95. sofar-1.2.1.dist-info/WHEEL +5 -0
  96. sofar-1.2.1.dist-info/top_level.txt +3 -0
  97. tests/__init__.py +0 -0
  98. tests/conftest.py +27 -0
  99. tests/test_deprecations.py +19 -0
  100. tests/test_io.py +349 -0
  101. tests/test_sofa.py +353 -0
  102. tests/test_sofa_upgrade_conventions.py +111 -0
  103. tests/test_sofa_verify.py +480 -0
  104. tests/test_sofastream.py +127 -0
  105. tests/test_utils.py +250 -0
docs/Makefile ADDED
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line.
5
+ SPHINXOPTS =
6
+ SPHINXBUILD = python -msphinx
7
+ SPHINXPROJ = sofar
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
docs/api_reference.rst ADDED
@@ -0,0 +1,20 @@
1
+ .. _api_reference:
2
+
3
+ API Reference
4
+ =============
5
+
6
+ This section documents sofar objects and functions. Sofar contains functions
7
+ for reading, writing and comparing SOFA files, functions to handle SOFA
8
+ conventions, and two classes to handle data from SOFA files. The
9
+ :py:class:`~sofar.Sofa` class is used to read and write entire SOFA files. To
10
+ open a SOFA file without reading the entire file into memory,
11
+ :py:class:`~sofar.SofaStream` enables partially reading data.
12
+
13
+ For examples on how to use sofar refer to the
14
+ :ref:`sofar and SOFA <gallery:/gallery/interactive/sofar_introduction.ipynb>`
15
+ notebook and the documentation below.
16
+
17
+ .. automodule:: sofar
18
+ :members:
19
+ :undoc-members:
20
+ :show-inheritance:
docs/conf.py ADDED
@@ -0,0 +1,167 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+
6
+ # -- Project information -----------------------------------------------------
7
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
+
9
+ import os
10
+ import sys
11
+ import urllib3
12
+ import shutil
13
+ sys.path.insert(0, os.path.abspath('..'))
14
+
15
+ import sofar
16
+ import resources.conventions
17
+
18
+ # -- General configuration ---------------------------------------------------
19
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
20
+
21
+ extensions = [
22
+ 'sphinx.ext.autodoc',
23
+ 'sphinx.ext.viewcode',
24
+ 'sphinx.ext.napoleon',
25
+ 'sphinx.ext.autosummary',
26
+ 'sphinx.ext.imgmath',
27
+ 'sphinx.ext.mathjax',
28
+ 'sphinx.ext.intersphinx',
29
+ 'autodocsumm',
30
+ 'sphinx_design',
31
+ 'sphinx_favicon',
32
+ 'sphinx_reredirects',
33
+ 'sphinx_mdinclude',
34
+ ]
35
+
36
+ # show tocs for classes and functions of modules using the autodocsumm
37
+ # package
38
+ autodoc_default_options = {'autosummary': True}
39
+
40
+ # show the code of plots that follows the command .. plot:: based on the
41
+ # package matplotlib.sphinxext.plot_directive
42
+ plot_include_source = True
43
+
44
+ # Add any paths that contain templates here, relative to this directory.
45
+ templates_path = ['_templates']
46
+
47
+ # The suffix(es) of source filenames.
48
+ # You can specify multiple suffix as a list of string:
49
+ source_suffix = {
50
+ '.rst': 'restructuredtext',
51
+ '.md': 'markdown',
52
+ }
53
+
54
+
55
+ # The master toctree document.
56
+ master_doc = 'index'
57
+
58
+ # General information about the project.
59
+ project = 'sofar'
60
+ copyright = '2020, The pyfar developers'
61
+ author = 'The pyfar developers'
62
+
63
+ # The version info for the project you're documenting, acts as replacement
64
+ # for |version| and |release|, also used in various other places throughout
65
+ # the built documents.
66
+ #
67
+ # The short X.Y version.
68
+ version = sofar.__version__
69
+ # The full version, including alpha/beta/rc tags.
70
+ release = sofar.__version__
71
+
72
+ # This is also used if you do content translation via gettext catalogs.
73
+ # Usually you set "language" from the command line for these cases.
74
+ language = 'en'
75
+
76
+ # List of patterns, relative to source directory, that match files and
77
+ # directories to ignore when looking for source files.
78
+ # This patterns also effect to html_static_path and html_extra_path
79
+ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
80
+
81
+ # The name of the Pygments (syntax highlighting) style to use (Not defining
82
+ # uses the default style of the html_theme).
83
+ # pygments_style = 'sphinx'
84
+
85
+ # If true, '()' will be appended to :func: etc. cross-reference text.
86
+ add_function_parentheses = False
87
+
88
+ # If true, `todo` and `todoList` produce output, else they produce nothing.
89
+ todo_include_todos = False
90
+
91
+ # default language for highlighting in source code
92
+ highlight_language = "python3"
93
+
94
+ # intersphinx mapping
95
+ intersphinx_mapping = {
96
+ 'numpy': ('https://numpy.org/doc/stable/', None),
97
+ 'gallery': ('https://pyfar-gallery.readthedocs.io/en/latest/', None),
98
+ }
99
+
100
+ # -- Options for HTML output -------------------------------------------------
101
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
102
+
103
+ html_theme = 'pydata_sphinx_theme'
104
+ html_static_path = ['_static']
105
+ html_css_files = ['css/custom.css']
106
+ html_logo = 'resources/logos/pyfar_logos_fixed_size_sofar.png'
107
+ html_title = "sofar"
108
+ html_favicon = '_static/favicon.ico'
109
+
110
+ # -- HTML theme options
111
+ # https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/layout.html
112
+ html_sidebars = {
113
+ "sofar": []
114
+ }
115
+
116
+ html_theme_options = {
117
+ "navbar_start": ["navbar-logo"],
118
+ "navbar_end": ["navbar-icon-links", "theme-switcher"],
119
+ "navbar_align": "content",
120
+ "header_links_before_dropdown": 8,
121
+ "icon_links": [
122
+ {
123
+ "name": "GitHub",
124
+ "url": "https://github.com/pyfar",
125
+ "icon": "fa-brands fa-square-github",
126
+ "type": "fontawesome",
127
+ },
128
+ ],
129
+ # Configure secondary (right) side bar
130
+ "show_toc_level": 3, # Show all subsections of notebooks
131
+ "secondary_sidebar_items": ["page-toc"], # Omit 'show source' link that that shows notebook in json format
132
+ "navigation_with_keys": True,
133
+ # Configure navigation depth for section navigation
134
+ "navigation_depth": 1,
135
+ }
136
+
137
+ html_context = {
138
+ "default_mode": "light"
139
+ }
140
+
141
+ # redirect index to pyfar.html
142
+ redirects = {
143
+ "index": f"{project}.html"
144
+ }
145
+
146
+ # -- download navbar and style files from gallery -----------------------------
147
+ branch = 'main'
148
+ link = f'https://github.com/pyfar/gallery/raw/{branch}/docs/'
149
+ folders_in = [
150
+ '_static/css/custom.css',
151
+ '_static/favicon.ico',
152
+ '_static/header.rst',
153
+ 'resources/logos/pyfar_logos_fixed_size_sofar.png',
154
+ ]
155
+ c = urllib3.PoolManager()
156
+ for file in folders_in:
157
+ url = link + file
158
+ filename = file
159
+ os.makedirs(os.path.dirname(filename), exist_ok=True)
160
+ with c.request('GET', url, preload_content=False) as res, open(filename, 'wb') as out_file:
161
+ shutil.copyfileobj(res, out_file)
162
+
163
+ # replace sofar hard link to internal link
164
+ with open("_static/header.rst", "rt") as fin:
165
+ with open("header.rst", "wt") as fout:
166
+ for line in fin:
167
+ fout.write(line.replace(f'https://{project}.readthedocs.io', project))
docs/contributing.rst ADDED
@@ -0,0 +1 @@
1
+ .. include:: ../CONTRIBUTING.rst
docs/history.rst ADDED
@@ -0,0 +1 @@
1
+ .. include:: ../HISTORY.rst
docs/index.rst ADDED
@@ -0,0 +1,4 @@
1
+ sofar
2
+ =====
3
+
4
+ .. include:: header.rst
docs/make.bat ADDED
@@ -0,0 +1,36 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=python -msphinx
9
+ )
10
+ set SOURCEDIR=.
11
+ set BUILDDIR=_build
12
+ set SPHINXPROJ=sofar
13
+
14
+ if "%1" == "" goto help
15
+
16
+ %SPHINXBUILD% >NUL 2>NUL
17
+ if errorlevel 9009 (
18
+ echo.
19
+ echo.The Sphinx module was not found. Make sure you have Sphinx installed,
20
+ echo.then set the SPHINXBUILD environment variable to point to the full
21
+ echo.path of the 'sphinx-build' executable. Alternatively you may add the
22
+ echo.Sphinx directory to PATH.
23
+ echo.
24
+ echo.If you don't have Sphinx installed, grab it from
25
+ echo.http://sphinx-doc.org/
26
+ exit /b 1
27
+ )
28
+
29
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30
+ goto end
31
+
32
+ :help
33
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
34
+
35
+ :end
36
+ popd
docs/readme.rst ADDED
@@ -0,0 +1 @@
1
+ .. mdinclude:: ../README.md
@@ -0,0 +1,162 @@
1
+ import os
2
+ import sys
3
+ import json
4
+ sys.path.insert(0, os.path.abspath(os.path.join('..', '..')))
5
+
6
+ import sofar as sf
7
+
8
+ base_dir = os.path.dirname(__file__)
9
+
10
+ # get conventions (paths, names, version) and upgrade rules -------------------
11
+ paths = sf.utils._get_conventions('path')
12
+ names_versions = sf.utils._get_conventions('name_version')
13
+
14
+ # using Sofa()._verification_rules() does not work on readthedocs
15
+ upgrade_rules = os.path.join(
16
+ os.path.dirname(paths[0]), '..', 'rules', 'upgrade.json')
17
+ with open(upgrade_rules) as file:
18
+ upgrade_rules = json.load(file)
19
+
20
+ deprecation_rules = os.path.join(
21
+ os.path.dirname(paths[0]), '..', 'rules', 'deprecations.json')
22
+ with open(deprecation_rules) as file:
23
+ deprecation_rules = json.load(file)
24
+
25
+ # write general information ---------------------------------------------------
26
+ docs = (
27
+ '.. _conventions_introduction:\n\n'
28
+ 'SOFA Conventions\n'
29
+ '================\n\n'
30
+ 'SOFA conventions specify what data and metadata must be stored in a SOFA '
31
+ 'file. Different conventions can be used to store different types of data,'
32
+ 'e.g., head-related impulse responses or musical instrument directivities.'
33
+ 'It is advised to always use the conventions that is most specific for the'
34
+ 'data.\n\n'
35
+ 'In the following, SOFA conventions are described in tables with the '
36
+ 'information\n\n'
37
+ '* **Name:** The Name of the data. The prefix *GLOBAL* denotes global '
38
+ 'attribute, i.e., attributes that pertain the entire data set. Underscores'
39
+ ' denote attributes that are data specific. E.g., *SourcePosition_Units* '
40
+ 'denotes the *Units* of the data *SourcePosition*.\n'
41
+ '* **Type:** The Type of the data.\n\n'
42
+ ' * **Attribute:** A verbose description given by a string\n'
43
+ ' * **Double:** A numeric array of data\n'
44
+ ' * **String:** A string array of data\n\n'
45
+ '* **Default:** The default value\n'
46
+ '* **Dimensions:** The dimensions of the data. Lower case letters denote '
47
+ 'the data that sets the dimension.\n\n'
48
+ ' * **E:** Number of emitters\n'
49
+ ' * **R:** Number of receivers\n'
50
+ ' * **M:** Number of measurements\n'
51
+ ' * **N:** Number of samples or frequency bins of the data\n'
52
+ ' * **C:** Number of coordinates (always 3)\n'
53
+ ' * **I:** Unity dimensions (always 1)\n'
54
+ ' * **S:** Lengths of the longest string contained in the data '
55
+ '(detected automatically)\n\n'
56
+ '* **Flags:**\n\n'
57
+ ' * **r:** read only data. Data can be written if flag is missing.\n'
58
+ ' * **m:** mandatory data. Data is optional if flag is missing\n\n')
59
+
60
+ # write table of content ------------------------------------------------------
61
+ docs += '.. _conventions:\n\nConventions\n-----------\n\n'
62
+ for path, name_version in zip(paths, names_versions):
63
+ name, version = name_version
64
+
65
+ label = f'{name} v{version}'
66
+ if 'deprecated' in path:
67
+ label += ' (deprecated)'
68
+ reference = f'{name}_{version}'
69
+
70
+ docs += f'* :ref:`{label} <{reference}>`\n'
71
+
72
+ # write conventions -----------------------------------------------------------
73
+ docs += '\nCurrent\n-------\n\n'
74
+
75
+ # loop conventions
76
+ deprecated = False
77
+ for path, name_version in zip(paths, names_versions):
78
+ name, version = name_version
79
+
80
+ # read convention from json file
81
+ with open(path, 'r') as file:
82
+ convention = json.load(file)
83
+
84
+ # write section title
85
+ if 'deprecated' in path and not deprecated:
86
+ docs += 'Deprecated\n----------\n\n'
87
+ deprecated = True
88
+
89
+ # write convention name, version
90
+ docs += f'.. _{name}_{version}:\n\n'
91
+ docs += f'**{name} v{version}**\n\n'
92
+
93
+ # name new convention if current convention is deprecated
94
+ if deprecated:
95
+ # upgrade rules give best feedback
96
+ if name in upgrade_rules:
97
+ for upgrade in upgrade_rules[name]['from_to']:
98
+ if version in upgrade[0]:
99
+ upgrade_to = upgrade[1]
100
+ references = [f':ref:`{u} <{u}>`' for u in upgrade_to]
101
+ ':ref:`{label} <{reference}>`'
102
+ docs += ('This convention is deprecated. '
103
+ f'Use {", ".join(references)} instead.\n\n')
104
+ # deprecations are used if no upgrade rules are available
105
+ elif name in deprecation_rules['GLOBAL:SOFAConventions']:
106
+ docs += ("This convention is deprecated. Use "
107
+ f"{deprecation_rules['GLOBAL:SOFAConventions'][name]} "
108
+ "instead.\n\n")
109
+
110
+ # name purpose of the convention
111
+ docs += f'{convention["GLOBAL:SOFAConventions"]["comment"]}\n\n'
112
+
113
+ # write header
114
+ docs += (
115
+ '.. list-table::\n'
116
+ ' :widths: 20 50 25 30 100\n'
117
+ ' :header-rows: 1\n\n'
118
+ ' * - Name (Type)\n'
119
+ ' - Default\n'
120
+ ' - Dim.\n'
121
+ ' - Flags\n'
122
+ ' - Comment\n')
123
+
124
+ # loop entries
125
+ for key, value in convention.items():
126
+
127
+ if value["dimensions"] is None:
128
+ dimensions = ""
129
+ else:
130
+ dimensions = value["dimensions"]
131
+
132
+ if value["flags"] is None:
133
+ flags = ""
134
+ elif len(value["flags"]) > 1:
135
+ flags = f'{value["flags"][0]}, {value["flags"][1]}'
136
+ else:
137
+ flags = value["flags"]
138
+
139
+ if key == "GLOBAL:SOFAConventions":
140
+ value["comment"] = ""
141
+
142
+ if value["type"] == 'attribute':
143
+ type_str = 'attr.'
144
+ elif value["type"] == 'double':
145
+ type_str = 'doub.'
146
+ else:
147
+ type_str = 'str.'
148
+
149
+ docs += (
150
+ f' * - {key.replace(":", "_").replace(".", "_")} '
151
+ f'(*{value["type"]}*)\n'
152
+ f' - {value["default"]}\n'
153
+ f' - {dimensions}\n'
154
+ f' - {flags}\n'
155
+ f' - {value["comment"]}\n')
156
+
157
+ docs += '\n:ref:`back to top <conventions>`\n\n'
158
+
159
+ # write docs to rst file ------------------------------------------------------
160
+ docs_file = os.path.join(base_dir, 'conventions.rst')
161
+ with open(docs_file, 'w') as file:
162
+ file.writelines(docs)
docs/sofar.rst ADDED
@@ -0,0 +1,82 @@
1
+ sofar
2
+ =====
3
+
4
+ .. toctree::
5
+ :maxdepth: 2
6
+ :hidden:
7
+
8
+ readme
9
+ api_reference
10
+ resources/conventions
11
+ contributing
12
+ history
13
+
14
+
15
+ Python package for handling SOFA files.
16
+
17
+ SOFA files store spatially distributed acoustic data such as head-related
18
+ transfer functions. Sofar can read, create, write, manipulate, and verify SOFA
19
+ files.
20
+
21
+ .. grid:: 1 2 2 3
22
+ :gutter: 4
23
+
24
+ .. grid-item-card::
25
+ :link: readme.html
26
+ :text-align: center
27
+
28
+ **Getting Started**
29
+ ^^^^
30
+
31
+ .. raw:: html
32
+
33
+ <i class="fa-solid fa-rocket icon-style"></i>
34
+
35
+
36
+ .. grid-item-card::
37
+ :link: api_reference
38
+ :link-type: ref
39
+ :text-align: center
40
+
41
+ **API Reference**
42
+ ^^^^
43
+
44
+ .. raw:: html
45
+
46
+ <i class="fa-solid fa-file-lines icon-style"></i>
47
+
48
+ .. grid-item-card::
49
+ :link: conventions_introduction
50
+ :link-type: ref
51
+ :text-align: center
52
+
53
+ **SOFA Conventions**
54
+ ^^^^
55
+
56
+ .. raw:: html
57
+
58
+ <i class="fa-solid fa-book-open icon-style"></i>
59
+
60
+
61
+ .. grid-item-card::
62
+ :link: contributing.html
63
+ :text-align: center
64
+
65
+ **Contributing**
66
+ ^^^^
67
+
68
+ .. raw:: html
69
+
70
+ <i class="fa-solid fa-pen icon-style"></i>
71
+
72
+ .. grid-item-card::
73
+ :link: history.html
74
+ :text-align: center
75
+
76
+ **History**
77
+ ^^^^
78
+
79
+ .. raw:: html
80
+
81
+ <i class="fa-solid fa-clock-rotate-left icon-style">
82
+ </i>
sofar/__init__.py ADDED
@@ -0,0 +1,28 @@
1
+ """Main init that determines how the sofar package is structured."""
2
+ # -*- coding: utf-8 -*-
3
+ __author__ = """The pyfar developers"""
4
+ __email__ = 'info@pyfar.org'
5
+ __version__ = '1.2.1'
6
+
7
+ from .sofa import Sofa
8
+
9
+ from .sofastream import SofaStream
10
+
11
+ from .io import read_sofa, read_sofa_as_netcdf, write_sofa
12
+
13
+ from .utils import (list_conventions,
14
+ equals,
15
+ version)
16
+
17
+ from .update_conventions import update_conventions
18
+
19
+
20
+ __all__ = ['Sofa',
21
+ 'SofaStream',
22
+ 'update_conventions',
23
+ 'list_conventions',
24
+ 'read_sofa',
25
+ 'read_sofa_as_netcdf',
26
+ 'write_sofa',
27
+ 'equals',
28
+ 'version']