OAM-KIST 0.2.15__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.
- oam_kist-0.2.15/OAM_KIST/__init__.py +7 -0
- oam_kist-0.2.15/OAM_KIST/holography.py +118 -0
- oam_kist-0.2.15/OAM_KIST/utils.py +25 -0
- oam_kist-0.2.15/OAM_KIST.egg-info/PKG-INFO +62 -0
- oam_kist-0.2.15/OAM_KIST.egg-info/SOURCES.txt +11 -0
- oam_kist-0.2.15/OAM_KIST.egg-info/dependency_links.txt +1 -0
- oam_kist-0.2.15/OAM_KIST.egg-info/requires.txt +4 -0
- oam_kist-0.2.15/OAM_KIST.egg-info/top_level.txt +1 -0
- oam_kist-0.2.15/PKG-INFO +62 -0
- oam_kist-0.2.15/README.md +39 -0
- oam_kist-0.2.15/setup.cfg +4 -0
- oam_kist-0.2.15/setup.py +38 -0
- oam_kist-0.2.15/tests/test_core.py +59 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import cv2
|
|
5
|
+
from scipy.special import factorial, eval_genlaguerre
|
|
6
|
+
|
|
7
|
+
from .utils import inv_sinc
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def generate_oam_superposition(res, pixel_pitch, beam_w0, l_modes, p_modes, weights):
|
|
11
|
+
""" Creat E field of superimposed OAM mode (Interferogram method)
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
res (list[int]): resolution of SLM. [x resolution, y resolution]
|
|
15
|
+
pixel_pitch (float): pixel size. specified at device document
|
|
16
|
+
beam_w0 (float): beam-waist at z=0.
|
|
17
|
+
l_modes (list[int]): selected l indices for superposion. list with length 1 for eigen mode
|
|
18
|
+
weights (list[float]): weights for selected l modes.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
np.ndarray[float], np.ndarray[float], np.ndarray[float], np.ndarray[float]: information about E field and meshgrid i.e. superimosed
|
|
22
|
+
|
|
23
|
+
Example:
|
|
24
|
+
>>> res = [1920, 1080]
|
|
25
|
+
>>> pixel_pitch = 8e-1
|
|
26
|
+
>>> beam_w0 = 0.8e-3
|
|
27
|
+
>>> l_modes = [-3, -1, 1, 3]
|
|
28
|
+
>>> weights = [0.4, 0.03, 0.07, 0.5]
|
|
29
|
+
>>> amp, phase, X, Y = generate_oam_superposition(res, pixel_pitch, beam_w0, l_modes, weights)
|
|
30
|
+
"""
|
|
31
|
+
x = np.linspace(-res[0] * pixel_pitch / 2, res[0] * pixel_pitch / 2, res[0])
|
|
32
|
+
y = np.linspace(-res[1] * pixel_pitch / 2, res[1] * pixel_pitch / 2, res[1])
|
|
33
|
+
X, Y = np.meshgrid(x, y)
|
|
34
|
+
|
|
35
|
+
R = np.sqrt(X ** 2 + Y ** 2)
|
|
36
|
+
Phi = np.arctan2(Y, X)
|
|
37
|
+
|
|
38
|
+
R[R == 0] = 1e-10
|
|
39
|
+
|
|
40
|
+
E_total = np.zeros_like(Phi, dtype=complex)
|
|
41
|
+
for l, p, w in zip(l_modes, p_modes, weights):
|
|
42
|
+
C = np.sqrt(2 * factorial(p)/(np.pi*factorial(np.abs(l))))
|
|
43
|
+
E_total += w * C * ((np.sqrt(2) * R / beam_w0) ** abs(l)) * eval_genlaguerre(p,abs(l),2*((R**2)/(beam_w0**2))) * np.exp(-(R**2) / (beam_w0**2)) * np.exp(-1j * l * Phi)
|
|
44
|
+
|
|
45
|
+
Amp = np.abs(E_total)
|
|
46
|
+
Phase = np.angle(E_total)
|
|
47
|
+
|
|
48
|
+
return Amp, Phase, X, Y
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def encode_hologram(Amp, Phase, X, Y, pixel_pitch, d, N_steps=0, M=1, prepare=False, measure=False, save=False, path="", name=""):
|
|
52
|
+
"""phase mask for given amplitude and phase map of superimposed OAM mode.
|
|
53
|
+
|
|
54
|
+
입력받은 위상, 진폭 정보를 논문 공식에 대입하여 이 상태를 인코딩하는 SLM 홀로그램을 생성합니다.
|
|
55
|
+
Fundamental Gaussian 모드와의 분리를 위해서 간격이 d 픽셀인 그레이팅이 적용됩니다.
|
|
56
|
+
상태 준비에 사용될지, 측정에 사용될지에 따라서 그레이팅의 방향이 바뀝니다. 변수 parity가 이것을 반영합니다.
|
|
57
|
+
생성된 홀로그램을 저장할 수 있습니다.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
Amp (np.ndarray[float]): amplitude map of superimposed OAM mode. 0. <= *Amp <= 1.
|
|
61
|
+
Phase (np.ndarray[float]): phase map of superimposed OAM mode. -pi < *Phase <= pi
|
|
62
|
+
X (np.ndarray[float]): x dependent meshgrid.
|
|
63
|
+
Y (np.ndarray[float]): y dependent meshgrid.
|
|
64
|
+
pixel_pitch (float): pixel size. specified at device document
|
|
65
|
+
d (float): grating width. dimension in # of pixel
|
|
66
|
+
N_steps (float): number of steps per grating with period d. N_steps=0 is equal to N_steps=d (continuous)
|
|
67
|
+
M (int): phase depth. M is basically 1
|
|
68
|
+
prepare (bool): decide whether to prepare.
|
|
69
|
+
measure (bool): decide whether to measure.
|
|
70
|
+
save (bool): decide whether to save.
|
|
71
|
+
path (string): directory path for images. needed only when arg save is True
|
|
72
|
+
name (string): filename of this image. needed only when arg save is True
|
|
73
|
+
|
|
74
|
+
Return:
|
|
75
|
+
np.ndarray[float] or None: returns carculated hologram.
|
|
76
|
+
if arg save is False(default), a hologram in numpy ndarray. And if not, hologram is saved in the directory addording to arg path.
|
|
77
|
+
|
|
78
|
+
Example:
|
|
79
|
+
>>> res = [1920, 1080]
|
|
80
|
+
>>> pixel_pitch = 8e-1
|
|
81
|
+
>>> beam_w0 = 0.8e-3
|
|
82
|
+
>>> l_modes = [-3, -1, 1, 3]
|
|
83
|
+
>>> weights = [0.4, 0.03, 0.07, 0.5]
|
|
84
|
+
>>> amp, phase, X, Y = generate_oam_superposition(res, pixel_pitch, beam_w0, l_modes, weights)
|
|
85
|
+
>>> encode_hologram(amp, phase, X, Y, pixel_pitch, 16, 0, prepare=True, save=True, path="./images", name="l8_dim16")
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
modified_amp = 1 + (1/np.pi)*inv_sinc(Amp)
|
|
89
|
+
modified_amp = modified_amp / np.max(modified_amp)
|
|
90
|
+
modified_phase = Phase - np.pi*modified_amp
|
|
91
|
+
|
|
92
|
+
parity = 0
|
|
93
|
+
if prepare: parity = -1
|
|
94
|
+
elif measure: parity = 1
|
|
95
|
+
|
|
96
|
+
if N_steps==0: N_steps = d
|
|
97
|
+
res = np.shape(X)[1]
|
|
98
|
+
X_normalized = (X + (res*pixel_pitch/2))/(pixel_pitch*d*M)
|
|
99
|
+
X_grating = X_normalized - X_normalized.astype(int)
|
|
100
|
+
X_stepped = np.floor(X_grating * N_steps)
|
|
101
|
+
X_final = cv2.normalize(X_stepped, X_stepped, 0, 1, cv2.NORM_MINMAX)
|
|
102
|
+
|
|
103
|
+
hologram = modified_amp * np.mod(modified_phase + (parity * 2*np.pi * X_final), 2*np.pi)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
hologram_final = hologram
|
|
107
|
+
|
|
108
|
+
if not save:
|
|
109
|
+
return hologram_final
|
|
110
|
+
elif save:
|
|
111
|
+
if not os.path.exists(path):
|
|
112
|
+
os.mkdir(path)
|
|
113
|
+
hologram_final = cv2.normalize(hologram_final, None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8U)
|
|
114
|
+
cv2.imwrite(path+"/"+name+".bmp", hologram_final)
|
|
115
|
+
return 0
|
|
116
|
+
else:
|
|
117
|
+
return 0
|
|
118
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from scipy.interpolate import interp1d
|
|
3
|
+
|
|
4
|
+
_lookuptable = np.linspace(0, np.pi + 1e-9, 10001)
|
|
5
|
+
_sinc_values = np.sinc(_lookuptable / np.pi)
|
|
6
|
+
|
|
7
|
+
_interpolator = interp1d(
|
|
8
|
+
x=_sinc_values,
|
|
9
|
+
y=_lookuptable,
|
|
10
|
+
kind='linear',
|
|
11
|
+
bounds_error=False,
|
|
12
|
+
fill_value=(0, np.pi)
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def inv_sinc(x):
|
|
17
|
+
"""Inverse Sinc function.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
x (float or np.ndarray): Normalized Amplitude (0.0 ~ 1.0)
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
float or np.ndarray: Phase value (-pi ~ 0.0)
|
|
24
|
+
"""
|
|
25
|
+
return _interpolator(x)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: OAM_KIST
|
|
3
|
+
Version: 0.2.15
|
|
4
|
+
Summary: Quantum information and technology using OAM states and SLM for KIST research
|
|
5
|
+
Author: Youngjun Kim
|
|
6
|
+
Author-email: kyjun0915@kist.re.kr
|
|
7
|
+
Project-URL: Documentation, https://yjun0915.github.io/OAM_KIST/
|
|
8
|
+
Project-URL: Source, https://github.com/yjun0915/OAM_KIST
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: numpy
|
|
12
|
+
Requires-Dist: matplotlib
|
|
13
|
+
Requires-Dist: scipy
|
|
14
|
+
Requires-Dist: opencv-python
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: description
|
|
18
|
+
Dynamic: description-content-type
|
|
19
|
+
Dynamic: project-url
|
|
20
|
+
Dynamic: requires-dist
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
<div align="center">
|
|
25
|
+
<img src="https://raw.githubusercontent.com/yjun0915/OAM_KIST/main/assets/logo.png" alt="KIST OAM Logo" width="300">
|
|
26
|
+
<br>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+

|
|
31
|
+

|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+

|
|
36
|
+

|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
[](https://github.com/yjun0915/OAM_KIST/actions/workflows/test.yml)
|
|
40
|
+
[](https://badge.fury.io/py/OAM_KIST)
|
|
41
|
+
|
|
42
|
+
Imaging and sequence toolkit for Lageurre-Gaussian mode light, i.e. Orbital Angular Montum(OAM) state.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
.
|
|
47
|
+
├── OAM_KIST/ # Main Source Code
|
|
48
|
+
│ ├── __init__.py # Package initialization
|
|
49
|
+
│ ├── holography.py # Core logic for hologram generation
|
|
50
|
+
│ ├── utils.py # Helper functions (math, interpolation)
|
|
51
|
+
│ └── outputs/ # Directory for generated images
|
|
52
|
+
├── docs/ # Documentation (Sphinx)
|
|
53
|
+
│ ├── source/ # Documentation source files (.rst, conf.py)
|
|
54
|
+
│ ├── Makefile # Build command for Mac/Linux
|
|
55
|
+
│ └── make.bat # Build command for Windows
|
|
56
|
+
├── tests/ # Unit Tests
|
|
57
|
+
│ └── test_core.py # Pytest test cases
|
|
58
|
+
├── main.py # Execution script
|
|
59
|
+
├── README.md # Project overview
|
|
60
|
+
├── requirements.txt # Dependencies
|
|
61
|
+
└── setup.py # PyPI distribution setup
|
|
62
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
OAM_KIST/__init__.py
|
|
4
|
+
OAM_KIST/holography.py
|
|
5
|
+
OAM_KIST/utils.py
|
|
6
|
+
OAM_KIST.egg-info/PKG-INFO
|
|
7
|
+
OAM_KIST.egg-info/SOURCES.txt
|
|
8
|
+
OAM_KIST.egg-info/dependency_links.txt
|
|
9
|
+
OAM_KIST.egg-info/requires.txt
|
|
10
|
+
OAM_KIST.egg-info/top_level.txt
|
|
11
|
+
tests/test_core.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
OAM_KIST
|
oam_kist-0.2.15/PKG-INFO
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: OAM_KIST
|
|
3
|
+
Version: 0.2.15
|
|
4
|
+
Summary: Quantum information and technology using OAM states and SLM for KIST research
|
|
5
|
+
Author: Youngjun Kim
|
|
6
|
+
Author-email: kyjun0915@kist.re.kr
|
|
7
|
+
Project-URL: Documentation, https://yjun0915.github.io/OAM_KIST/
|
|
8
|
+
Project-URL: Source, https://github.com/yjun0915/OAM_KIST
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: numpy
|
|
12
|
+
Requires-Dist: matplotlib
|
|
13
|
+
Requires-Dist: scipy
|
|
14
|
+
Requires-Dist: opencv-python
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: description
|
|
18
|
+
Dynamic: description-content-type
|
|
19
|
+
Dynamic: project-url
|
|
20
|
+
Dynamic: requires-dist
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
<div align="center">
|
|
25
|
+
<img src="https://raw.githubusercontent.com/yjun0915/OAM_KIST/main/assets/logo.png" alt="KIST OAM Logo" width="300">
|
|
26
|
+
<br>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+

|
|
31
|
+

|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+

|
|
36
|
+

|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
[](https://github.com/yjun0915/OAM_KIST/actions/workflows/test.yml)
|
|
40
|
+
[](https://badge.fury.io/py/OAM_KIST)
|
|
41
|
+
|
|
42
|
+
Imaging and sequence toolkit for Lageurre-Gaussian mode light, i.e. Orbital Angular Montum(OAM) state.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
.
|
|
47
|
+
├── OAM_KIST/ # Main Source Code
|
|
48
|
+
│ ├── __init__.py # Package initialization
|
|
49
|
+
│ ├── holography.py # Core logic for hologram generation
|
|
50
|
+
│ ├── utils.py # Helper functions (math, interpolation)
|
|
51
|
+
│ └── outputs/ # Directory for generated images
|
|
52
|
+
├── docs/ # Documentation (Sphinx)
|
|
53
|
+
│ ├── source/ # Documentation source files (.rst, conf.py)
|
|
54
|
+
│ ├── Makefile # Build command for Mac/Linux
|
|
55
|
+
│ └── make.bat # Build command for Windows
|
|
56
|
+
├── tests/ # Unit Tests
|
|
57
|
+
│ └── test_core.py # Pytest test cases
|
|
58
|
+
├── main.py # Execution script
|
|
59
|
+
├── README.md # Project overview
|
|
60
|
+
├── requirements.txt # Dependencies
|
|
61
|
+
└── setup.py # PyPI distribution setup
|
|
62
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/yjun0915/OAM_KIST/main/assets/logo.png" alt="KIST OAM Logo" width="300">
|
|
3
|
+
<br>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
[](https://github.com/yjun0915/OAM_KIST/actions/workflows/test.yml)
|
|
17
|
+
[](https://badge.fury.io/py/OAM_KIST)
|
|
18
|
+
|
|
19
|
+
Imaging and sequence toolkit for Lageurre-Gaussian mode light, i.e. Orbital Angular Montum(OAM) state.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
.
|
|
24
|
+
├── OAM_KIST/ # Main Source Code
|
|
25
|
+
│ ├── __init__.py # Package initialization
|
|
26
|
+
│ ├── holography.py # Core logic for hologram generation
|
|
27
|
+
│ ├── utils.py # Helper functions (math, interpolation)
|
|
28
|
+
│ └── outputs/ # Directory for generated images
|
|
29
|
+
├── docs/ # Documentation (Sphinx)
|
|
30
|
+
│ ├── source/ # Documentation source files (.rst, conf.py)
|
|
31
|
+
│ ├── Makefile # Build command for Mac/Linux
|
|
32
|
+
│ └── make.bat # Build command for Windows
|
|
33
|
+
├── tests/ # Unit Tests
|
|
34
|
+
│ └── test_core.py # Pytest test cases
|
|
35
|
+
├── main.py # Execution script
|
|
36
|
+
├── README.md # Project overview
|
|
37
|
+
├── requirements.txt # Dependencies
|
|
38
|
+
└── setup.py # PyPI distribution setup
|
|
39
|
+
```
|
oam_kist-0.2.15/setup.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_version():
|
|
7
|
+
init_path = os.path.join(os.path.dirname(__file__), "OAM_KIST", "__init__.py")
|
|
8
|
+
with open(init_path, "r", encoding="utf-8") as f:
|
|
9
|
+
for line in f:
|
|
10
|
+
if line.startswith("__version__"):
|
|
11
|
+
return line.split("=")[1].strip().strip('"').strip("'")
|
|
12
|
+
raise RuntimeError("패키지 버전 정보를 찾을 수 없습니다.")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
this_directory = Path(__file__).parent
|
|
16
|
+
long_description = (this_directory / "README.md").read_text(encoding="utf-8")
|
|
17
|
+
|
|
18
|
+
setup(
|
|
19
|
+
name="OAM_KIST",
|
|
20
|
+
version=get_version(),
|
|
21
|
+
packages=find_packages(),
|
|
22
|
+
install_requires=[
|
|
23
|
+
"numpy",
|
|
24
|
+
"matplotlib",
|
|
25
|
+
"scipy",
|
|
26
|
+
"opencv-python"
|
|
27
|
+
],
|
|
28
|
+
author="Youngjun Kim",
|
|
29
|
+
author_email="kyjun0915@kist.re.kr",
|
|
30
|
+
description="Quantum information and technology using OAM states and SLM for KIST research",
|
|
31
|
+
long_description=long_description,
|
|
32
|
+
long_description_content_type='text/markdown',
|
|
33
|
+
project_urls={
|
|
34
|
+
"Documentation": "https://yjun0915.github.io/OAM_KIST/",
|
|
35
|
+
"Source": "https://github.com/yjun0915/OAM_KIST",
|
|
36
|
+
},
|
|
37
|
+
python_requires=">=3.7",
|
|
38
|
+
)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
import os
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from OAM_KIST.holography import generate_oam_superposition, encode_hologram
|
|
6
|
+
from OAM_KIST.utils import inv_sinc
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_inv_sinc_accuracy():
|
|
10
|
+
"""inv_sinc 함수가 예상된 수학적 값을 반환하는지 테스트"""
|
|
11
|
+
x_val = 0.5
|
|
12
|
+
expected = 1.89547036302816116
|
|
13
|
+
result = inv_sinc(x_val)
|
|
14
|
+
|
|
15
|
+
assert np.isclose(result, expected, atol=1e-4)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_generate_oam_superposition_shape():
|
|
19
|
+
"""OAM 중첩 함수가 올바른 크기의 배열을 반환하는지 테스트"""
|
|
20
|
+
res = [100, 100]
|
|
21
|
+
pixel_pitch = 8e-6
|
|
22
|
+
beam_w0 = 8e-4
|
|
23
|
+
l_modes = [-1, 1]
|
|
24
|
+
p_modes = [0, 0]
|
|
25
|
+
weights = [0.5, 0.5]
|
|
26
|
+
|
|
27
|
+
amp, phase, X, Y = generate_oam_superposition(res, pixel_pitch, beam_w0, l_modes, p_modes, weights)
|
|
28
|
+
|
|
29
|
+
assert amp.shape == (100, 100)
|
|
30
|
+
assert phase.shape == (100, 100)
|
|
31
|
+
assert X.shape == (100, 100)
|
|
32
|
+
assert Y.shape == (100, 100)
|
|
33
|
+
|
|
34
|
+
assert np.max(amp) <= 1.0 + 1e-9
|
|
35
|
+
assert np.min(amp) >= 0.0
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_encode_hologram_save(tmp_path):
|
|
39
|
+
"""
|
|
40
|
+
tmp_path: pytest가 제공하는 임시 폴더 Fixture (테스트 끝나면 자동 삭제됨)
|
|
41
|
+
실제로 파일을 저장하고 잘 생기는지 테스트합니다.
|
|
42
|
+
"""
|
|
43
|
+
res = 50
|
|
44
|
+
X, Y = np.meshgrid(np.linspace(-1, 1, res), np.linspace(-1, 1, res))
|
|
45
|
+
amp = np.random.rand(res, res)
|
|
46
|
+
phase = np.random.rand(res, res) * 2 * np.pi - np.pi
|
|
47
|
+
|
|
48
|
+
save_dir = tmp_path / "test_outputs"
|
|
49
|
+
file_name = "test_hologram"
|
|
50
|
+
|
|
51
|
+
encode_hologram(
|
|
52
|
+
Amp=amp, Phase=phase, X=X, Y=Y,
|
|
53
|
+
pixel_pitch=1e-6, d=10,
|
|
54
|
+
prepare=True, save=True,
|
|
55
|
+
path=str(save_dir), name=file_name
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
expected_file = save_dir / (file_name + ".bmp")
|
|
59
|
+
assert expected_file.exists()
|