Coordinates¤
cart2polar
dLux.utils.coordinates.cart2polar(coordinates)
¤
Converts the input (x, y) Cartesian coordinates into (r, phi) polar coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coordinates
|
Array
|
The (x, y) Cartesian coordinates to be converted into polar coordinates. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
coordinates |
Array
|
The input Cartesian coordinates converted into (r, phi) polar coordinates. |
Source code in dLux/utils/coordinates.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
polar2cart
dLux.utils.coordinates.polar2cart(coordinates)
¤
Converts the input (r, phi) polar coordinates into (x, y) Cartesian coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coordinates
|
Array
|
The (r, phi) polar coordinates to be converted into Cartesian coordinates. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
coordinates |
Array
|
The input polar coordinates converted into (x, y) Cartesian coordinates. |
Source code in dLux/utils/coordinates.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
pixel_coords
dLux.utils.coordinates.pixel_coords(npixels, diameter=None, radius=None, pixel_scale=None, polar=False, fft_style=False)
¤
Returns a paraxial set of 2d coordinates for each pixel center.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
npixels
|
int
|
The output size of the coordinates array to generate. |
required |
diameter
|
float = None
|
The diameter of the coordinates array to generate. |
None
|
radius
|
float = None
|
The radius of the coordinates array to generate. |
None
|
pixel_scale
|
float = None
|
The pixel scale of the coordinates array to generate. |
None
|
polar
|
bool = False
|
Output the coordinates in polar (r, phi) coordinates. |
False
|
fft_style
|
bool = False
|
If True, use FFT-style centering. For even npixels this produces integer centered coordinates. For odd npixels this is identical to the default. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
coordinates |
Array
|
The array of pixel center coordinates. |
Source code in dLux/utils/coordinates.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
nd_coords
dLux.utils.coordinates.nd_coords(npixels, pixel_scales=1.0, offsets=0.0, indexing='xy')
¤
Returns a set of nd pixel center coordinates, with an optional offset. Each
dimension can have a different number of pixels, pixel scale and offset by passing
in tuples of values: nd_coords((10, 10), (1, 2), (0, 1)). pixel scale and offset
can also be passed in as floats to apply those values to all dimensions, i.e.:
nd_coords((10, 10), 1, 0).
The indexing argument is the same as in numpy.meshgrid, i.e.: giving the string ‘ij’ returns a meshgrid with matrix indexing, while ‘xy’ returns a meshgrid with Cartesian indexing. In the 2-D case with inputs of length M and N, the outputs are of shape (N, M) for ‘xy’ indexing and (M, N) for ‘ij’ indexing. In the 3-D case with inputs of length M, N and P, outputs are of shape (N, M, P) for ‘xy’ indexing and (M, N, P) for ‘ij’ indexing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
npixels
|
int | tuple[int, ...]
|
The number of pixels in each dimension. |
required |
pixel_scales
|
float | tuple[float, ...] = 1.0
|
The pixel_scales of each dimension. If a tuple, the length of the tuple must match the number of dimensions. If a float, the same scale is applied to all dimensions. |
1.0
|
offsets
|
float | tuple[float, ...] = 0.0
|
The offset of the pixel centers in each dimension. If a tuple, the length of the tuple must match the number of dimensions. If a float, the same offset is applied to all dimensions. set to 0. |
0.0
|
indexing
|
str = 'xy'
|
The indexing of the output. Default is 'xy'. See numpy.meshgrid for more details. |
'xy'
|
Returns:
| Name | Type | Description |
|---|---|---|
coordinates |
Array
|
The positions of the pixel centers in the given dimensions. |
Source code in dLux/utils/coordinates.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
translate_coords
dLux.utils.coordinates.translate_coords(coords, translation)
¤
Translates the coordinates by to a new centre. Translation must have shape (2,).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
Array
|
The input coordinates to translate. |
required |
translation
|
Array
|
The translation to apply to the coordinates. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
coords |
Array
|
The translated coordinates. |
Source code in dLux/utils/coordinates.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
compress_coords
dLux.utils.coordinates.compress_coords(coords, compress)
¤
Compresses the coordinates by a given factor. Compress must have shape (2,).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
Array
|
The input coordinates to compress. |
required |
compress
|
Array
|
The compression to apply to the coordinates. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
coords |
Array
|
The compressed coordinates. |
Source code in dLux/utils/coordinates.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
shear_coords
dLux.utils.coordinates.shear_coords(coords, shear)
¤
Shears the coordinates by a given factor. Shear must have shape (2,).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
Array
|
The input coordinates to shear. |
required |
shear
|
Array
|
The shear to apply to the coordinates. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
coords |
Array
|
The sheared coordinates. |
Source code in dLux/utils/coordinates.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
rotate_coords
dLux.utils.coordinates.rotate_coords(coords, rotation)
¤
Rotates the coordinates by a given angle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
Array
|
The input coordinates to rotate. |
required |
rotation
|
(float, radians)
|
The rotation to apply to the coordinates. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
coords |
Array
|
The rotated coordinates. |
Source code in dLux/utils/coordinates.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
gen_powers
dLux.utils.coordinates.gen_powers(degree)
¤
Generates the powers required for a 2d polynomial
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degree
|
int
|
Maximum power to generate |
required |
Returns:
| Name | Type | Description |
|---|---|---|
xpows |
Array
|
x axis powers |
ypows |
Array
|
y axis powers |
Source code in dLux/utils/coordinates.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
distort_coords
dLux.utils.coordinates.distort_coords(coords, coeffs, pows)
¤
Apply a 2D polynomial distortion to some coordinates
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
Array
|
Input coordinates to distort |
required |
coeffs
|
Array
|
Distortion polynomial coefficients |
required |
pows
|
Array
|
Distortion polynomial powers |
required |
Returns:
| Name | Type | Description |
|---|---|---|
distorted_coords |
Array
|
Coords with the distortion applied |
Source code in dLux/utils/coordinates.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |