Geometry
This module is used as for calculating geometric shapes on coordinate arrays, used to generate apertures. Each shape has two functions. One that generates a hard-edged oversampled one for more accurate aperture shapes, but is not differentiable/jittable. These are the circle
, square
, etc functions. The other type are differentiable and jittable in order to gain dynamic aperture that can be fit to data. These instead calculate the distance of each pixel from an edge and 'clip' the values between 0-1 for distances above a specified threshold. These functions are denoted with a soft_
prefix, ie soft_circle
, soft_square
, etc.
There are also some other helper functions for scaling and downsampling.
TODO: Little tutorial on generating apertures.
circle
Calculates a soft-edged circle via downsampling. This function is not differentiable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords
|
Array
|
The coordinates to calculate the circle on. |
required |
radius
|
float
|
The radius of the circle. |
required |
invert
|
bool = False
|
Whether to invert the circle. |
False
|
Returns:
Name | Type | Description |
---|---|---|
circle |
Array
|
The circle. |
Source code in src/dLux/utils/geometry.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
square
Calculates a soft-edged square via downsampling. This function is not differentiable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords
|
Array
|
The coordinates to calculate the square on. |
required |
width
|
float
|
The width of the square. |
required |
invert
|
bool = False
|
Whether to invert the square. |
False
|
Returns:
Name | Type | Description |
---|---|---|
square |
Array
|
The square. |
Source code in src/dLux/utils/geometry.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
rectangle
Calculates a soft-edged rectangle via downsampling. This function is not differentiable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords
|
Array
|
The coordinates to calculate the rectangle on. |
required |
width
|
float
|
The width of the rectangle. |
required |
height
|
float
|
The height of the rectangle. |
required |
Returns:
Name | Type | Description |
---|---|---|
rectangle |
Array
|
The rectangle. |
Source code in src/dLux/utils/geometry.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
reg_polygon
Calculates a soft-edged regular polygon via downsampling. This function is not differentiable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords
|
Array
|
The coordinates to calculate the polygon on. |
required |
rmax
|
float
|
The radius of the polygon. |
required |
nsides
|
int
|
The number of sides of the polygon. |
required |
invert
|
bool = False
|
Whether to invert the polygon. |
False
|
Returns:
Name | Type | Description |
---|---|---|
polygon |
Array
|
The polygon. |
Source code in src/dLux/utils/geometry.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
spider
Calculates a soft-edged spider via downsampling. This function is not differentiable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords
|
Array
|
The coordinates to calculate the spider on. |
required |
width
|
float
|
The width of the spider. |
required |
angles
|
Array
|
The angles of the spider. |
required |
Returns:
Name | Type | Description |
---|---|---|
spider |
Array
|
The spider. |
Source code in src/dLux/utils/geometry.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
combine
Combines multiple arrays by multiplying them together, and downsampling the output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arrays
|
Array
|
The arrays to be combined. Should have shape (n_arrays, npix, npix). |
required |
oversample
|
int = 1
|
The amount to downsample the output by. |
1
|
sum
|
bool = False
|
Whether to sum the arrays instead of multiplying them. |
False
|
Source code in src/dLux/utils/geometry.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
soft_circle
Calculates a soft-edged circle differentiably. The 'clip_dist' parameter defines the distance from the edge to 'soften' up to. A large clip_dist will result in a circle with a very soft edge, while a small clip_dist will result in a circle with a very hard edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords
|
Array
|
The coordinates to calculate the circle on. |
required |
radius
|
float
|
The radius of the circle. |
required |
clip_dist
|
float = 0.1
|
The distance from the edge to 'soften' up to. circle. |
0.1
|
invert
|
bool = False
|
Whether to invert the circle. |
False
|
Returns:
Name | Type | Description |
---|---|---|
circle |
Array
|
The softened circle. |
Source code in src/dLux/utils/geometry.py
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 |
|
soft_square
Calculates a soft-edged square differentiably. The 'clip_dist' parameter defines the distance from the edge to 'soften' up to. A large clip_dist will result in a square with a very soft edge, while a small clip_dist will result in a square with a very hard edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords
|
Array
|
The coordinates to calculate the square on. |
required |
width
|
float
|
The width of the square. |
required |
clip_dist
|
float = 0.1
|
The distance from the edge to 'soften' up to. square. |
0.1
|
invert
|
bool = False
|
Whether to invert the square. |
False
|
Returns:
Name | Type | Description |
---|---|---|
square |
Array
|
The softened square. |
Source code in src/dLux/utils/geometry.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
soft_rectangle
Calculates a soft-edged rectangle differentiably. The 'clip_dist' parameter defines the distance from the edge to 'soften' up to. A large clip_dist will result in a rectangle with a very soft edge, while a small clip_dist will result in a rectangle with a very hard edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords
|
Array
|
The coordinates to calculate the rectangle on. |
required |
width
|
float
|
The width of the rectangle. |
required |
height
|
float
|
The height of the rectangle. |
required |
clip_dist
|
float = 0.1
|
The distance from the edge to 'soften' up to. |
0.1
|
Returns:
Name | Type | Description |
---|---|---|
rectangle |
Array
|
The softened rectangle. |
Source code in src/dLux/utils/geometry.py
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 |
|
soft_reg_polygon
Calculates a soft-edged regular polygon differentiably. The 'clip_dist' parameter defines the distance from the edge to 'soften' up to. A large clip_dist will result in a polygon with a very soft edge, while a small clip_dist will result in a polygon with a very hard edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords
|
Array
|
The coordinates to calculate the polygon on. |
required |
radius
|
float
|
The radius of the polygon. |
required |
nsides
|
int
|
The number of sides of the polygon. |
required |
clip_dist
|
float = 0.1
|
The distance from the edge to 'soften' up to. |
0.1
|
invert
|
bool = False
|
Whether to invert the polygon. |
False
|
Returns:
Name | Type | Description |
---|---|---|
polygon |
Array
|
The softened polygon. |
Source code in src/dLux/utils/geometry.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
soft_spider
Calculates a soft-edged spider differentiably. The 'clip_dist' parameter defines the distance from the edge to 'soften' up to. A large clip_dist will result in a spider with a very soft edge, while a small clip_dist will result in a spider with a very hard edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords
|
Array
|
The coordinates to calculate the spider on. |
required |
width
|
float
|
The width of the spider. |
required |
angles
|
Array
|
The angles of the spider. |
required |
clip_dist
|
float = 0.1
|
The distance from the edge to 'soften' up to. |
0.1
|
invert
|
bool = False
|
Whether to invert the spider. |
False
|
Returns:
Name | Type | Description |
---|---|---|
spider |
Array
|
The softened spider. |
Source code in src/dLux/utils/geometry.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|