Detector Layers¤
GaussianJitter
dLuxToliman.layers.detector_layers.GaussianJitter
¤
Bases: BaseJitter
Convolves the image with a multivariate Gaussian kernel parameterised by the magnitude, shear and angle.
Attributes:
| Name | Type | Description |
|---|---|---|
kernel_size |
int
|
The size in pixels of the convolution kernel to use. |
r |
(float, arcseconds ^ 4)
|
The magnitude of the jitter, (sigma_major * sigma_minor)^2. |
shear |
float
|
The shear of the jitter. |
phi |
(float, degrees)
|
The angle of the jitter. |
kernel_size |
(int, odd)
|
The size of the convolution kernel in pixels to use. |
kernel_oversample |
int
|
Unused; the kernel is built in Fourier space and needs no oversampling. Kept so that existing code passing it still runs. |
Source code in dLuxToliman/layers/detector_layers.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 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 133 134 135 136 137 138 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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 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 | |
covariance_matrix
property
¤
Generates the covariance matrix for the multivariate normal distribution.
Returns:
| Name | Type | Description |
|---|---|---|
covariance_matrix |
Array
|
The covariance matrix. |
__call__(psf)
¤
Blurs the PSF by multiplying its Fourier transform by the Gaussian's.
This is exact for a well-sampled PSF at any jitter width. A kernel sampled on the pixel grid is not: once the jitter is narrower than about a pixel it puts almost all of its weight in the central pixel and drops most of the blur, worst along the minor axis of a sheared kernel. The PSF is zero-padded by kernel_size // 2 pixels on each side first, so the edges behave like a convolution with a kernel_size kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psf
|
PSF
|
The PSF object to operate on. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
psf |
PSF
|
The blurred PSF object. |
Source code in dLuxToliman/layers/detector_layers.py
196 197 198 199 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 | |
__init__(r, shear=0, phi=0, kernel_size=11, kernel_oversample=1)
¤
Constructor for the ApplyJitter class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
float
|
The jitter magnitude, defined as the determinant of the covariance matrix of the multivariate Gaussian kernel. This is the square of the product of the standard deviations of the minor and major axes of the kernel, (sigma_major * sigma_minor)^2, in arcseconds^4. A symmetric kernel has variance sqrt(r) arcseconds^2. |
required |
shear
|
float, [0, 1)
|
A measure of how asymmetric the jitter is. Defined as one minus the ratio between the standard deviations of the minor/major axes of the multivariate Gaussian kernel. It must lie on the interval [0, 1). A shear of 0 corresponds to a symmetric jitter, while as shear approaches one the jitter kernel becomes more linear. |
0
|
phi
|
float
|
The angle of the jitter in degrees. |
0
|
kernel_size
|
int = 11
|
The PSF is zero-padded by kernel_size // 2 pixels before the blur, and generate_kernel returns a kernel of this size. It should span at least ~8 standard deviations of the major axis, so that light blurred past the image edge is not wrapped onto the opposite edge. |
11
|
kernel_oversample
|
int = 1
|
Unused; kept so that existing code passing it still runs. |
1
|
Source code in dLuxToliman/layers/detector_layers.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 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 133 134 135 | |
generate_kernel(pixel_scale)
¤
The blur that the layer applies, as a normalised kernel_size x kernel_size kernel, e.g. for plotting. It is computed on a grid four times larger and cropped, so that it matches the layer. Below about one pixel it has small negative side lobes, as any band-limited blur does.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pixel_scale
|
float
|
The pixel scale of the image in arcseconds per pixel. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
kernel |
Array
|
The normalised Gaussian kernel. |
Source code in dLuxToliman/layers/detector_layers.py
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 | |
transfer_function(fx, fy)
¤
The Fourier transform of the Gaussian kernel, exp(-2 pi^2 f^T C f).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fx
|
Array
|
Spatial frequencies along x (columns), in cycles per arcsecond. |
required |
fy
|
Array
|
Spatial frequencies along y (rows), in cycles per arcsecond. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
transfer |
Array
|
The transfer function evaluated at (fx, fy). |
Source code in dLuxToliman/layers/detector_layers.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
SHMJitter
dLuxToliman.layers.detector_layers.SHMJitter
¤
Bases: BaseJitter
A class to simulate the effect of a one-dimensional simple harmonic jitter. This would be used in the case that the jitter is dominated by a single high-frequency vibration.
Source code in dLuxToliman/layers/detector_layers.py
259 260 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 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 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 | |
CDF(x)
¤
The cumulative distribution function for the simple harmonic motion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
The input values. |
required |
Source code in dLuxToliman/layers/detector_layers.py
329 330 331 332 333 334 335 336 337 338 339 | |
__init__(A, phi, kernel_size=11)
¤
Constructor for the ApplySHMJitter class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
(float, arcseconds)
|
The amplitude of the oscillation. |
required |
phi
|
(float, deg)
|
The angle of the jitter in degrees. |
required |
kernel_size
|
int = 9
|
The size of the convolution kernel in pixels to use. It is important for simple harmonic jitter that the kernel size is large enough to capture the full extent of the jitter. The optimal_kernel_size method will return a value for kernel_size that it recommended, or at least is a lower bound on usable values. |
11
|
Source code in dLuxToliman/layers/detector_layers.py
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 | |
generate_kernel(pixel_scale)
¤
Generates the normalised multivariate Gaussian kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pixel_scale
|
float
|
The pixel scale of the image in arcseconds per pixel. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
kernel |
Array
|
The normalised convolution kernel. |
Source code in dLuxToliman/layers/detector_layers.py
341 342 343 344 345 346 347 348 349 350 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 | |
machine_epsilon(dtype)
staticmethod
¤
Method to fetch machine epsilon for a given dtype (e.g. float32, float64).
Source code in dLuxToliman/layers/detector_layers.py
321 322 323 324 325 326 327 | |
optimal_kernel_size(pixel_scale)
¤
Calculates the recommended kernel size in pixels for a given pixel scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pixel_scale
|
float
|
The pixel scale of the image in arcseconds per pixel. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
kernel_size |
int
|
The kernel size in pixels. |
Source code in dLuxToliman/layers/detector_layers.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |