noise
Noise models for maps where the CMB is a significant noise source.
The CMB power spectrum is the lensed TT spectrum of the Planck 2018 cosmology, stored in
witch/data/lensed_tt_planck2018.npz, so CAMB is not needed by default. To use another
cosmology generate a spectrum with generate_lensed_dl (needs the optional camb extra) and
pass it as dl to cmb_cl, cmb_covariance or NoiseCMBMap, see scripts/make_lensed_dl.py
to store one. CAMB also covers the scales above the patch size that a covariance measured
from a map cannot.
Note
This is an interim model that is expected to be replaced by the multi-frequency
NoiseMapCov model, which takes cross-covariance files for every pair of datasets.
See the PR that added this module for what the replacement has to keep or change
(the sample hook in fitter.process_maps, resolve_noise_args, sim_seed and
sim_noise_kwargs). The stored CMB spectrum is still useful there for the scales
above the patch size.
NoiseCMBMap
Dense map noise model: white instrument noise from ivar plus a CMB covariance.
The mean of the map is also marginalised over since cutouts have an arbitrary offset.
This is a registered pytree and only suitable for small maps (the inverse is dense).
Attributes:
| Name | Type | Description |
|---|---|---|
ninv |
Array
|
The |
shape |
tuple[int, int]
|
Shape of the maps this is applied to. This is static pytree data. |
Source code in witch/noise.py
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 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
apply_noise(dat)
Apply the inverse covariance to a map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dat
|
Array
|
Map to filter, with shape |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dat_filt |
Array
|
|
Source code in witch/noise.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
compute(dat, ivar, pix_deg, cmb_scale=1.0, mean_sigma=1000.0, **kwargs)
classmethod
Build the noise model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dat
|
Array
|
The map, only used for its shape. |
required |
ivar
|
Array
|
Inverse variance of the white noise per pixel. Pixels with 0 get no weight. |
required |
pix_deg
|
float
|
Pixel size in degrees (sign is ignored). |
required |
cmb_scale
|
float
|
Multiplier on the CMB covariance. |
1.0
|
mean_sigma
|
float
|
Prior width on the map offset in uK. |
1e3
|
**kwargs
|
Any
|
Passed to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
noise_model |
NoiseCMBMap
|
The noise model. |
Source code in witch/noise.py
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 | |
sample(key, dat, ivar, pix_deg, cmb_scale=1.0, **kwargs)
classmethod
Draw a noise realisation from the same model compute uses, minus the mean prior.
The ivar weighted mean is removed to match load_maps, and pixels with no weight are zeroed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Array
|
PRNG key. |
required |
dat
|
Array
|
The map, only used for its shape. |
required |
ivar
|
Array
|
Inverse variance of the white noise per pixel. |
required |
pix_deg
|
float
|
Pixel size in degrees (sign is ignored). |
required |
cmb_scale
|
float
|
Multiplier on the CMB covariance. |
1.0
|
**kwargs
|
Any
|
Passed to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
noise |
Array
|
A noise map with the shape of |
Source code in witch/noise.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
NoiseSpectrum
Bases: NoiseCMBMap
Dense map noise model from an empirically measured stationary power spectrum.
The spectrum is the output of ring_cross_spectra for a single band, measured for example
on control fields of the same map. The mean of the map is marginalised over.
Only suitable for small maps (the inverse is dense), the pixels must match the spectrum grid.
Warning
Interim model kept for comparisons: it assumes a stationary, periodic noise measured offline from control fields or splits. It is not the ACT noise estimate and should be replaced by it.
Source code in witch/noise.py
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | |
compute(dat, ivar, pix_deg, power_path, mean_sigma=0.0001)
classmethod
Build the noise model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dat
|
Array
|
The map, only used for its shape which must be that of the spectrum. |
required |
ivar
|
Array
|
Unused, kept so the signature matches |
required |
pix_deg
|
float
|
Unused, the spectrum is already in pixel units. |
required |
power_path
|
str
|
|
required |
mean_sigma
|
float
|
Prior width on the map offset in map units. |
1e-4
|
Returns:
| Name | Type | Description |
|---|---|---|
noise_model |
NoiseSpectrum
|
The noise model. |
Source code in witch/noise.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | |
cmb_cl(ell, fg_dl3000=100.0, fwhm_arcmin=2.0, dl=None)
Beam smoothed lensed CMB plus a crude white foreground power spectrum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ell
|
ndarray
|
Multipoles. |
required |
fg_dl3000
|
float
|
Foreground D_l at l=3000 in uK^2, scaled as l^2 (white in C_l). |
100.0
|
fwhm_arcmin
|
float
|
FWHM of the Gaussian beam the map was smoothed with. |
2.0
|
dl
|
ndarray
|
Lensed CMB D_l in uK_CMB^2 indexed by l, from |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
cl |
ndarray
|
C_l in uK^2 sr, including the beam window squared. |
Source code in witch/noise.py
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 | |
cmb_covariance(shape, pix_arcmin, **kwargs)
Pixel-pixel covariance of the beam smoothed CMB on a flat patch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple[int, int]
|
Shape of the map. |
required |
pix_arcmin
|
float
|
Pixel size in arcmin. |
required |
**kwargs
|
Any
|
Passed to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
cov |
ndarray
|
The |
Source code in witch/noise.py
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 | |
cmb_covariance_multiband(shape, pix_arcmin, fwhms, fg_dl3000=100.0, dl=None)
Joint covariance of the primary CMB in several bands on the same flat patch.
The CMB is the same sky in every band (in uK_CMB) so the bands are perfectly correlated
apart from their beams. Block (i, j) has the spectrum times b_i(l) b_j(l), which for
Gaussian beams is the single band form with fwhm = sqrt((fwhm_i^2 + fwhm_j^2) / 2).
The crude white foreground term is only added to the auto blocks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple[int, int]
|
Shape of the maps, which all share a pixelisation. |
required |
pix_arcmin
|
float
|
Pixel size in arcmin. |
required |
fwhms
|
Sequence[float]
|
Beam FWHM of each band in arcmin. |
required |
fg_dl3000
|
float
|
Foreground D_l at l=3000 in uK^2 for the auto blocks, see |
100.0
|
dl
|
ndarray
|
Lensed CMB D_l indexed by l, see |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
cov |
ndarray
|
The |
Source code in witch/noise.py
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 | |
generate_lensed_dl(lmax=10000, **cosmology)
Lensed LCDM TT spectrum from CAMB.
Needs the optional camb dependency. The stored default spectrum was made with this
function and the Planck 2018 parameters, see scripts/make_lensed_dl.py.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lmax
|
int
|
Maximum multipole. |
10000
|
**cosmology
|
float
|
Parameters passed to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dl |
ndarray
|
D_l = l(l+1)C_l/2pi in uK_CMB^2, indexed by l. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
Source code in witch/noise.py
46 47 48 49 50 51 52 53 54 55 56 57 58 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 | |
noise_covariance(power, ix, iy)
Stationary noise covariance of a set of pixels from the 2D power.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power
|
ndarray
|
Output of |
required |
ix
|
ndarray
|
Pixel indices of the pixels to use, flattened. |
required |
iy
|
ndarray
|
Pixel indices of the pixels to use, flattened. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
cov |
ndarray
|
|
Source code in witch/noise.py
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 | |
ring_cross_spectra(noise)
Ring averaged cross power of the noise realisations of several bands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
noise
|
ndarray
|
Shape |
required |
Returns:
| Name | Type | Description |
|---|---|---|
power |
ndarray
|
The 2D power |
ring |
ndarray
|
Integer ring index of each Fourier mode, shape |
Source code in witch/noise.py
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 259 260 261 | |