beam_utils
Utility functions for working with beam maps.
TODO: Make everything radians
crop_maps(maps, cent, extent)
Crop a list of maps to be smaller. Note that all input maps will be cropped relative to the same pixel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maps
|
list[Float[ndmap, 'nx ny']]
|
List of maps to crop. These should all have the same center. |
required |
cent
|
tuple[int, int]
|
The index of the center pixel. |
required |
extent
|
int
|
The extent of the output map. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
cropped |
list[Float[ndmap "2extent 2extent"]]
|
The cropped maps. Each one will have size (2extent, 2extent) unless that goes outside of the input map's bounding box, in which case the cropped map stops at that box. |
Source code in lat_beams/beam_utils.py
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 | |
estimate_cent(imap, sigma=5, buf=30)
Estimate the location of the central pixel of a beam map.
To do this we first smooth the map with a gaussian of size sigma,
then we take the location of the maximum that is farther than buf from the edge of the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
imap
|
Float[ndarray, (nx, ny)]
|
The beam map to look for the center of. |
required |
sigma
|
float
|
The sigma of the gaussian in pixels to smooth the map by when searching for the max. |
5
|
buf
|
int
|
Pixels within |
30
|
Returns:
| Name | Type | Description |
|---|---|---|
cent |
tuple[int, int]
|
The index of the estimated center pixel. |
Source code in lat_beams/beam_utils.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 | |
estimate_solid_angle(imap, model, res, data_fwhm, cent, min_sigma)
Estimate the solid angle of a map given a fit model. Here we correct for the bias in our solid angle integration by computing:
Where \(\tilde{\Omega}\) implies a solid angle estimated with the solid_angle function from this module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
imap
|
Float[ndarray, 'nx ny']
|
The input map to estimate the solid angle of. |
required |
model
|
Float[ndarray, 'nx ny']
|
Model of map to estimate the solid angle of. |
required |
res
|
float
|
The resolution of the map in arcseconds. |
required |
data_fwhm
|
float
|
The FWHM of the map in arcseconds. |
required |
cent
|
tuple[int, int]
|
The index of the center pixel. |
required |
min_sigma
|
float
|
The number of sigma to use as the radius for aperture photometry. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
data_solid_angle_meas |
float
|
\(\tilde{\Omega_{imap}}\) in stradians. |
model_solid_angle_meas |
float
|
\(\tilde{\Omega_{model}}\) in stradians. |
model_solid_angle_true |
float
|
\(Omega_{model}\) in stradians. |
data_solid_angle_corr |
float
|
\(Omega\) in stradians. |
Source code in lat_beams/beam_utils.py
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 | |
get_fit_vec(all_fits, name, fall_back=None)
Get a fit value from all fits in a structured array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
all_fits
|
Shaped[ndarray, nfits]
|
The fits to get values from.
See |
required |
name
|
str
|
The name of the field to load from the AxisManagers in
|
required |
fall_back
|
str
|
Field to load in |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
fit_vec |
Quantity
|
The loaded values.
Will have length |
Source code in lat_beams/beam_utils.py
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | |
get_fwhm_radial_bins(r, y, interpolate=False, frac=0.5)
Estimate FWHM from a radial profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
Float[ndarray, nr]
|
The radial position at each point. |
required |
y
|
Float[ndarray, nr]
|
The value of the profile at each point. |
required |
interpolate
|
bool
|
If True then interpolate the input profile on an evenly spaced grid of 100 points before estimating the FWHM. |
False
|
frac
|
float
|
The fraction of the peak to get the width at. By default this is 0.5 which is the FWHM, but other values can be passed if needed. |
0.5
|
Returns:
| Name | Type | Description |
|---|---|---|
fwhm |
float
|
The estimated FWHM in the same units as |
Source code in lat_beams/beam_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 | |
get_split_vec(fits, split, ctx, round_to=2, metasplits={})
Get an array of metadata to split fits by.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fits
|
Shaped[ndarray, nfits]
|
The fits to get values from.
See |
required |
split
|
str
|
List of collumns in |
required |
ctx
|
Context
|
Context used to lookup values from the obsdb. |
required |
round_to
|
int
|
How many decimal places to round numeric collumns to. |
2
|
metasplits
|
dict[str, tuple[str, list[str | float]]]
|
A method of defining a collumn that matches against values
from a normal split collumn. Each entry should have some |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
split_vec |
Shaped[ndarray, nfits]
|
Array of strings containing the values from the split collumns.
Values are in the same order as |
Source code in lat_beams/beam_utils.py
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 | |
load_beam_fits_from_jobs(fpath, joblist, jdb=None)
Load beam fits from a list of jobs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fpath
|
str
|
The path to the HDF5 file containing the fits. |
required |
job
|
list[Job]
|
List of jobs to load fits for.
Jobs should be of jclass |
required |
Returns:
| Name | Type | Description |
|---|---|---|
all_fits |
Shaped[ndarray, nfits]
|
Loaded fits. This is a numpy structured array with the following collumns:
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If loaded fits do not all contain the same structure. |
Source code in lat_beams/beam_utils.py
468 469 470 471 472 473 474 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 523 524 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 | |
process_model(aman, solved, model, noise, min_snr, c, map_units, pixsize, data_fwhm, min_sigma, job, logger)
Convenience function to postproccess a map and it's fit model. This fundtion checks the SNR of the model, computes its radial profile, and computes the solid angle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aman
|
AxisManager
|
AxisManager with the fit parameters. No values are read off this, but it wil be modified in place. |
required |
solved
|
Float[ndarray, 'nx ny']
|
The map that was fit. |
required |
model
|
Float[ndarray, 'nx ny']
|
The model computed on the same grid as the map. |
required |
noise
|
float
|
The noise level of the map. |
required |
min_snr
|
float
|
The minimum SNR of the model.
If the SNR is less than this then |
required |
c
|
tuple[int, int]
|
The index of the center pixel. |
required |
map_units
|
Unit
|
The units of the map. |
required |
pixsize
|
float
|
The pixel size in arcseconds. |
required |
data_fwhm
|
float
|
The data fwhm in arcseconds. |
required |
min_sigma
|
float
|
See |
required |
job
|
Optional[Job]
|
The job associated with the fit.
Pass |
required |
logger
|
Optional[LoggerLike]
|
The logger to log with.
Pass |
required |
Returns:
| Name | Type | Description |
|---|---|---|
aman |
Optional[AxisManager]
|
The input |
Source code in lat_beams/beam_utils.py
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 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 | |
radial_profile(data, center, avg=True)
Compute the radial profile of a beam, this is a naive way of doing thing just looking at the pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Float[ndarray, 'nx ny']
|
The input beam. |
required |
center
|
tuple[int, int]
|
The index of the center pixel. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
radialprofile |
Float[ndarray, nr]
|
Radial profile of the input map. |
Source code in lat_beams/beam_utils.py
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 | |
radial_profile_lin(data, posmap, xi0=0.0, eta0=0.0, r=None, n_bins=None, rmax=None)
Compute the azimuthally averaged radial profile using the true beam center. This computes a matrix for the binning operation that can be reused.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Map to bin. |
required |
posmap
|
tuple[ndarray, ndarray]
|
Beam-coordinate maps |
required |
xi0
|
float
|
Beam center in the same units as |
0.0
|
eta0
|
float
|
Beam center in the same units as |
0.0
|
r
|
ndarray
|
Radial bin centers. If omitted, |
None
|
n_bins
|
int
|
Number of radial bins when |
None
|
rmax
|
float
|
Maximum radius when generating bins. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
r |
ndarray
|
Radial bin centers. |
profile |
ndarray
|
Azimuthally averaged radial profile. |
R |
csr_matrix
|
Radial binning operator satisfying
|
Source code in lat_beams/beam_utils.py
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 257 258 259 | |
solid_angle(az, el, beam, cent, r1, norm)
Compute the integrated solid angle of a beam map. This uses aperture photometry to handle bias from the background of the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
az
|
Float[ndarray, nx]
|
The x coordinates of the map in arcseconds. |
required |
el
|
Float[ndarray, nx]
|
The y coordinates of the map in arcseconds. |
required |
beam
|
Float[ndarray, 'nx ny']
|
The beam map to compute the solid angle of. |
required |
cent
|
tuple[int, int]
|
The index of the center pixel. |
required |
r1
|
float
|
The radius of the inner ring in aperture photometry in arcseconds. |
required |
norm
|
float
|
The value to normalize the map by. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
solid_angle |
float
|
the solid angle in stradians. |
Source code in lat_beams/beam_utils.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 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 | |