utils
A set of utility functions and constants used for unit conversions and adding generic structure common to multiple models.
K_CMB2K_RJ(freq)
Convert from K_CMB to K_RJ.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
freq |
float
|
The observing frequency in Hz. |
required |
Returns:
Name | Type | Description |
---|---|---|
K_CMB2K_RJ |
float
|
Conversion factor from K_CMB to K_RJ. |
Source code in witch/utils.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
beam_double_gauss(dr, fwhm1, amp1, fwhm2, amp2)
Helper function to generate a double gaussian beam.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dr |
float
|
Pixel size. |
required |
fwhm1 |
float
|
Full width half max of the primary gaussian in the same units as |
required |
amp1 |
float
|
Amplitude of the primary gaussian. |
required |
fwhm2 |
float
|
Full width half max of the secondairy gaussian in the same units as |
required |
amp2 |
float
|
Amplitude of the secondairy gaussian. |
required |
Returns:
Type | Description |
---|---|
beam: Double gaussian beam.
|
|
Source code in witch/utils.py
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
|
bilinear_interp(x, y, xp, yp, fp)
JAX implementation of bilinear interpolation. Out of bounds values are set to 0. Using the repeated linear interpolation method here, see https://en.wikipedia.org/wiki/Bilinear_interpolation#Repeated_linear_interpolation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Array
|
X values to return interpolated values at. |
required |
y |
Array
|
Y values to return interpolated values at. |
required |
xp |
Array
|
X values to interpolate with, should be 1D. Assumed to be sorted. |
required |
yp |
Array
|
Y values to interpolate with, should be 1D. Assumed to be sorted. |
required |
fp |
Array
|
Functon values at |
required |
Returns:
Name | Type | Description |
---|---|---|
f |
Array
|
The interpolated values. |
Source code in witch/utils.py
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
|
fft_conv(image, kernel)
Perform a convolution using FFTs for speed with jax.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
ArrayLike
|
Data to be convolved. |
required |
kernel |
ArrayLike
|
Convolution kernel. |
required |
Returns:
Name | Type | Description |
---|---|---|
convolved_map |
Array
|
Image convolved with kernel. |
Source code in witch/utils.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
get_da(z)
Get factor to convert from arcseconds to MPc.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
z |
float
|
The redshift at which to compute the factor. |
required |
Returns:
Name | Type | Description |
---|---|---|
da |
float
|
Conversion factor from arcseconds to MPc. |
Source code in witch/utils.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
get_hz(z)
Get the dimensionless hubble constant, h, at a given redshift.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
z |
float
|
The redshift at which to compute h. |
required |
Returns:
Name | Type | Description |
---|---|---|
hz |
float
|
h at the given z. |
Source code in witch/utils.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
get_nz(z)
Get the critical density at a given redshift.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
z |
float
|
The redshift at which to compute the critical density. |
required |
Returns:
Name | Type | Description |
---|---|---|
nz |
float
|
Critical density at the given z. |
Source code in witch/utils.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
make_grid(r_map, dx, dy=None, dz=None, x0=0, y0=0)
Make coordinate grids to build models in.
All grids are sparse and are int(2*r_map / dr)
in each the non-sparse dimension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
r_map |
float
|
Size of grid radially. |
required |
dx |
float
|
Grid resolution in x, should be in same units as r_map. |
required |
dy |
Optional[float]
|
Grid resolution in y, should be in same units as r_map. If None then dy is set to dx. |
None
|
dz |
Optional[float]
|
Grid resolution in z, should be in same units as r_map. If None then dz is set to dx. |
None
|
x0 |
float
|
Origin of grid in RA, assumed to be in same units as r_map. |
0
|
y0 |
float
|
Origin of grid in Dec, assumed to be in same units as r_map. |
0
|
Returns:
Name | Type | Description |
---|---|---|
x |
Array
|
Grid of x coordinates in same units as r_map. Has shape (`int(2*r_map / dr), 1, 1). |
y |
Array
|
Grid of y coordinates in same units as r_map. Has shape (1, `int(2*r_map / dr), 1). |
z |
Array
|
Grid of z coordinates in same units as r_map.
Has shape (1, 1, |
x0 |
float
|
Origin of grid in RA, in same units as r_map. |
y0 |
float
|
Origin of grid in Dec, in same units as r_map. |
Source code in witch/utils.py
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 |
|
make_grid_from_skymap(skymap, z_map, dz, x0=None, y0=None)
Make coordinate grids to build models in from a minkasi skymap.
All grids are sparse and match the input map and xy and have size int(2*z_map/dz)
in z.
Unlike make_grid
here we assume things are radians.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
skymap |
Skymap
|
The map to base the grid off of. |
required |
z_map |
float
|
Size of grid along LOS, in radians. |
required |
dz |
float
|
Grid resolution along LOS, in radians. |
required |
x0 |
Optional[float]
|
Map x center in radians. If None, grid center is used. |
None
|
y0 |
Optional[float]
|
Map y center in radians. If None, grid center is used. |
None
|
Returns:
Name | Type | Description |
---|---|---|
x |
Array
|
Grid of x coordinates in radians.
Has shape ( |
y |
Array
|
Grid of y coordinates in radians.
Has shape (1, |
z |
Array
|
Grid of z coordinates in same units as radians.
Has shape (1, 1, |
x0 |
float
|
Origin of grid in RA, in radians. |
y0 |
float
|
Origin of grid in Dec, in radians. |
Source code in witch/utils.py
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 |
|
tod_hi_pass(tod, N_filt)
High pass a tod with a tophat
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tod |
Array
|
TOD to high pass. |
required |
N_filt |
int
|
N_filt of tophat. |
required |
Returns:
Name | Type | Description |
---|---|---|
tod_filtered |
Array
|
High pass filtered TOD |
Source code in witch/utils.py
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 |
|
tod_to_index(xi, yi, x0, y0, grid, conv_factor=1.0)
Convert RA/Dec TODs to index space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xi |
NDArray[floating]
|
RA TOD, usually in radians |
required |
yi |
NDArray[floating]
|
Dec TOD, usually in radians |
required |
grid |
Grid
|
The grid to index on. |
required |
conv_factor |
float
|
Conversion factor to put RA and Dec in same units as the grid. |
1.
|
Returns:
Name | Type | Description |
---|---|---|
idx |
Array
|
The RA TOD in index space |
idy |
Array
|
The Dec TOD in index space. |
Source code in witch/utils.py
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
|
transform_grid(dx, dy, dz, r_1, r_2, r_3, theta, xyz)
Shift, rotate, and apply ellipticity to coordinate grid.
Note that the Grid
type is an alias for tuple[jax.Array, jax.Array, jax.Array, float, float]
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dx |
float
|
Amount to move grid origin in x |
required |
dy |
float
|
Amount to move grid origin in y |
required |
dz |
float
|
Amount to move grid origin in z |
required |
r_1 |
float
|
Amount to scale along x-axis |
required |
r_2 |
float
|
Amount to scale along y-axis |
required |
r_3 |
float
|
Amount to scale along z-axis |
required |
theta |
float
|
Angle to rotate in xy-plane in radians |
required |
xyz |
Grid
|
Coordinte grid to transform |
required |
Returns:
Name | Type | Description |
---|---|---|
trasnformed |
Grid
|
Transformed coordinate grid. |
Source code in witch/utils.py
415 416 417 418 419 420 421 422 423 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 |
|
y2K_CMB(freq, Te)
Convert from compton y to K_CMB.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
freq |
float
|
The observing frequency in Hz. |
required |
Te |
float
|
Electron temperature |
required |
Returns:
Name | Type | Description |
---|---|---|
y2K_CMB |
float
|
Conversion factor from compton y to K_CMB. |
Source code in witch/utils.py
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 |
|
y2K_RJ(freq, Te)
Convert from compton y to K_RJ.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
freq |
float
|
The observing frequency in Hz. |
required |
Te |
float
|
Electron temperature |
required |
Returns:
Name | Type | Description |
---|---|---|
y2K_RJ |
float
|
Conversion factor from compton y to K_RJ. |
Source code in witch/utils.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|