emsutil 0.2.1__tar.gz → 0.2.2__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 (31) hide show
  1. {emsutil-0.2.1 → emsutil-0.2.2}/.bumpversion.toml +1 -1
  2. {emsutil-0.2.1 → emsutil-0.2.2}/PKG-INFO +1 -1
  3. {emsutil-0.2.1 → emsutil-0.2.2}/pyproject.toml +1 -1
  4. emsutil-0.2.2/src/emsutil/inexport/ffdata.py +58 -0
  5. emsutil-0.2.2/src/emsutil/inexport/strutil.py +22 -0
  6. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/display.py +6 -2
  7. {emsutil-0.2.1 → emsutil-0.2.2}/uv.lock +1 -1
  8. {emsutil-0.2.1 → emsutil-0.2.2}/.gitignore +0 -0
  9. {emsutil-0.2.1 → emsutil-0.2.2}/.python-version +0 -0
  10. {emsutil-0.2.1 → emsutil-0.2.2}/README.md +0 -0
  11. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/__init__.py +0 -0
  12. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/const.py +0 -0
  13. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/emdata.py +0 -0
  14. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/isola.py +0 -0
  15. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/lib.py +0 -0
  16. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/material.py +0 -0
  17. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/plot/__init__.py +0 -0
  18. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/plot/plot2d.py +0 -0
  19. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/__init__.py +0 -0
  20. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/cmap_maker.py +0 -0
  21. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/display_settings.py +0 -0
  22. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/textures/background.png +0 -0
  23. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/textures/tex1.png +0 -0
  24. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/textures/tex2.png +0 -0
  25. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/textures/tex3.png +0 -0
  26. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/textures/tex4.png +0 -0
  27. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/textures/tex5.png +0 -0
  28. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/textures/tex6.png +0 -0
  29. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/pyvista/utils.py +0 -0
  30. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/rogers.py +0 -0
  31. {emsutil-0.2.1 → emsutil-0.2.2}/src/emsutil/themes.py +0 -0
@@ -1,5 +1,5 @@
1
1
  [tool.bumpversion]
2
- current_version = "0.2.1"
2
+ current_version = "0.2.2"
3
3
  parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
4
4
  serialize = ["{major}.{minor}.{patch}"]
5
5
  search = "{current_version}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: emsutil
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Common utilities for Emerge projects EMerge, Optycal and Heavi
5
5
  Project-URL: Homepage, https://github.com/FennisRobert/emsutil
6
6
  Project-URL: Issues, https://github.com/FennisRobert/emsutil/issues
@@ -4,7 +4,7 @@ allow-direct-references = true
4
4
 
5
5
  [project]
6
6
  name = "emsutil"
7
- version = "0.2.1"
7
+ version = "0.2.2"
8
8
  description = "Common utilities for Emerge projects EMerge, Optycal and Heavi"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -0,0 +1,58 @@
