opticalib 2.4.0__tar.gz → 2.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 (162) hide show
  1. {opticalib-2.4.0/opticalib.egg-info → opticalib-2.5.0}/PKG-INFO +2 -2
  2. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/__init__.py +1 -0
  3. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/_version.py +3 -3
  4. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/analyzer/image_processing.py +9 -5
  5. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/analyzer/timeseries.py +4 -2
  6. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/core/config.py +9 -8
  7. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/core/root.py +8 -6
  8. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/__init__.py +2 -0
  9. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/cameras/GigE_live_viewer.py +8 -3
  10. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/dms/alpaoAPI.py +5 -0
  11. opticalib-2.5.0/opticalib/devices/_API/dms/nacoAPI.py +185 -0
  12. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/__init__.py +10 -1
  13. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/cameras.py +49 -6
  14. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/deformable_mirrors.py +202 -0
  15. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/interferometer.py +5 -6
  16. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/dmutils/_misc.py +7 -7
  17. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/dmutils/flattening.py +5 -5
  18. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/dmutils/iff_processing.py +4 -3
  19. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/ground/_stitching_algorithm.py +13 -0
  20. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/ground/logger.py +17 -2
  21. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/ground/osutils.py +8 -8
  22. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/ground/reconstructor.py +4 -0
  23. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/app.py +107 -11
  24. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/kernel.py +1 -1
  25. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/plugins.py +12 -5
  26. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/widgets/config_editor.py +8 -4
  27. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/widgets/connect_dialog.py +9 -3
  28. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/widgets/data_browser.py +1 -1
  29. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/widgets/device_registry.py +11 -5
  30. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/visualization.py +2 -1
  31. {opticalib-2.4.0 → opticalib-2.5.0/opticalib.egg-info}/PKG-INFO +2 -2
  32. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib.egg-info/SOURCES.txt +4 -0
  33. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib.egg-info/requires.txt +3 -1
  34. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib.egg-info/scm_file_list.json +4 -0
  35. opticalib-2.5.0/opticalib.egg-info/scm_version.json +8 -0
  36. {opticalib-2.4.0 → opticalib-2.5.0}/pyproject.toml +4 -1
  37. {opticalib-2.4.0 → opticalib-2.5.0}/setup_calpy.py +2 -2
  38. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_analyzer_timeseries.py +44 -0
  39. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_devices_cameras.py +15 -1
  40. opticalib-2.5.0/tests/test_devices_cameras_no_vmbpy.py +64 -0
  41. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_devices_interferometer.py +74 -4
  42. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_dmutils_iff_processing.py +3 -3
  43. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_ground_logger.py +84 -0
  44. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_ground_osutils.py +60 -0
  45. opticalib-2.5.0/tests/test_ground_stitching_algorithm.py +63 -0
  46. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_gui_config_editor.py +30 -0
  47. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_gui_devices.py +37 -0
  48. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_gui_widgets.py +102 -0
  49. opticalib-2.5.0/tests/test_portability.py +108 -0
  50. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_setup_calpy.py +5 -3
  51. opticalib-2.4.0/opticalib.egg-info/scm_version.json +0 -8
  52. {opticalib-2.4.0 → opticalib-2.5.0}/CITATION.bib +0 -0
  53. {opticalib-2.4.0 → opticalib-2.5.0}/LICENSE +0 -0
  54. {opticalib-2.4.0 → opticalib-2.5.0}/MANIFEST.in +0 -0
  55. {opticalib-2.4.0 → opticalib-2.5.0}/README.md +0 -0
  56. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/__init_script__/initCalpy.py +0 -0
  57. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/__version__.py +0 -0
  58. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/analyzer/__init__.py +0 -0
  59. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/analyzer/signals.py +0 -0
  60. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/core/__init__.py +0 -0
  61. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/core/_configurations/DOCS.md +0 -0
  62. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/core/_configurations/configuration.yaml +0 -0
  63. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/core/_types.py +0 -0
  64. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/core/data_classes.py +0 -0
  65. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/core/decorators.py +0 -0
  66. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/core/exceptions.py +0 -0
  67. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/core/fitsarray.py +0 -0
  68. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/base_devices.py +0 -0
  69. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/cameras/__init__.py +0 -0
  70. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/cameras/frame_buffer.py +0 -0
  71. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/dms/__init__.py +0 -0
  72. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/dms/micAPI.py +0 -0
  73. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/dms/piAPI.py +0 -0
  74. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/dms/splattAPI.py +0 -0
  75. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/wfs/__init__.py +0 -0
  76. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/wfs/i4dAPI.py +0 -0
  77. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/_API/wfs/pupil_detector.py +0 -0
  78. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/devices/wfs.py +0 -0
  79. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/dmutils/__actuator_identification_wip.py +0 -0
  80. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/dmutils/__init__.py +0 -0
  81. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/dmutils/__pupil_calibration_wip.py +0 -0
  82. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/dmutils/iff_preparation.py +0 -0
  83. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/dmutils/slaving.py +0 -0
  84. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/ground/__init__.py +0 -0
  85. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/ground/geometry.py +0 -0
  86. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/ground/modal_decomposer.py +0 -0
  87. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/ground/roi.py +0 -0
  88. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/__init__.py +0 -0
  89. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/activity.py +0 -0
  90. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/kernel_backend.py +0 -0
  91. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/kernel_side.py +0 -0
  92. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/procedures/__init__.py +0 -0
  93. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/procedures/alignment.py +0 -0
  94. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/procedures/base.py +0 -0
  95. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/procedures/dm_calibration.py +0 -0
  96. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/procedures/params.py +0 -0
  97. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/procedures/phasing.py +0 -0
  98. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/procedures/stitching.py +0 -0
  99. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/procedures/timeseries.py +0 -0
  100. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/resources/opticalib.ico +0 -0
  101. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/resources/opticalib.png +0 -0
  102. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/resources/opticalib.svg +0 -0
  103. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/theme.py +0 -0
  104. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/widgets/__init__.py +0 -0
  105. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/widgets/common.py +0 -0
  106. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/widgets/device_panel.py +0 -0
  107. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/widgets/plot_viewer.py +0 -0
  108. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/gui/widgets/workspace.py +0 -0
  109. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/procedures/__init__.py +0 -0
  110. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/procedures/alignment.py +0 -0
  111. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/procedures/iff.py +0 -0
  112. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/procedures/measurements.py +0 -0
  113. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/procedures/phasing.py +0 -0
  114. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/procedures/stitching.py +0 -0
  115. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/py.typed +0 -0
  116. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/simulator/_API/__init__.py +0 -0
  117. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/simulator/_API/alpao_conf.yaml +0 -0
  118. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/simulator/_API/base_fake_adopticadm.py +0 -0
  119. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/simulator/_API/base_fake_alpao.py +0 -0
  120. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/simulator/_API/base_petalmirror.py +0 -0
  121. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/simulator/_API/base_simulated_dm.py +0 -0
  122. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/simulator/_API/simdata.py +0 -0
  123. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/simulator/__init__.py +0 -0
  124. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/simulator/factory.py +0 -0
  125. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/simulator/fake_dms.py +0 -0
  126. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib/simulator/fake_interf.py +0 -0
  127. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib.egg-info/dependency_links.txt +0 -0
  128. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib.egg-info/entry_points.txt +0 -0
  129. {opticalib-2.4.0 → opticalib-2.5.0}/opticalib.egg-info/top_level.txt +0 -0
  130. {opticalib-2.4.0 → opticalib-2.5.0}/pytest.ini +0 -0
  131. {opticalib-2.4.0 → opticalib-2.5.0}/setup.cfg +0 -0
  132. {opticalib-2.4.0 → opticalib-2.5.0}/tests/README.md +0 -0
  133. {opticalib-2.4.0 → opticalib-2.5.0}/tests/__init__.py +0 -0
  134. {opticalib-2.4.0 → opticalib-2.5.0}/tests/conftest.py +0 -0
  135. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_analyzer_images_processing.py +0 -0
  136. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_analyzer_signals.py +0 -0
  137. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_core_dataclass.py +0 -0
  138. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_core_exceptions.py +0 -0
  139. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_core_fits.py +0 -0
  140. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_core_read_config.py +0 -0
  141. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_core_root.py +0 -0
  142. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_devices_deformable_mirrors.py +0 -0
  143. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_devices_wfs.py +0 -0
  144. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_dmutils_flattening.py +0 -0
  145. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_dmutils_iff_acquisition_preparation.py +0 -0
  146. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_dmutils_iff_module.py +0 -0
  147. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_dmutils_iff_normalization.py +0 -0
  148. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_dmutils_slaving.py +0 -0
  149. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_ground_computerec.py +0 -0
  150. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_ground_geometry.py +0 -0
  151. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_ground_modal_decomposer.py +0 -0
  152. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_ground_roi.py +0 -0
  153. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_gui_activity.py +0 -0
  154. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_gui_app.py +0 -0
  155. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_gui_kernel_bridge.py +0 -0
  156. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_gui_kernel_side.py +0 -0
  157. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_gui_procedures.py +0 -0
  158. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_measurements.py +0 -0
  159. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_simulator_factory_functions.py +0 -0
  160. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_simulator_run_cmd_history.py +0 -0
  161. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_simulator_simdata.py +0 -0
  162. {opticalib-2.4.0 → opticalib-2.5.0}/tests/test_typings.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opticalib
