svetlanna.phase_retrieval_problem package

Submodules

svetlanna.phase_retrieval_problem.algorithms module

svetlanna.phase_retrieval_problem.algorithms.gerchberg_saxton_algorithm(target_intensity: Tensor, source_intensity: Tensor, forward: Callable, reverse: Callable, initial_approximation: Tensor, tol: float, maxiter: int, target_phase: Tensor | None = None, target_region: Tensor | None = None) PhaseRetrievalResult

Gerchberg-Saxton algorithm(GS) for solving the phase retrieval problem

Parameters

target_intensitytorch.Tensor

Intensity profile in the Fourier plane

source_intensitytorch.Tensor

Intensity distribution before the optical setup(in the image plane)

forwardCallable

Function which describes forward propagation through the optical system

reverseCallable

Function which describes reverse propagation through the optical system

initial_approximationtorch.Tensor

Initial approximation for the phase profile

tolfloat

Accuracy for the algorithm

maxiterint

Maximum number of iterations

target_phasetorch.Tensor | None, optional

Phase profile on the Fourier plane(optional for the generating target intensity profile problem) for reconstructing phase profile problem, by default None

target_regiontorch.Tensor | None, optional

Region to preserve phase and amplitude profiles in the Fourier plane for reconstructing phase profile problem(optional for the generating target intensity profile problem), by default None

Returns

prr.PhaseRetrievalResult

Exemplar of class PhaseRetrievalResult which presents result of optimization

svetlanna.phase_retrieval_problem.algorithms.hybrid_input_output(target_intensity: Tensor, source_intensity: Tensor, forward: Callable, reverse: Callable, initial_approximation: Tensor, tol: float, maxiter: int, target_phase: Tensor | None = None, target_region: Tensor | None = None, constant_factor: float = 0.9) PhaseRetrievalResult

Hybrid Input-Output(HIO) algorithm for for solving the phase retrieval problem

Parameters

target_intensitytorch.Tensor

Intensity profile in the Fourier plane

source_intensitytorch.Tensor

Intensity distribution before the optical setup(in the image plane)

forwardCallable

Function which describes forward propagation through the optical system

reverseCallable

Function which describes reverse propagation through the optical system

initial_approximationtorch.Tensor

Initial approximation for the phase profile

tolfloat

Accuracy for the algorithm

maxiterint

Maximum number of iterations

target_phasetorch.Tensor | None, optional

Phase profile on the Fourier plane(optional for the generating target intensity profile problem) for reconstructing phase profile problem, by default None

target_regiontorch.Tensor | None, optional

Region to preserve phase and amplitude profiles in the Fourier plane for reconstructing phase profile problem(optional for the generating target intensity profile problem), by default None

constant_factor: float

Learning rate value for the HIO algorithm, by default 0.9

Returns

prr.PhaseRetrievalResult

Exemplar of class PhaseRetrievalResult which presents result of optimization

svetlanna.phase_retrieval_problem.phase_retrieval module

class svetlanna.phase_retrieval_problem.phase_retrieval.AlgorithmOptions

Bases: TypedDict

constant_factor: float
disp: bool
maxiter: int
tol: float
class svetlanna.phase_retrieval_problem.phase_retrieval.SetupLike(*args, **kwargs)

Bases: Protocol

A class for phase_retrieval_problem with personal realizations of forward and reverse methods instead of methods in svetlanna.setup.LinearOpticalSetup

Parameters

Protocol_type_

_description_

forward(input_field: Tensor) Tensor
reverse(transmission_field: Tensor) Tensor
svetlanna.phase_retrieval_problem.phase_retrieval.retrieve_phase(source_intensity: Tensor, optical_setup: LinearOpticalSetup | SetupLike, target_intensity: Tensor, *, initial_phase: Tensor | None = None, method: Literal['GS', 'HIO'] = 'GS', options: AlgorithmOptions | None = None) PhaseRetrievalResult
svetlanna.phase_retrieval_problem.phase_retrieval.retrieve_phase(source_intensity: Tensor, optical_setup: LinearOpticalSetup | SetupLike, target_intensity: Tensor, target_phase: Tensor, target_region: Tensor, *, initial_phase: Tensor | None = None, method: Literal['GS', 'HIO'] = 'GS', options: AlgorithmOptions | None = None) PhaseRetrievalResult

Function for solving phase retrieval problem: generating target intensity profile or reconstructing the phase profile of the field

Parameters

source_intensitytorch.Tensor

Intensity distribution before the optical setup

optical_setupLinearOpticalSetup | SetupLike

Optical system through which the beam is propagated

target_intensitytorch.Tensor

Intensity profile in the Fourier plane

target_phasetorch.Tensor | None, optional

Phase profile on the Fourier plane(optional for the generating target intensity profile problem)

target_regiontorch.Tensor, optional

Region to preserve phase and amplitude profiles in the Fourier plane( optional for the generating target intensity profile problem)

initial_phasetorch.Tensor, optional

Initial approximation for the phase profile, by default None

methodLiteral['GS', 'HIO'], optional

Algorithms for phase retrieval problem, by default ‘GS’

optionsdict, optional

