Geometry¤
combine
dLux.utils.geometry.combine(arrays, oversample=1, use_sum=False)
¤
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
|
use_sum
|
bool = False
|
Whether to sum the arrays instead of multiplying them. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
array |
Array
|
The combined array, optionally downsampled by |
Source code in dLux/utils/geometry.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
circle
dLux.utils.geometry.circle(coords, radius, invert=False)
¤
Calculates a hard-edged circle. 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 dLux/utils/geometry.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
square
dLux.utils.geometry.square(coords, width, invert=False)
¤
Calculates a hard-edged square. 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 dLux/utils/geometry.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
rectangle
dLux.utils.geometry.rectangle(coords, width, height, invert=False)
¤
Calculates a hard-edged rectangle. 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 |
invert
|
bool = False
|
Whether to invert the rectangle. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
rectangle |
Array
|
The rectangle. |
Source code in dLux/utils/geometry.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
reg_polygon
dLux.utils.geometry.reg_polygon(coords, rmax, nsides, invert=False)
¤
Calculates a hard-edged regular polygon. 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 dLux/utils/geometry.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
spider
dLux.utils.geometry.spider(coords, width, angles)
¤
Calculates a hard-edged spider. 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 in degrees. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
spider |
Array
|
The spider. |
Source code in dLux/utils/geometry.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
soft_circle
dLux.utils.geometry.soft_circle(coords, radius, clip_dist=0.1, invert=False)
¤
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. |
0.1
|
invert
|
bool = False
|
Whether to invert the circle. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
circle |
Array
|
The softened circle. |
Source code in dLux/utils/geometry.py
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 | |
soft_square
dLux.utils.geometry.soft_square(coords, width, clip_dist=0.1, invert=False)
¤
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. |
0.1
|
invert
|
bool = False
|
Whether to invert the square. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
square |
Array
|
The softened square. |
Source code in dLux/utils/geometry.py
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 281 | |
soft_rectangle
dLux.utils.geometry.soft_rectangle(coords, width, height, clip_dist=0.1, invert=False)
¤
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
|
invert
|
bool = False
|
Whether to invert the rectangle. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
rectangle |
Array
|
The softened rectangle. |
Source code in dLux/utils/geometry.py
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 | |
soft_reg_polygon
dLux.utils.geometry.soft_reg_polygon(coords, radius, nsides, clip_dist=0.1, invert=False)
¤
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 dLux/utils/geometry.py
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 349 350 351 | |
soft_spider
dLux.utils.geometry.soft_spider(coords, width, angles, clip_dist=0.1, invert=False)
¤
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 dLux/utils/geometry.py
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 386 387 388 | |