lsClient.solve_scan_lpu(
matrixData=None,
scanDictionary=None,
waitForSolution=True,
inputPath=None,
num_runs=1,
average_over=1,
exposure_time=None,
num_neighbors=1,
effective_coupmat_translation_accuracy=10.0,
effective_coupmat_translation_time=0.0,
)Purpose: Run the Physical LPU on a complex coupling matrix while scanning user-defined phase settings over multiple steps. The scan is defined by scanDictionary, which specifies which lasers (pairs of indices) are scanned and what phase values to apply at each scan step.
| Parameters |
matrixData: numpy.ndarray, Required unless
scanDictionary: dict, Required unless num_of_steps: int lasers_to_scan: numpy.ndarray phases_to_scan: numpy.ndarray waitForSolution: bool, Optional; default = True inputPath: str | None, Optional; default = None num_runs: int, Optional; default = 1 average_over: int, Optional; default = 1 exposure_time: int | None, Optional; default = None num_neighbors: int, Optional; default = 1 effective_coupmat_translation_accuracy: float, Optional; default = 10.0 effective_coupmat_translation_time: float, Optional; default = 0.0 |
| Returns (synchronous, when waitForSolution=True) |
Return type: command: str data: dict solutions: list solutions[i]: list[dict] solutions[i][j]: dict phase_problem: ndarray[float] phase_reference: ndarray[float] energy_problem: ndarray[float] energy_reference: ndarray[float] contrast_problem: ndarray[float] contrast_reference: ndarray[float] snr_problem: ndarray[float] snr_reference: ndarray[float] image_problem_list: ndarray[int] image_reference_list: ndarray[int] solver_running_time: float exposure_time: int creation_time: str reqTime: str id: str userId: str receivedTime: str effective_coupmat: ndarray[complex64] warnings: None |
| Returns (asynchronous, when waitForSolution=False) |
Return type: dictA request descriptor dictionary returned by the service. Pass this dictionary unchanged to get_solution_sync to retrieve the solution later.id: str reqTime: str ( "DD-MM-YYYY-HH-MM-SS-microseconds")receivedTime: str |
| Notes and comments |
| Phases to scan must be a 2D array even if you are scanning only one laser |
Examples
Constructing scanDictionary
import numpy as np
size = 5
coupling_matrix = 0.5 * numpy.eye(size, dtype=numpy.complex64)
coupling = (1-0.5)/2
for i in range(size - 1):
coupling_matrix[i,i+1] = coupling
coupling_matrix[i+1,i] = coupling
num_steps = 16
# lasers to scan
lasers_to_scan = np.array([[1, 1]])
# phases to scan for each pair of indices over num_steps
phases_to_scan = np.linspace(0,2*np.pi , num_steps)
phases_to_scan = np.tile(phases_to_scan, (lasers_to_scan.shape[0], 1))
scan_dictionary = {
"num_of_steps": num_steps,
"lasers_to_scan": lasers_to_scan,
"phases_to_scan": phases_to_scan,
}Running the solver scan
# Run scan solve (synchronous)
result = lsClient.solve_scan_lpu(
matrixData=coupling_matrix ,
scanDictionary=scan_dictionary,
num_runs=2,
average_over=1,
exposure_time=600,
waitForSolution=True,
)
Accessing the results
# Top-level metadata
print("Command:", res["command"])
print("Solver time:", res["data"]["solver_running_time"])
print("Exposure time:", res["data"]["exposure_time"])
# Access experiment list
experiments = res["data"]["solutions"]
for exp_idx, experiment in enumerate(experiments):
print(f"\nExperiment {exp_idx + 1}")
print(f"Number of scan steps: {len(experiment)}")
for scan_idx, scan_step in enumerate(experiment):
phase_problem = scan_step["phase_problem"]
contrast_problem = scan_step["contrast_problem"]
snr_problem = scan_step["snr_problem"]
print(f" Scan step {scan_idx + 1}")
print(f" Phase shape: {phase_problem.shape}")
print(f" Contrast mean: {contrast_problem.mean():.4f}")
print(f" SNR mean: {snr_problem.mean():.4f}")
# Effective coupling matrix (if needed)
effective_coupmat = res["effective_coupmat"]
print("\nEffective coupling matrix shape:", effective_coupmat.shape)