Dictionary with optimization parameters, by default { ‘tol’: 1e-16, # criteria for stop optimization ‘maxiter’: 100, # maximum number of iterations ‘constant_factor’: 0.9, # convergence parameter for HIO ‘disp’: False # show result of optimization }

Returns

prr.PhaseRetrievalResult

Exemplar of class PhaseRetrievalResult which presents result of optimization

Raises

ValueError

Unknown optimization method

svetlanna.phase_retrieval_problem.phase_retrieval_result module

class svetlanna.phase_retrieval_problem.phase_retrieval_result.PhaseRetrievalResult(solution: Tensor, cost_func: float, cost_func_evolution: list[float], number_of_iterations: int)

Bases: object

Represents the phase retrieval result

cost_func: float
cost_func_evolution: list[float]
number_of_iterations: int
solution: Tensor

Module contents

class svetlanna.phase_retrieval_problem.PhaseRetrievalResult(solution: Tensor, cost_func: float, cost_func_evolution: list[float], number_of_iterations: int)

Bases: object

Represents the phase retrieval result

cost_func: float
cost_func_evolution: list[float]
number_of_iterations: int
solution: Tensor
class svetlanna.phase_retrieval_problem.SetupLike(*args, **kwargs)

Bases: Protocol

A class for phase_retrieval_problem with personal realizations of forward and reverse methods instead of methods in svetlanna.setup.LinearOpticalSetup

Parameters

Protocol_type_

_description_

forward(input_field: Tensor) Tensor
reverse(transmission_field: Tensor) Tensor
svetlanna.phase_retrieval_problem.gerchberg_saxton_algorithm(target_intensity: Tensor, source_intensity: Tensor, forward: Callable, reverse: Callable, initial_approximation: Tensor, tol: float, maxiter: int, target_phase: Tensor | None = None, target_region: Tensor | None = None) PhaseRetrievalResult

Gerchberg-Saxton algorithm(GS) for solving the phase retrieval problem

Parameters

target_intensitytorch.Tensor

Intensity profile in the Fourier plane

source_intensitytorch.Tensor

Intensity distribution before the optical setup(in the image plane)

forwardCallable

Function which describes forward propagation through the optical system

reverseCallable

Function which describes reverse propagation through the optical system

initial_approximationtorch.Tensor

Initial approximation for the phase profile

tolfloat

Accuracy for the algorithm

maxiterint

Maximum number of iterations

target_phasetorch.Tensor | None, optional

Phase profile on the Fourier plane(optional for the generating target intensity profile problem) for reconstructing phase profile problem, by default None

target_regiontorch.Tensor | None, optional

Region to preserve phase and amplitude profiles in the Fourier plane for reconstructing phase profile problem(optional for the generating target intensity profile problem), by default None

Returns

prr.PhaseRetrievalResult

Exemplar of class PhaseRetrievalResult which presents result of optimization

svetlanna.phase_retrieval_problem.hybrid_input_output(target_intensity: Tensor, source_intensity: Tensor, forward: Callable, reverse: Callable, initial_approximation: Tensor, tol: float, maxiter: int, target_phase: Tensor | None = None, target_region: Tensor | None = None, constant_factor: float = 0.9) PhaseRetrievalResult

Hybrid Input-Output(HIO) algorithm for for solving the phase retrieval problem

Parameters

target_intensitytorch.Tensor

Intensity profile in the Fourier plane

source_intensitytorch.Tensor

Intensity distribution before the optical setup(in the image plane)

forwardCallable

Function which describes forward propagation through the optical system

reverseCallable

Function which describes reverse propagation through the optical system

initial_approximationtorch.Tensor

Initial approximation for the phase profile

tolfloat

Accuracy for the algorithm

maxiterint

Maximum number of iterations

target_phasetorch.Tensor | None, optional

Phase profile on the Fourier plane(optional for the generating target intensity profile problem) for reconstructing phase profile problem, by default None

target_regiontorch.Tensor | None, optional

Region to preserve phase and amplitude profiles in the Fourier plane for reconstructing phase profile problem(optional for the generating target intensity profile problem), by default None

constant_factor: float

Learning rate value for the HIO algorithm, by default 0.9

Returns

prr.PhaseRetrievalResult

Exemplar of class PhaseRetrievalResult which presents result of optimization

svetlanna.phase_retrieval_problem.retrieve_phase(source_intensity: Tensor, optical_setup: LinearOpticalSetup | SetupLike, target_intensity: Tensor, target_phase: Tensor | None = None, target_region: Tensor | None = None, *, initial_phase: Tensor | None = None, method: Literal['GS', 'HIO'] = 'GS', options: AlgorithmOptions | None = None) PhaseRetrievalResult

Function for solving phase retrieval problem: generating target intensity profile or reconstructing the phase profile of the field

Parameters

source_intensitytorch.Tensor

Intensity distribution before the optical setup

optical_setupLinearOpticalSetup | SetupLike

Optical system through which the beam is propagated

target_intensitytorch.Tensor

Intensity profile in the Fourier plane

target_phasetorch.Tensor | None, optional

Phase profile on the Fourier plane(optional for the generating target intensity profile problem)

target_regiontorch.Tensor, optional

Region to preserve phase and amplitude profiles in the Fourier plane( optional for the generating target intensity profile problem)

initial_phasetorch.Tensor, optional

Initial approximation for the phase profile, by default None

methodLiteral['GS', 'HIO'], optional

Algorithms for phase retrieval problem, by default ‘GS’

optionsdict, optional

Dictionary with optimization parameters, by default { ‘tol’: 1e-16, # criteria for stop optimization ‘maxiter’: 100, # maximum number of iterations ‘constant_factor’: 0.9, # convergence parameter for HIO ‘disp’: False # show result of optimization }

Returns

prr.PhaseRetrievalResult

Exemplar of class PhaseRetrievalResult which presents result of optimization

Raises

ValueError

Unknown optimization method