3
- Version: 2.4.0
3
+ Version: 2.5.0
4
4
  Summary: This package is a python interface for laboratory adaptive optics systems, with a focus on the calibration of deformable mirrors (DMs) and the acquisition of wavefront data using wavefront sensors.
5
5
  Author-email: Adaptive Optics Group - INAF - Osservatorio Astrofisico di Arcetri <pietro.ferraiuolo@inaf.it>
6
6
  Maintainer-email: Pietro Ferraiuolo <pietro.ferraiuolo@inaf.it>
@@ -23,7 +23,7 @@ Requires-Dist: arte
23
23
  Requires-Dist: astropy
24
24
  Requires-Dist: scikit-image
25
25
  Requires-Dist: scikit-learn
26
- Requires-Dist: vmbpy
26
+ Requires-Dist: vmbpy; sys_platform != "darwin"
27
27
  Requires-Dist: pipython
28
28
  Requires-Dist: photutils
29
29
  Requires-Dist: scipy
@@ -38,6 +38,7 @@ from . import (
38
38
  simulator,
39
39
  visualization,
40
40
  )
41
+
41
42
  vis = visualization
42
43
 
43
44
  from .devices.interferometer import _4DInterferometer
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '2.4.0'
22
- __version_tuple__ = version_tuple = (2, 4, 0)
21
+ __version__ = version = '2.5.0'
22
+ __version_tuple__ = version_tuple = (2, 5, 0)
23
23
 
