magni.imaging.measurements._lissajous module¶
Module providing public functions for the magni.imaging.measurements subpackage.
Routine listings¶
- lissajous_sample_image(h, w, scan_length, num_points, f_y=1., f_x=1.,
- theta_y=0., theta_x=np.pi / 2) Function for lissajous sampling an image.
- lissajous_sample_surface(l, w, speed, sample_rate, time, f_y=1., f_x=1.,
- theta_y=0., theta_x=np.pi / 2, speed_mode=0) Function for lissajous sampling a surface.
-
magni.imaging.measurements._lissajous.
lissajous_sample_image
(h, w, scan_length, num_points, f_y=1.0, f_x=1.0, theta_y=0.0, theta_x=1.5707963267948966)[source]¶ Sample an image using a lissajous pattern.
The coordinates (in units of pixels) resulting from sampling an image of size h times w using a lissajous pattern are determined. The scan_length determines the length of the path scanned whereas num_points indicates the number of samples taken on that path.
Parameters: - h (int) – The height of the area to scan in units of pixels.
- w (int) – The width of the area to scan in units of pixels.
- scan_length (float) – The length of the path to scan in units of pixels.
- num_points (int) – The number of samples to take on the scanned path.
- f_y (float) – The frequency of the y-sinusoid (the default value is 1.0).
- f_x (float) – The frequency of the x-sinusoid (the default value is 1.0).
- theta_y (float) – The starting phase of the y-sinusoid (the default is 0.0).
- theta_x (float) – The starting phase of the x-sinusoid (the default is pi / 2).
Returns: coords (ndarray) – The coordinates of the samples arranged into a 2D array, such that each row is a coordinate pair (x, y).
Notes
The orientation of the coordinate system is such that the width w is measured along the x-axis whereas the height h is measured along the y-axis.
Examples
For example,
>>> import numpy as np >>> from magni.imaging.measurements import lissajous_sample_image >>> h = 10 >>> w = 10 >>> scan_length = 50.0 >>> num_points = 12 >>> np.set_printoptions(suppress=True) >>> lissajous_sample_image(h, w, scan_length, num_points) array([[ 5. , 9.5 ], [ 1.40370042, 7.70492686], [ 0.67656563, 3.75183526], [ 3.39871123, 0.79454232], [ 7.39838148, 1.19240676], [ 9.48459832, 4.62800824], [ 7.99295651, 8.36038857], [ 4.11350322, 9.41181634], [ 0.94130617, 6.94345168], [ 1.0071768 , 2.92458128], [ 4.25856283, 0.56150128], [ 8.10147506, 1.7395012 ], [ 9.4699986 , 5.51876059]])
-
magni.imaging.measurements._lissajous.
lissajous_sample_surface
(l, w, speed, sample_rate, time, f_y=1.0, f_x=1.0, theta_y=0.0, theta_x=1.5707963267948966, speed_mode=0)[source]¶ Sample a surface area using a lissajous pattern.
The coordinates (in units of meters) resulting from sampling an area of size l times w using a lissajous pattern are determined. The scanned path is determined from the probe speed and the scan
time
.Parameters: - l (float) – The length of the area to scan in units of meters.
- w (float) – The width of the area to scan in units of meters.
- speed (float) – The probe speed in units of meters/second.
- sample_rate (float) – The sample rate in units of Hertz.
- time (float) – The scan time in units of seconds.
- f_y (float) – The frequency of the y-sinusoid (the default value is 1.0).
- f_x (float) – The frequency of the x-sinusoid (the default value is 1.0).
- theta_y (float) – The starting phase of the y-sinusoid (the default is 0.0).
- theta_x (float) – The starting phase of the x-sinusoid (the default is pi / 2).
- speed_mode (int) – The speed mode used to select sampling points (the default is 0 which implies that the speed argument determines the speed, and f_y and f_x determine the ratio between the relative frequencies used).
Returns: coords (ndarray) – The coordinates of the samples arranged into a 2D array, such that each row is a coordinate pair (x, y).
Notes
The orientation of the coordinate system is such that the width w is measured along the x-axis whereas the length l is measured along the y-axis.
Generally, the lissajous sampling pattern does not provide constant speed, and this cannot be compensated for without violating f_y, f_x, or both. Therefore, speed_mode allows the user to determine how this issue is handled: In speed_mode 0, constant speed equal to speed is ensured by non-uniform sampling of a lissajous curve, whereby f_y and f_x are not constant frequencies. In speed_mode 1, average speed equal to speed is ensured by scaling f_y and f_x by the same constant. In speed_mode 2, f_y and f_x are kept constant and the speed is only used to determine the path length in combination with
time
.Examples
For example,
>>> import numpy as np >>> from magni.imaging.measurements import lissajous_sample_surface >>> l = 1e-6 >>> w = 1e-6 >>> speed = 7e-7 >>> sample_rate = 1.0 >>> time = 12.0 >>> np.set_printoptions(suppress=True) >>> lissajous_sample_surface(l, w, speed, sample_rate, time) array([[ 0.0000005 , 0.000001 ], [ 0.00000001, 0.00000058], [ 0.00000033, 0.00000003], [ 0.00000094, 0.00000025], [ 0.00000082, 0.00000089], [ 0.00000017, 0.00000088], [ 0.00000007, 0.00000024], [ 0.00000068, 0.00000003], [ 0.00000099, 0.0000006 ], [ 0.00000048, 0.000001 ], [ 0. , 0.00000057], [ 0.00000035, 0.00000002], [ 0.00000094, 0.00000027]])