get_spatial_coords
- colibri.optics.functional.get_spatial_coords(M, N, pixel_size, device=device(type='cpu'), type='cartesian')[source]
Generate the spatial coordinates for wave optics simulations in a specific coordinate system.
Note
- if type is ‘cartesian’, we generate \((x, y)\) coordinates in the Cartesian coordinate system, where
\(x \in \bigg[-\frac{\Delta\cdot N}{2}, \frac{\Delta\cdot N}{2} \bigg]\)
\(y \in \bigg[-\frac{\Delta\cdot M}{2}, \frac{\Delta\cdot M}{2} \bigg]\)
- if type is ‘polar’, we generate \((r, \theta)\) coordinates in the Polar coordinate system, where
\(r \in \Bigg[0, \sqrt{\bigg(\frac{\Delta\cdot N}{2}\bigg)^2 + \bigg(\frac{\Delta\cdot M}{2}\bigg)^2} \Bigg]\)
\(\theta \in [-\pi, \pi]\)
with \(\Delta\) being the pixel size, \(M\) the number of pixels in the y axis, and \(N\) the number of pixels in the x axis.
- Parameters:
M (int) – number of pixels in the y axis.
N (int) – number of pixels in the x axis.
pixel_size (float) – Pixel size in meters.
device (torch.device) – Device, for more see torch.device().
type (str) – Type of coordinate system to generate (‘cartesian’ or ‘polar’).
- Returns:
- A tuple of tensors representing the X and Y coordinates
if ‘cartesian’, or radius (r) and angle (theta) if ‘polar’.
- Return type:
tuple[torch.Tensor, torch.Tensor]