24
- __commit_id__ = commit_id = 'ga3a0a791f'
24
+ __commit_id__ = commit_id = 'g87bbaaf2e'
@@ -293,7 +293,9 @@ def push_pull_reduction_algorithm(
293
293
  return image
294
294
 
295
295
 
296
- def create_cube(fl_or_il: list[str]|list[_ot.ImageData], register: bool = False) -> _ot.CubeData:
296
+ def create_cube(
297
+ fl_or_il: list[str] | list[_ot.ImageData], register: bool = False
298
+ ) -> _ot.CubeData:
297
299
  """
298
300
  Creates a cube of images from an images file list
299
301
 
@@ -317,7 +319,10 @@ def create_cube(fl_or_il: list[str]|list[_ot.ImageData], register: bool = False)
317
319
  memmap = True
318
320
  # check it is a list
319
321
  if not isinstance(fl_or_il, list):
320
- raise TypeError("filelist must be a list of strings or images")
322
+ if isinstance(fl_or_il, str) or _ot.isinstance_(fl_or_il, "ImageData"):
323
+ fl_or_il = [fl_or_il]
324
+ else:
325
+ raise TypeError("filelist must be a list of strings or images")
321
326
 
322
327
  # check if it is composed of file paths to load
323
328
  if all([isinstance(item, str) for item in fl_or_il]):
@@ -356,9 +361,8 @@ def create_cube(fl_or_il: list[str]|list[_ot.ImageData], register: bool = False)
356
361
 
357
362
  if len(fl_or_il) == 1:
358
363
  return _np.expand_dims(
359
- _fa.fits_array(fl_or_il[0], header=header),
360
- axis=2
361
- )
364
+ _fa.fits_array(fl_or_il[0], header=header), axis=2
365
+ ).copy()
362
366
 
363
367
  return _fa.fits_array(_np.ma.dstack(fl_or_il), header=header)
364
368
 
@@ -53,7 +53,9 @@ def average_frames(
53
53
  s = slice(first, last) if last != -1 else slice(first, None)
54
54
 
55
55
  if osu.is_tn(tn_or_fl):
56
- fl = osu.get_file_list(tn_or_fl, fold=_OPDSER.split("/")[-1], key="20")
56
+ fl = osu.get_file_list(
57
+ tn_or_fl, fold=_os.path.basename(_os.path.normpath(_OPDSER)), key="20"
58
+ )
57
59
  fl = fl[s] if file_selector is None else fl[file_selector]
58
60
  imcube = _ip.create_cube(fl)
59
61
  elif _ot.isinstance_(tn_or_fl, "CubeData"):
@@ -267,7 +269,7 @@ def timevec(tn: str) -> _ot.ArrayLike:
267
269
  flist = osu.get_file_list(tn, key="20")
268
270
  timevector = []
269
271
  for f in flist:
270
- tni = (f.split("/")[-1]).replace(".fits", "")
272
+ tni = _os.path.splitext(_os.path.basename(f))[0]
271
273
  jdi = _track2jd(tni)
272
274
  timevector.append(jdi)
273
275
  timevector = _np.array(timevector)
@@ -141,7 +141,7 @@ def load(path: str | None = None) -> dict[str, _Any]:
141
141
  The configuration dictionary.
142
142
  """
143
143
  fname = _resolve_config_path(path)
144
- with open(fname, "r") as f:
144
+ with open(fname, "r", encoding="utf-8") as f:
145
145
  config = yaml.safe_load(f) or {}
146
146
  return config
147
147
 
@@ -158,7 +158,7 @@ def dump(config: dict[str, _Any], path: str | None = None) -> None:
158
158
  Base path of the file to write. Default points to the configuration root folder.
159
159
  """
160
160
  fname = _resolve_config_path(path)
161
- with open(fname, "w") as f:
161
+ with open(fname, "w", encoding="utf-8") as f:
162
162
  yaml.safe_dump(config, f, sort_keys=False)
163
163
 
164
164
 
@@ -370,6 +370,7 @@ def get_device_config(device_type: str, device_name: str | None = None):
370
370
  # | IFF configuration section handling |#
371
371
  ### ------------------------------------------------------------------------ ###
372
372
 
373
+
373
374
  def get_iff_config(key: str | None, bpath: str = _cfold):
374
375
  """
375
376
  Reads the configuration from the YAML file for the IFF acquisition.
@@ -448,9 +449,9 @@ def copy_iff_config_file(tn: str, old_path: str = _cfold):
448
449
  """
449
450
  config = _get_section_config(section="INFLUENCE.FUNCTIONS", path=old_path)
450
451
  nfname = _os.path.join(_iffold, tn, "iffConfig.yaml")
451
- with open(nfname, "w") as f:
452
+ with open(nfname, "w", encoding="utf-8") as f:
452
453
  yaml.safe_dump(config, f, sort_keys=False)
453
- print(f"IFF configuration copied to {nfname.rsplit('/' + yaml_config_file, 1)[0]}")
454
+ print(f"IFF configuration copied to {_os.path.dirname(nfname)}")
454
455
  return nfname
455
456
 
456
457
 
@@ -497,10 +498,12 @@ def update_iff_config(tn: str, item: str | list[str], value: _Any | list[_Any]):
497
498
  config[key][item] = str(value)
498
499
  dump(config, file)
499
500
 
501
+
500
502
  ### ------------------------------------------------------------------------ ###
501
503
  # | General utilities |#
502
504
  ### ------------------------------------------------------------------------ ###
503
505
 
506
+
504
507
  def get_configuration_version(path: str | None = None) -> str | None:
505
508
  """
506
509
  Retrieves the version of the configuration from the YAML configuration file.
@@ -651,10 +654,12 @@ def _parse_val(val: _Any):
651
654
  raise ValueError(f"Value type {type(val)} could not be recognized.")
652
655
  return val
653
656
 
657
+
654
658
  ### ------------------------------------------------------------------------ ###
655
659
  # | Legacy configuration handling. To be checked |#
656
660
  ### ------------------------------------------------------------------------ ###
657
661
 
662
+
658
663
  def get_cmd_delay(bpath: str = _cfold):
659
664
  """
660
665
  Retrieves the command delay from the YAML configuration file.
@@ -685,8 +690,6 @@ def get_cmd_delay(bpath: str = _cfold):
685
690
  return cmdDelay
686
691
 
687
692
 
688
-
689
-
690
693
  def get_cameras_config(device_name: str = None):
691
694
  """
692
695
  Reads the cameras settings in the configuration file.
@@ -806,8 +809,6 @@ def get_stitching_config():
806
809
  return config
807
810
 
808
811
 
809
-
810
-
811
812
  def get_phasing_config():
812
813
  """
813
814
  Retrieves the phasing configuration from the YAML configuration file.
@@ -108,12 +108,12 @@ def _stamp_created_with(file: str, data_path: str | None = None) -> None:
108
108
  from ..__version__ import __version__
109
109
 
110
110
  try:
111
- with open(file, "r") as _f:
111
+ with open(file, "r", encoding="utf-8") as _f:
112
112
  config = _gyml.load(_f)
113
113
  config["SYSTEM"]["created_with"] = str(__version__)
114
114
  if data_path is not None:
115
115
  config["SYSTEM"]["data_path"] = data_path
116
- with open(file, "w") as _f:
116
+ with open(file, "w", encoding="utf-8") as _f:
117
117
  _gyml.dump(config, _f)
118
118
  except (OSError, KeyError, TypeError) as exc:
119
119
  import warnings
@@ -166,13 +166,15 @@ def create_configuration_file(path: str = "", data_path: str | bool = False) ->
166
166
  print(f"Configuration file moved to {conf_folder}")
167
167
 
168
168
 
169
- TEMPLATE_CONF_FILE: str = (
170
- _os.path.dirname(_os.path.abspath(__file__)) + "/_configurations/configuration.yaml"
169
+ TEMPLATE_CONF_FILE: str = _os.path.join(
170
+ _os.path.dirname(_os.path.abspath(__file__)),
171
+ "_configurations",
172
+ "configuration.yaml",
171
173
  )
172
174
  CONFIGURATION_ROOT_FOLDER: str = _os.path.dirname(TEMPLATE_CONF_FILE)
173
175
  CONFIGURATION_FILE: str = _os.getenv("AOCONF", TEMPLATE_CONF_FILE)
174
176
 
175
- with open(CONFIGURATION_FILE, "r") as _f:
177
+ with open(CONFIGURATION_FILE, "r", encoding="utf-8") as _f:
176
178
  _config = _gyml.load(_f)
177
179
 
178
180
  _bdp = _config["SYSTEM"].get("data_path")
@@ -187,7 +189,7 @@ if BASE_DATA_PATH == _fallback_bdp:
187
189
  if not _os.path.exists(CONFIGURATION_FILE):
188
190
  _copy(TEMPLATE_CONF_FILE, CONFIGURATION_FILE)
189
191
  _stamp_created_with(CONFIGURATION_FILE)
190
- with open(CONFIGURATION_FILE, "r") as _f:
192
+ with open(CONFIGURATION_FILE, "r", encoding="utf-8") as _f:
191
193
  _config = _gyml.load(_f)
192
194
 
193
195
  OPT_DATA_ROOT_FOLDER: str = _os.path.join(BASE_DATA_PATH, "OPTData")
@@ -18,6 +18,7 @@ from .wfs.i4dAPI import I4D
18
18
  from .base_devices import BaseWavefrontSensor, BaseDeformableMirror, BaseCamera
19
19
  from .dms.micAPI import BaseAdOpticaDm
20
20
  from .dms.piAPI import BasePetalMirror
21
+ from .dms.nacoAPI import NACOMirror
21
22
 
22
23
  __all__ = [
23
24
  "SPLATTEngine",
@@ -28,4 +29,5 @@ __all__ = [
28
29
  "BaseAdOpticaDm",
29
30
  "BasePetalMirror",
30
31
  "BaseCamera",
32
+ "NACOMirror",
31
33
  ]
@@ -32,6 +32,10 @@ reader, so a slow GUI can never slow down the acquisition. (Caveat: numpy
32
32
  issues no memory fences, so this relies on the CPU not reordering the stores,
33
33
  as on x86; on ARM a torn frame could rarely slip through: a cosmetic glitch.)
34
34
 
35
+ .. note::
36
+ The live viewer is POSIX-only (Linux and macOS): it is not supported on
37
+ Windows.
38
+
35
39
  This file has two roles:
36
40
 
37
41
  - imported by ``opticalib`` (parent side): ``ViewerProcess`` starts the child
@@ -78,10 +82,11 @@ class SharedFrame:
78
82
  # Before 3.13, attaching registers the block with this process'
79
83
  # resource tracker, which would *delete* it when the child exits,
80
84
  # although the parent owns it. Unregister to prevent that.
81
- from multiprocessing import resource_tracker
82
-
83
85
  shm = shared_memory.SharedMemory(name=name)
84
- resource_tracker.unregister(shm._name, "shared_memory")
86
+ if os.name == "posix":
87
+ from multiprocessing import resource_tracker
88
+
89
+ resource_tracker.unregister(shm._name, "shared_memory")
85
90
  return cls(shm, shape, dtype)
86
91
 
87
92
  # --- writer side (parent, called from the camera SDK thread) ------------
@@ -111,6 +111,11 @@ class BaseAlpaoMirror(BaseDeformableMirror):
111
111
  Any hardware-level exception raised by the underlying backend
112
112
  on connection failure is propagated to the caller.
113
113
  """
114
+ if nacts is not None:
115
+ self._name = f"Alpao{nacts}"
116
+ else:
117
+ self._name = "Alpao"
118
+
114
119
  self._resolve_init(sdk_params, plico_params)
115
120
  self._is_plico = bool(plico_params[0])
116
121
 
@@ -0,0 +1,185 @@
1
+ import numpy as _np
2
+ import socket
3
+ from opticalib.core.config import get_section_config
4
+ from opticalib.core.exceptions import CommandError
5
+ from opticalib.core import _types as _t
6
+ from ..base_devices import BaseDeformableMirror
7
+
8
+
9
+ class NACOMirror(BaseDeformableMirror):
10
+ """
11
+ Class to send commands to the NACO deformable mirror via PLC.
12
+
13
+ The NACO mirror has no built-in position readback, so the last
14
+ commanded vector is cached internally and returned by
15
+ :meth:`get_shape`.
16
+
17
+ Parameters
18
+ ----------
19
+ host : str
20
+ IP address or hostname of the NACO mirror.
21
+ port : int
22
+ Port number for the PLC connection.
23
+ """
24
+
25
+ def __init__(
26
+ self,
27
+ host: str,
28
+ port: int,
29
+ reply_timeout: float = 1.0,
30
+ ) -> None:
31
+ """
32
+ Initialize the NACO mirror interface.
33
+
34
+
35
+ Parameters
36
+ ----------
37
+ host : str
38
+ IP address or hostname of the NACO mirror.
39
+ port : int
40
+ Port number for the PLC connection.
41
+ reply_timeout : float, optional
42
+ Seconds to wait for the PLC reply after each command.
43
+ Default is 1.0.
44
+
45
+ Raises
46
+ ------
47
+ socket.gaierror
48
+ If *host* cannot be resolved.
49
+ """
50
+ self._host = host
51
+ self._port = port
52
+ self._reply_timeout = reply_timeout
53
+ # A connected UDP socket only receives datagrams from the PLC
54
+ self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
55
+ self._sock.connect((host, port))
56
+ self.last_reply: _t.ArrayLike | None = None
57
+
58
+ self.n_acts = 185
59
+ self._dmCoords = {
60
+ "dm185": [7, 9, 11, 13, 15],
61
+ }
62
+
63
+ self._last_cmd: _t.ArrayLike = _np.zeros(self.n_acts)
64
+ self._name = f"NACO{self.n_acts}"
65
+ self.act_coord = self._init_act_coord()
66
+ self.cmdHistory = None
67
+ self.refAct = None
68
+
69
+ # ------------------------------------------------------------------
70
+ # SDK-level interface
71
+ # ------------------------------------------------------------------
72
+
73
+ def get_shape(self) -> _t.ArrayLike:
74
+ """
75
+ Return the last commanded actuator positions.
76
+
77
+ The NACO mirror does not provide a hardware readback; the last
78
+ vector sent via :meth:`set_shape` is returned instead.
79
+
80
+ Returns
81
+ -------
82
+ numpy.ndarray
83
+ Array of length ``n_acts`` with the
84
+ last commanded positions (zeros before the first command).
85
+ """
86
+ return self._last_cmd.copy()
87
+
88
+ def set_shape(self, cmd: _t.ArrayLike) -> None:
89
+ """
90
+ Send an absolute command vector to the NACO mirror via the PLC.
91
+
92
+ Data is sent as an UDP packet with 185 values in raw float32 format.
93
+ The PLC will convert the values to the appropriate DAC units and send them to the mirror.
94
+
95
+ The PLC replies to every packet: with the 185 computed actuator
96
+ commands (raw float32) on success, or with a short error string
97
+ if the packet was malformed. This method waits for that reply and
98
+ stores the returned commands in ``last_reply``.
99
+
100
+ Parameters
101
+ ----------
102
+ cmd : array_like
103
+ Command vector of length ``n_acts``.
104
+
105
+ Raises
106
+ ------
107
+ CommandError
108
+ If the length of *cmd* does not match the number of
109
+ actuators, if no reply is received from the PLC within
110
+ the timeout, or if the PLC replies with an error.
111
+ """
112
+ cmd = _np.asarray(cmd, dtype=float)
113
+ if cmd.size != self.n_acts:
114
+ raise CommandError(
115
+ f"Command length {cmd.size} does not match the number "
116
+ f"of actuators ({self.n_acts})."
117
+ )
118
+ # Discard stale replies (e.g. a late answer to a timed-out command)
119
+ self._sock.setblocking(False)
120
+ try:
121
+ while True:
122
+ self._sock.recv(65535)
123
+ except OSError: # nothing left to read
124
+ pass
125
+ self._sock.settimeout(self._reply_timeout)
126
+ # Send UDP packet to PLC (raw float32) and wait for its reply
127
+ self._sock.send(cmd.astype(_np.float32).tobytes())
128
+ try:
129
+ reply = self._sock.recv(65535)
130
+ except OSError as e: # timeout, or ICMP port unreachable
131
+ raise CommandError(
132
+ f"No reply from NACO PLC at {self._host}:{self._port}: {e!r}"
133
+ ) from e
134
+ if len(reply) != 4 * self.n_acts:
135
+ raise CommandError(f"NACO PLC rejected the command, reply: {reply!r}")
136
+ self.last_reply = _np.frombuffer(reply, dtype=_np.float32).astype(float)
137
+ self._last_cmd = cmd.copy()
138
+
139
+ # ------------------------------------------------------------------
140
+ # Higher-level helpers
141
+ # ------------------------------------------------------------------
142
+
143
+ @property
144
+ def n_actuators(self) -> int:
145
+ """Number of actuators on the DM."""
146
+ return self.n_acts
147
+
148
+ # ------------------------------------------------------------------
149
+ # Private initialisation helpers
150
+ # ------------------------------------------------------------------
151
+
152
+ def _init_act_coord(self) -> _t.ArrayLike:
153
+ """
154
+ Build the 2-D actuator coordinate array from the DM layout table.
155
+
156
+ Returns
157
+ -------
158
+ numpy.ndarray or None
159
+ Array of shape ``(2, n_acts)`` with ``(x, y)`` pixel
160
+ coordinates, or an empty array if the model is unknown.
161
+ """
162
+ try:
163
+ nacts_row_sequence = self._dmCoords[f"dm{self.n_acts}"]
164
+ except KeyError:
165
+ self.act_coord = _np.array([], dtype=int)
166
+ return
167
+ n_dim = nacts_row_sequence[-1]
168
+ upper_rows = nacts_row_sequence[:-1]
169
+ lower_rows = list(reversed(upper_rows))
170
+ center_rows = [n_dim] * upper_rows[0]
171
+ rows_number_of_acts = upper_rows + center_rows + lower_rows
172
+ n_rows = len(rows_number_of_acts)
173
+ cx = _np.array([], dtype=int)
174
+ cy = _np.array([], dtype=int)
175
+ for i in range(n_rows):
176
+ cx = _np.concatenate(
177
+ (
178
+ cx,
179
+ _np.arange(rows_number_of_acts[i])
180
+ + (n_dim - rows_number_of_acts[i]) // 2,
181
+ )
182
+ )
183
+ cy = _np.concatenate((cy, _np.full(rows_number_of_acts[i], i)))
184
+ self.act_coord = _np.array([cx, cy])
185
+ return self.act_coord
@@ -14,7 +14,15 @@ deformable mirrors, INGO-T WFS, and Allied Vision GigE cameras.
14
14
  """
15
15
 
16
16
  from .interferometer import PhaseCam, AccuFiz, Processer4D
17
- from .deformable_mirrors import SplattDm, AlpaoDm, AdOpticaDm, DP, M4AU, PetalMirror
17
+ from .deformable_mirrors import (
18
+ SplattDm,
19
+ AlpaoDm,
20
+ AdOpticaDm,
21
+ DP,
22
+ M4AU,
23
+ PetalMirror,
24
+ NACODm,
25
+ )
18
26
  from .wfs import Ingot
19
27
  from .cameras import GigaVision
20
28
 
@@ -30,4 +38,5 @@ __all__ = [
30
38
  "GigaVision",
31
39
  "Ingot",
32
40
  "PetalMirror",
41
+ "NACODm",
33
42
  ]
@@ -8,10 +8,21 @@ and frame retrieval.
8
8
 
9
9
  """
10
10
 
11
+ import sys as _sys
11
12
  import time as _time
12
- import vmbpy as _vmbpy
13
13
  import threading as _th
14
14
 
15
+ try:
16
+ import vmbpy as _vmbpy
17
+
18
+ _VMBPY_IMPORT_ERROR = None
19
+ except ImportError as _exc:
20
+ # vmbpy ships no wheels for macOS (only Linux and Windows): keep
21
+ # ``opticalib.devices`` importable there, GigaVision raises on creation
22
+ # (chaining this error, which also reveals a broken install elsewhere).
23
+ _vmbpy = None
24
+ _VMBPY_IMPORT_ERROR = _exc
25
+
15
26
  from ..core import _types as _ot
16
27
  from ..core.decorators import allow_reconnect as _ar
17
28
  from ..ground.logger import SystemLogger as _sl
@@ -20,8 +31,17 @@ from ._API.base_devices import BaseCamera
20
31
  from ._API.cameras.frame_buffer import FrameBuffer as _FrameBuffer
21
32
  from ._API.cameras.GigE_live_viewer import ViewerProcess as _ViewerProcess
22
33
 
34
+ # SDK exceptions retried by ``allow_reconnect``. Without vmbpy the camera
35
+ # cannot be created, so only the generic errors are left.
36
+ if _vmbpy is not None:
37
+ _FEATURE_ERRORS = (_vmbpy.VmbFeatureError, AttributeError)
38
+ _ACQUISITION_ERRORS = (_vmbpy.VmbCameraError, _vmbpy.VmbTimeout, AttributeError)
39
+ else:
40
+ _FEATURE_ERRORS = (AttributeError,)
41
+ _ACQUISITION_ERRORS = (AttributeError,)
42
+
23
43
 
24
- def _frame_to_array(frame: _vmbpy.Frame) -> _ot.ImageData:
44
+ def _frame_to_array(frame: "_vmbpy.Frame") -> _ot.ImageData:
25
45
  """Copy a Vimba frame into a numpy array: (H, W) mono, (C, H, W) color."""
26
46
  img = frame.as_numpy_ndarray() # a *view* on the SDK buffer, shape (H, W, C)
27
47
  img = img[:, :, 0] if img.shape[2] == 1 else img.transpose(2, 0, 1)
@@ -40,7 +60,18 @@ class GigaVision(BaseCamera):
40
60
  name : str
41
61
  The name of the camera to be used, as defined in the configuration
42
62
  file.
63
+
64
+ Raises
65
+ ------
66
+ ImportError
67
+ If ``vmbpy`` is not installed (it has no macOS distribution).
43
68
  """
69
+ if _vmbpy is None:
70
+ raise ImportError(
71
+ "GigaVision needs the Allied Vision 'vmbpy' package (Vimba X "
72
+ "SDK), which could not be imported. It is distributed only for "
73
+ "Linux and Windows: there, install it with 'pip install vmbpy'."
74
+ ) from _VMBPY_IMPORT_ERROR
44
75
  self._name = name
45
76
  self._cam_config = _gcc(device_name=self._name)
46
77
  self._logger = _sl(__class__)
@@ -202,7 +233,7 @@ class GigaVision(BaseCamera):
202
233
  finally:
203
234
  self._vimba = None
204
235
 
205
- @_ar(error_instance=(_vmbpy.VmbFeatureError, AttributeError))
236
+ @_ar(error_instance=_FEATURE_ERRORS)
206
237
  def get_exptime(self) -> float:
207
238
  """
208
239
  Get the exposure time of the camera in micro-seconds.
@@ -217,7 +248,7 @@ class GigaVision(BaseCamera):
217
248
  self._exptime = exptimeFeat.get()
218
249
  return self._exptime
219
250
 
220
- @_ar(error_instance=(_vmbpy.VmbFeatureError, AttributeError))
251
+ @_ar(error_instance=_FEATURE_ERRORS)
221
252
  def set_exptime(self, exptime_us: float):
222
253
  """
223
254
  Set the exposure time of the camera.
@@ -284,7 +315,9 @@ class GigaVision(BaseCamera):
284
315
  self._buffer.interrupt() # waiters raise now, not at timeout
285
316
  self._buffer.clear() # free the memory of the stored frames
286
317
 
287
- def _on_frame(self, cam: _vmbpy.Camera, stream: _vmbpy.Stream, frame: _vmbpy.Frame):
318
+ def _on_frame(
319
+ self, cam: "_vmbpy.Camera", stream: "_vmbpy.Stream", frame: "_vmbpy.Frame"
320
+ ):
288
321
  """
289
322
  Frame handler: runs in the **Vimba SDK thread**, once per frame.
290
323
 
@@ -306,7 +339,7 @@ class GigaVision(BaseCamera):
306
339
  # always give the buffer back to the camera, even on errors
307
340
  cam.queue_frame(frame)
308
341
 
309
- @_ar(error_instance=(_vmbpy.VmbCameraError, _vmbpy.VmbTimeout, AttributeError))
342
+ @_ar(error_instance=_ACQUISITION_ERRORS)
310
343
  def acquire_frames(
311
344
  self,
312
345
  nframes: int | None = None,
@@ -454,7 +487,17 @@ class GigaVision(BaseCamera):
454
487
  accepted by ``imshow`` (e.g. ``cmap``, ``vmin``, ``vmax``). Must
455
488
  be JSON-serializable. Giving ``vmin``/``vmax`` disables
456
489
  autoscaling.
490
+
491
+ Raises
492
+ ------
493
+ NotImplementedError
494
+ On Windows: the live view is available only on Linux and macOS.
457
495
  """
496
+ if _sys.platform == "win32":
497
+ raise NotImplementedError(
498
+ "GigaVision live view is available only on Linux and macOS "
499
+ "(it relies on POSIX shared memory and process handling)."
500
+ )
458
501
  if self.is_live:
459
502
  self._logger.info("Live view already running")
460
503
  return