1
+ import numpy as np
2
+ from .strutil import arry_to_line, matrix_to_lines, arry_to_fwl
3
+ from ..emdata import EHFieldFF
4
+
5
+ def export_ffdata(filename: str,
6
+ thetas: np.ndarray,
7
+ phis: np.ndarray,
8
+ frequencies: np.ndarray,
9
+ fields: list[EHFieldFF],
10
+ precision: int = 4) -> None:
11
+
12
+ lines = []
13
+ lines.append('% Theta (deg)')
14
+ lines.append(arry_to_line(thetas, precision=precision))
15
+ lines.append('% Phi (deg)')
16
+ lines.append(arry_to_line(phis, precision=precision))
17
+ lines.append('')
18
+ nF = frequencies.shape[0]
19
+
20
+ actual_frequencies = []
21
+ blocks = []
22
+
23
+ T, P = np.meshgrid(thetas, phis, indexing='ij')
24
+
25
+ thetal = T.flatten()
26
+ phil = P.flatten()
27
+
28
+ for iF in range(nF):
29
+ freq = frequencies[iF]
30
+ actual_frequencies.append(freq)
31
+
32
+ farfield = fields[iF]._E
33
+ Fx = farfield[0,:,:].squeeze().flatten()
34
+ Fy = farfield[1,:,:].squeeze().flatten()
35
+ Fz = farfield[2,:,:].squeeze().flatten()
36
+
37
+ block_lines = []
38
+
39
+ block_lines.append(f'# {freq} (Hz)')
40
+ block_lines.append('$ Theta(deg); Phi(deg); E_x[re](V/m); E_x[im](V/m); E_y[re](V/m); E_y[im](V/m); E_z[re](V/m); E_z[im](V/m)')
41
+ positions = (0, 14, 24, 38, 52, 66, 80, 94)
42
+ for th, ph, ex, ey, ez in zip(thetal, phil, Fx, Fy, Fz):
43
+ re_ex = np.real(ex)
44
+ im_ex = np.imag(ex)
45
+ re_ey = np.real(ey)
46
+ im_ey = np.imag(ey)
47
+ re_ez = np.real(ez)
48
+ im_ez = np.imag(ez)
49
+ line_values = np.array([th, ph, re_ex, im_ex, re_ey, im_ey, re_ez, im_ez])
50
+ line = arry_to_fwl(line_values, positions, precision=precision)
51
+ block_lines.append(line)
52
+
53
+ lines.extend(block_lines)
54
+ lines.extend('')
55
+
56
+ text = '\n'.join(lines)
57
+ with open(filename, 'w') as f:
58
+ f.write(text)
@@ -0,0 +1,22 @@
1
+ import numpy as np
2
+
3
+ def arry_to_line(array: np.ndarray, separator: str = ' ', precision: int = 4) -> str:
4
+ return separator.join([f"{x:.{precision}f}" for x in array.squeeze()])
5
+
6
+ def arry_to_fwl(array: np.ndarray, start_positions: list[int], precision: int = 4) -> str:
7
+ # Place the numbers at the starting position indices provided by the start-positions list
8
+ line_length = max(start_positions) + 10 # Extra space for number
9
+ line = [' ']*line_length
10
+ for i, pos in enumerate(start_positions):
11
+ num_str = f"{array[i]:.{precision}f}"
12
+ for j, ch in enumerate(num_str):
13
+ if pos + j < line_length:
14
+ line[pos + j] = ch
15
+ return ''.join(line)
16
+
17
+ def matrix_to_lines(matrix: np.ndarray, separator: str = ',', precision: int = 4) -> str:
18
+ lines = []
19
+ for row in matrix:
20
+ line = arry_to_line(row, separator, precision)
21
+ lines.append(line)
22
+ return '\n'.join(lines)
@@ -413,7 +413,7 @@ class EMergeDisplay:
413
413
  # Turn off directional lighting
414
414
  self._plot.remove_all_lights()
415
415
 
416
- if self.set.theme.draw_pvgrid:
416
+ if self.set.theme.draw_pvgrid and not self._bwdrawing:
417
417
  pv.set_plot_theme('dark')
418
418
  bounds = self._bounds
419
419
  extra_factor = 0.1
@@ -439,6 +439,10 @@ class EMergeDisplay:
439
439
  else:
440
440
  self._plot.disable_anti_aliasing()
441
441
  self._plot.title = 'EMerge'
442
+ if self._bwdrawing:
443
+ self._plot.set_background('white', top='white') # type: ignore
444
+ else:
445
+ self._plot.set_background(self.set.theme.backgroung_grad_1, top=self.set.theme.backgroung_grad_2) # type: ignore
442
446
 
443
447
  def _reset(self):
444
448
  self._plot.close()
@@ -1369,7 +1373,7 @@ class EMergeDisplay:
1369
1373
  light.set_direction_angle(*self.set.light_angle) # type: ignore
1370
1374
  self._plot.add_light(light)
1371
1375
 
1372
- self._plot.set_background(self.set.theme.backgroung_grad_1, top=self.set.theme.backgroung_grad_2) # type: ignore
1376
+
1373
1377
  self._plot.add_axes(color=self.set.theme.text_color,
1374
1378
  x_color=col_x,
1375
1379
  y_color=col_y,
@@ -279,7 +279,7 @@ wheels = [
279
279
 
280
280
  [[package]]
281
281
  name = "emsutil"
282
- version = "0.2.1"
282
+ version = "0.2.2"
283
283
  source = { editable = "." }
284
284
  dependencies = [
285
285
  { name = "loguru" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes