xnft-lemma-scanner 1.0.1__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.
@@ -0,0 +1,235 @@
1
+ *~lock~
2
+ */figures/*
3
+
4
+ # pixi environments
5
+ .pixi/*
6
+ !.pixi/config.toml
7
+
8
+ # Sphinx
9
+ docs/build
10
+
11
+ # macOS
12
+ .DS_Store
13
+
14
+ # == Python ===
15
+ # Byte-compiled / optimized / DLL files
16
+ __pycache__/
17
+ *.py[codz]
18
+ *$py.class
19
+
20
+ # C extensions
21
+ *.so
22
+
23
+ # Distribution / packaging
24
+ .Python
25
+ build/
26
+ develop-eggs/
27
+ dist/
28
+ downloads/
29
+ eggs/
30
+ .eggs/
31
+ lib/
32
+ lib64/
33
+ parts/
34
+ sdist/
35
+ var/
36
+ wheels/
37
+ share/python-wheels/
38
+ *.egg-info/
39
+ .installed.cfg
40
+ *.egg
41
+ MANIFEST
42
+
43
+ # PyInstaller
44
+ # Usually these files are written by a python script from a template
45
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
46
+ *.manifest
47
+ # *.spec
48
+
49
+ # Installer logs
50
+ pip-log.txt
51
+ pip-delete-this-directory.txt
52
+
53
+ # Unit test / coverage reports
54
+ htmlcov/
55
+ .tox/
56
+ .nox/
57
+ .coverage
58
+ .coverage.*
59
+ .cache
60
+ nosetests.xml
61
+ coverage.xml
62
+ *.cover
63
+ *.py.cover
64
+ .hypothesis/
65
+ .pytest_cache/
66
+ cover/
67
+ report.xml
68
+
69
+ # Translations
70
+ *.mo
71
+ *.pot
72
+
73
+ # Django stuff:
74
+ *.log
75
+ local_settings.py
76
+ db.sqlite3
77
+ db.sqlite3-journal
78
+
79
+ # Flask stuff:
80
+ instance/
81
+ .webassets-cache
82
+
83
+ # Scrapy stuff:
84
+ .scrapy
85
+
86
+ # Sphinx documentation
87
+ docs/_build/
88
+ # Generated api docs
89
+ docs/source/api/
90
+ docs/*.pdf
91
+
92
+ # PyBuilder
93
+ .pybuilder/
94
+ target/
95
+
96
+ # Jupyter Notebook
97
+ .ipynb_checkpoints
98
+
99
+ # IPython
100
+ profile_default/
101
+ ipython_config.py
102
+
103
+ # pyenv
104
+ # For a library or package, you might want to ignore these files since the code is
105
+ # intended to run in multiple environments; otherwise, check them in:
106
+ # .python-version
107
+
108
+ # pipenv
109
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
110
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
111
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
112
+ # install all needed dependencies.
113
+ # Pipfile.lock
114
+
115
+ # UV
116
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
117
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
118
+ # commonly ignored for libraries.
119
+ # uv.lock
120
+
121
+ # poetry
122
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
123
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
124
+ # commonly ignored for libraries.
125
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
126
+ # poetry.lock
127
+ # poetry.toml
128
+
129
+ # pdm
130
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
131
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
132
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
133
+ # pdm.lock
134
+ # pdm.toml
135
+ .pdm-python
136
+ .pdm-build/
137
+
138
+ # pixi
139
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
140
+ # pixi.lock
141
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
142
+ # in the .venv directory. It is recommended not to include this directory in version control.
143
+ .pixi
144
+
145
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
146
+ __pypackages__/
147
+
148
+ # Celery stuff
149
+ celerybeat-schedule
150
+ celerybeat.pid
151
+
152
+ # Redis
153
+ *.rdb
154
+ *.aof
155
+ *.pid
156
+
157
+ # RabbitMQ
158
+ mnesia/
159
+ rabbitmq/
160
+ rabbitmq-data/
161
+
162
+ # ActiveMQ
163
+ activemq-data/
164
+
165
+ # SageMath parsed files
166
+ *.sage.py
167
+
168
+ # Environments
169
+ .env
170
+ .envrc
171
+ .venv
172
+ env/
173
+ venv/
174
+ ENV/
175
+ env.bak/
176
+ venv.bak/
177
+
178
+ # Spyder project settings
179
+ .spyderproject
180
+ .spyproject
181
+
182
+ # Rope project settings
183
+ .ropeproject
184
+
185
+ # mkdocs documentation
186
+ /site
187
+
188
+ # mypy
189
+ .mypy_cache/
190
+ .dmypy.json
191
+ dmypy.json
192
+
193
+ # Pyre type checker
194
+ .pyre/
195
+
196
+ # pytype static type analyzer
197
+ .pytype/
198
+
199
+ # Cython debug symbols
200
+ cython_debug/
201
+
202
+ # PyCharm
203
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
204
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
205
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
206
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
207
+ # .idea/
208
+
209
+ # Abstra
210
+ # Abstra is an AI-powered process automation framework.
211
+ # Ignore directories containing user credentials, local state, and settings.
212
+ # Learn more at https://abstra.io/docs
213
+ .abstra/
214
+
215
+ # Visual Studio Code
216
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
217
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
218
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
219
+ # you could uncomment the following to ignore the entire vscode folder
220
+ # .vscode/
221
+
222
+ # Ruff stuff:
223
+ .ruff_cache/
224
+ code-quality-report.json
225
+
226
+ # PyPI configuration file
227
+ .pypirc
228
+
229
+ # Marimo
230
+ marimo/_static/
231
+ marimo/_lsp/
232
+ __marimo__/
233
+
234
+ # Streamlit
235
+ .streamlit/secrets.toml
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright 2026 LEmmA, Electromagnetics Research Group, Michigan State University.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.5
2
+ Name: xnft-lemma-scanner
3
+ Version: 1.0.1
4
+ Summary: Antenna measurement and analysis software.
5
+ Author: LEmmA Group, Michigan State University
6
+ Author-email: Jason Merlo <merlojas@msu.edu>, Mauro Ettorre <ettorre@msu.edu>
7
+ Maintainer-email: Jason Merlo <merlojas@msu.edu>
8
+ License-Expression: LicenseRef-Proprietary
9
+ License-File: LICENSE
10
+ Requires-Python: <3.15,>=3.12
11
+ Description-Content-Type: text/markdown
12
+
13
+ # LEmmA Scanner _xNFT_ Extension
14
+
15
+ Repository for the LEmmA planar near-field scanner _xNFT_ field loader extension.
@@ -0,0 +1,3 @@
1
+ # LEmmA Scanner _xNFT_ Extension
2
+
3
+ Repository for the LEmmA planar near-field scanner _xNFT_ field loader extension.
@@ -0,0 +1,65 @@
1
+ [project]
2
+ name = "xnft-lemma-scanner"
3
+ dynamic = ["version"]
4
+ authors = [
5
+ { name = "LEmmA Group, Michigan State University" },
6
+ { name = "Jason Merlo", email = "merlojas@msu.edu" },
7
+ { name = "Mauro Ettorre", email = "ettorre@msu.edu" },
8
+ ]
9
+ maintainers = [{ name = "Jason Merlo", email = "merlojas@msu.edu" }]
10
+ readme = "README.md"
11
+ description = "Antenna measurement and analysis software."
12
+ license = "LicenseRef-Proprietary"
13
+
14
+ requires-python = ">=3.12,<3.15"
15
+
16
+ # [project.scripts]
17
+ # xnft = "xnft.gui.app:main"
18
+
19
+ [project.urls]
20
+
21
+
22
+ [build-system]
23
+ requires = ["hatchling>=1.32.4,<2", "hatch-vcs>=0.5.0,<0.6"]
24
+ build-backend = "hatchling.build"
25
+
26
+ [tool.hatch.version]
27
+ source = "vcs"
28
+ tag-pattern = "^(?:pypi-)?v(?P<version>.*)$"
29
+
30
+ [tool.hatch.build.targets.wheel]
31
+ packages = ["src/xnft_lemma_scanner"]
32
+
33
+ [tool.hatch.build.targets.sdist]
34
+ include = [
35
+ "/src/xnft_lemma_scanner",
36
+ "/pyproject.toml",
37
+ "/README.md",
38
+ "/LICENSE",
39
+ ]
40
+ exclude = ["/tests", "/data", "/docs", "/.pixi", "/.pixi-cache"]
41
+
42
+ # === PyTest Configuration ===
43
+
44
+ [tool.pytest.ini_options]
45
+ addopts = "--cov='xnft' --cov-report term --cov-report xml:coverage.xml --junitxml report.xml -n auto"
46
+
47
+ [tool.coverage.run]
48
+ source = ["src"]
49
+ omit = ["**/.pixi/**", "**/tests/**"]
50
+
51
+ [tool.coverage.report]
52
+ exclude_lines = [
53
+ "pragma: no cover",
54
+ "if TYPE_CHECKING:",
55
+ "if __name__ == .__main__.:",
56
+ ]
57
+
58
+ [tool.ruff]
59
+ # Exclude CI pixi cache folder.
60
+ extend-exclude = [".pixi-cache"]
61
+
62
+
63
+ # === xNFT Plugin Configuration ===
64
+ [project.entry-points."xnft.plugins"]
65
+ example = "xnft_lemma_scanner.plugin"
@@ -0,0 +1,243 @@
1
+ """
2
+ File for LEmmA near field scanner file format.
3
+
4
+ Copyright 2025-2026 LEmmA, Electromagnetics Research Group, Michigan State University.
5
+ """
6
+
7
+ import logging
8
+
9
+ import h5py
10
+ import numpy as np
11
+ import xarray as xr
12
+ from xnft.common.enums import (
13
+ CoordinateSystemType,
14
+ DataPolarizationType,
15
+ FieldType,
16
+ ScanType,
17
+ SParameterType,
18
+ )
19
+ from xnft.common.registry import registry
20
+ from xnft.common.types import FieldDataset, FileInfo, PolarizationType
21
+
22
+ logger = logging.getLogger(__name__)
23
+
24
+
25
+ # Constant for scanner distnaces
26
+ POINTS_PER_METER = 200_000
27
+
28
+ # Register DataSource
29
+ LEMMA_SOURCE_V1 = registry.data_sources.register(
30
+ id="xnft-lemma-scanner.lemma_v1",
31
+ display_name="LEmmA Scanner V1",
32
+ )
33
+ LEMMA_SOURCE_V2 = registry.data_sources.register(
34
+ id="xnft-lemma-scanner.lemma_v2",
35
+ display_name="LEmmA Scanner V2",
36
+ )
37
+
38
+
39
+ @registry.loaders.fields.register(
40
+ source=LEMMA_SOURCE_V1,
41
+ field_type=FieldType.NEAR,
42
+ scan_type=ScanType.PLANAR,
43
+ data_polarization=DataPolarizationType.SINGLE_POL,
44
+ extension=".h5",
45
+ has_sp=True,
46
+ )
47
+ def load_lemma_v1_h5(file_list: list[FileInfo]) -> xr.Dataset:
48
+
49
+ co_file_info = cx_file_info = None
50
+ for file_info in file_list:
51
+ if file_info.polarization == PolarizationType.CO_POL:
52
+ co_file_info = file_info
53
+ elif file_info.polarization == PolarizationType.CROSS_POL:
54
+ cx_file_info = file_info
55
+ else:
56
+ raise TypeError(
57
+ "LEmmA loader only accepts polarization types CO_POL and CROSS_POL, not both "
58
+ "or none",
59
+ )
60
+
61
+ if co_file_info is None and cx_file_info is None:
62
+ raise RuntimeError("At least `co_pol` or `cross_pol` must be specified.")
63
+
64
+ # Open file
65
+ for file_info in file_list:
66
+ with h5py.File(file_info.path, "r") as dataset:
67
+ sample_frequencies = dataset["f"][()][0]
68
+ sample_locations = dataset["points"][()] / POINTS_PER_METER
69
+ x_locs = sample_locations[:, 2]
70
+ # NOTE: Swap y and z axes
71
+ y_locs = sample_locations[:, 0]
72
+
73
+ # TODO/FIXME: Hardcoded z-distance!!
74
+ z_locs = sample_locations[:, 1] + 0.069
75
+
76
+ # NOTE: We're only taking the first item in the set
77
+ if file_info.s_parameters != set():
78
+ sp = next(iter(file_info.s_parameters))
79
+ else:
80
+ sp = SParameterType.S21
81
+
82
+ field_amplitude = dataset[f"{sp}real"][()] + 1.0j * dataset[f"{sp}imag"][()]
83
+
84
+ if file_info.polarization == PolarizationType.CO_POL:
85
+ ey_array = field_amplitude
86
+ if cx_file_info is None:
87
+ ex_array = np.zeros_like(ey_array)
88
+ if file_info.polarization == PolarizationType.CROSS_POL:
89
+ ex_array = field_amplitude
90
+ if co_file_info is None:
91
+ ey_array = np.zeros_like(ex_array)
92
+
93
+ x_list = x_locs.tolist()
94
+ y_list = y_locs.tolist()
95
+ z_list = z_locs.tolist()
96
+
97
+ frequency_list = sample_frequencies.tolist()
98
+
99
+ ez_array = np.zeros_like(ex_array)
100
+
101
+ x_sample_location_array = np.sort(np.array(list(set(x_list))))
102
+ y_sample_location_array = np.sort(np.array(list(set(y_list))))
103
+ z_sample_location_array = np.sort(np.array(list(set(z_list))))
104
+
105
+ sample_frequency_array = np.sort(np.array(list(set(frequency_list))))
106
+
107
+ logger.debug(
108
+ "Sample location array shape: (x:%d, y:%d, z:%d, freq:%d)",
109
+ x_sample_location_array.size,
110
+ y_sample_location_array.size,
111
+ z_sample_location_array.size,
112
+ sample_frequency_array.size,
113
+ )
114
+
115
+ # Allocate new data array in multidimensional format
116
+ fields_shape = (
117
+ 3, # 3 for x,y,z component of the field
118
+ x_sample_location_array.size,
119
+ y_sample_location_array.size,
120
+ z_sample_location_array.size,
121
+ sample_frequency_array.size,
122
+ )
123
+ e_field = np.empty(fields_shape, dtype=np.complex128)
124
+
125
+ # Find to insert field values in e_field array
126
+ x_idx = np.searchsorted(x_sample_location_array, x_locs)
127
+ y_idx = np.searchsorted(y_sample_location_array, y_locs)
128
+ z_idx = np.searchsorted(z_sample_location_array, z_locs)
129
+
130
+ for f_idx in range(sample_frequencies.size):
131
+ e_field[0, x_idx, y_idx, z_idx, f_idx] = ex_array[:, f_idx]
132
+ e_field[1, x_idx, y_idx, z_idx, f_idx] = ey_array[:, f_idx]
133
+ e_field[2, x_idx, y_idx, z_idx, f_idx] = ez_array[:, f_idx]
134
+
135
+ fields = FieldDataset.create(
136
+ e_field=e_field,
137
+ h_field=None,
138
+ spatial_coords={
139
+ "x": x_sample_location_array,
140
+ "y": y_sample_location_array,
141
+ "z": z_sample_location_array,
142
+ },
143
+ frequency=sample_frequency_array,
144
+ coordinate_system=CoordinateSystemType.CARTESIAN,
145
+ field_type=FieldType.NEAR,
146
+ data_source=LEMMA_SOURCE_V1,
147
+ )
148
+
149
+ return fields
150
+
151
+
152
+ @registry.loaders.fields.register(
153
+ source=LEMMA_SOURCE_V2,
154
+ field_type=FieldType.NEAR,
155
+ scan_type=ScanType.PLANAR,
156
+ data_polarization=DataPolarizationType.SINGLE_POL,
157
+ extension=".h5",
158
+ has_sp=True,
159
+ )
160
+ def load_lemma_v2_h5(file_list: list[FileInfo]) -> xr.Dataset:
161
+
162
+ # Open file
163
+ for file_info in file_list:
164
+ with h5py.File(file_info.path, "r") as dataset:
165
+ sample_frequencies = dataset["f"][()][0]
166
+ sample_locations = dataset["points"][()] / POINTS_PER_METER
167
+ x_locs = sample_locations[:, 0]
168
+ y_locs = sample_locations[:, 1]
169
+ # TODO/FIXME: temporary hardcoded z-distance; need scanner to report correct value
170
+ z_locs = sample_locations[:, 2] + 0.07
171
+
172
+ # NOTE: We're only taking the first item in the set
173
+ if file_info.s_parameters != set():
174
+ sp = next(iter(file_info.s_parameters))
175
+ else:
176
+ sp = SParameterType.S21
177
+
178
+ field_amplitude = dataset[f"{sp}real"][()] + 1.0j * dataset[f"{sp}imag"][()]
179
+
180
+ # TODO/FIXME: Assumes all measurements are co-pol ONLY
181
+ logger.warning(
182
+ "LEmmA V2 loader currently assumes _all_ measurements are co-pol only. Cross-pol measurements are treated as co-pol.",
183
+ )
184
+ ey_array = field_amplitude
185
+ ex_array = np.zeros_like(ey_array)
186
+
187
+ x_list = x_locs.tolist()
188
+ y_list = y_locs.tolist()
189
+ z_list = z_locs.tolist()
190
+
191
+ frequency_list = sample_frequencies.tolist()
192
+
193
+ ez_array = np.zeros_like(ey_array)
194
+
195
+ x_sample_location_array = np.sort(np.array(list(set(x_list))))
196
+ y_sample_location_array = np.sort(np.array(list(set(y_list))))
197
+ z_sample_location_array = np.sort(np.array(list(set(z_list))))
198
+
199
+ sample_frequency_array = np.sort(np.array(list(set(frequency_list))))
200
+
201
+ logger.debug(
202
+ "Sample location array shape: (x:%d, y:%d, z:%d, freq:%d)",
203
+ x_sample_location_array.size,
204
+ y_sample_location_array.size,
205
+ z_sample_location_array.size,
206
+ sample_frequency_array.size,
207
+ )
208
+
209
+ # Allocate new data array in multidimensional format
210
+ fields_shape = (
211
+ 3, # 3 for x,y,z component of the field
212
+ x_sample_location_array.size,
213
+ y_sample_location_array.size,
214
+ z_sample_location_array.size,
215
+ sample_frequency_array.size,
216
+ )
217
+ e_field = np.empty(fields_shape, dtype=np.complex128)
218
+
219
+ # Find to insert field values in e_field array
220
+ x_idx = np.searchsorted(x_sample_location_array, x_locs)
221
+ y_idx = np.searchsorted(y_sample_location_array, y_locs)
222
+ z_idx = np.searchsorted(z_sample_location_array, z_locs)
223
+
224
+ for f_idx in range(sample_frequencies.size):
225
+ e_field[0, x_idx, y_idx, z_idx, f_idx] = ex_array[:, f_idx]
226
+ e_field[1, x_idx, y_idx, z_idx, f_idx] = ey_array[:, f_idx]
227
+ e_field[2, x_idx, y_idx, z_idx, f_idx] = ez_array[:, f_idx]
228
+
229
+ fields = FieldDataset.create(
230
+ e_field=e_field,
231
+ h_field=None,
232
+ spatial_coords={
233
+ "x": x_sample_location_array,
234
+ "y": y_sample_location_array,
235
+ "z": z_sample_location_array,
236
+ },
237
+ frequency=sample_frequency_array,
238
+ coordinate_system=CoordinateSystemType.CARTESIAN,
239
+ field_type=FieldType.NEAR,
240
+ data_source=LEMMA_SOURCE_V2,
241
+ )
242
+
243
+ return fields
@@ -0,0 +1,9 @@
1
+ """
2
+ Plugin manifest file.
3
+
4
+ All files with registry decorators must be imported here.
5
+
6
+ Copyright 2026 LEmmA, Electromagnetics Research Group, Michigan State University.
7
+ """
8
+
9
+ from xnft_lemma_scanner.loaders.fields.lemma import load_lemma_v1_h5, load_lemma_v2_h5 # noqa: F401