tools.py
Functions and classes related to VAST that have no specific category and can be used generically.
WiseClass
¶
Bases: Enum
WISE object classes defined in the WISE color-color plot.
Source code in vasttools/tools.py
671 672 673 674 675 676 677 678 679 680 681 682 |
|
WisePatchConfig
dataclass
¶
Style and annotation configurations for the patch drawn to represent a WISE object class in the WISE color-color plot.
Attributes:
Name | Type | Description |
---|---|---|
style | Dict[str, Any] | Any style keyword arguments and values supported by |
annotation_text | str | Text to annotate the patch. |
annotation_position | Tuple[float, float] | Position in data coordinates for the annotation text. |
Source code in vasttools/tools.py
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 |
|
add_credible_levels(filename, df, pipe=True)
¶
Calculate the minimum credible region containing each source and add to the dataframe in-place.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename | str | Path to the healpix skymap file. | required |
df | DataFrame | Dataframe of sources. | required |
pipe | bool | Whether the dataframe is from the pipeline. Defaults to True. | True |
Returns:
Type | Description |
---|---|
None | None |
Raises:
Type | Description |
---|---|
Exception | Path does not exist. |
Source code in vasttools/tools.py
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 |
|
add_obs_date(epoch, image_type, image_dir, epoch_path=None)
¶
Add datetime information to all fits files in a single epoch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
epoch | str | The epoch of interest. | required |
image_type | str |
| required |
image_dir | str | The name of the folder containing the images to be updated. E.g. | required |
epoch_path | str | Full path to the folder containing the epoch. Defaults to None, which will set the value based on the | None |
Returns:
Type | Description |
---|---|
None | None |
Raises:
Type | Description |
---|---|
ValueError | When image_type is not 'TILES' or 'COMBINED'. |
Source code in vasttools/tools.py
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 |
|
create_fields_metadata(epoch_num, db_path, outdir='.')
¶
Create and write the fields csv and skycoord pickle for a single epoch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
epoch_num | str | Epoch number of interest. | required |
db_path | str | Path to the askap_surveys database. | required |
outdir | Union[str, Path] | Path to the output directory. Defaults to the current directory. | '.' |
Returns:
Type | Description |
---|---|
None | None |
Raises:
Type | Description |
---|---|
Exception | Database path does not exist. |
Source code in vasttools/tools.py
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 |
|
find_in_moc(moc, df, pipe=True)
¶
Find the sources that are contained within a MOC
Parameters:
Name | Type | Description | Default |
---|---|---|---|
moc | MOC | The MOC of interest. | required |
df | DataFrame | Dataframe of sources. | required |
pipe | bool | Whether the dataframe is from the pipeline. Defaults to True. | True |
Returns:
Type | Description |
---|---|
ndarray | Indices of all sources contained within the MOC. |
Source code in vasttools/tools.py
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 |
|
gen_mocs_epoch(epoch, image_type, image_dir, epoch_path=None, outdir='.', base_stmoc=None)
¶
Generate MOCs and STMOCs for all images in a single epoch, and create a new full pilot STMOC.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
epoch | str | The epoch of interest. | required |
image_type | str |
| required |
image_dir | str | The name of the folder containing the images to be updated. E.g. | required |
epoch_path | str | Full path to the folder containing the epoch. Defaults to None, which will set the value based on the | None |
outdir | Union[str, Path] | Path to the output directory. Defaults to the current directory. | '.' |
base_stmoc | Union[str, Path] | Path to the STMOC to use as the base. Defaults to | None |
Returns:
Type | Description |
---|---|
None | None |
Raises:
Type | Description |
---|---|
Exception | Output directory does not exist. |
Source code in vasttools/tools.py
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 |
|
gen_mocs_image(fits_file, outdir='.', write=False)
¶
Generate a MOC and STMOC for a single fits file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fits_file | str | path to the fits file. | required |
outdir | Union[str, Path] | Path to the output directory. Defaults to the current directory. | '.' |
write | bool | Write the MOC/STMOC to file. | False |
Returns:
Type | Description |
---|---|
Union[MOC, STMOC] | The MOC and STMOC. |
Raises:
Type | Description |
---|---|
Exception | Output directory does not exist. |
Exception | Fits file does not exist. |
Source code in vasttools/tools.py
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 486 487 488 489 490 491 492 493 494 495 496 497 |
|
offset_postagestamp_axes(ax, centre_sc, ra_units=u.arcsec, dec_units=u.arcsec, ra_label='R.A. Offset', dec_label='Dec. Offset', major_tick_length=6, minor_tick_length=3)
¶
Display axis ticks and labels as offsets from a given coordinate, rather than in absolute coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax | Axes | The axis of interest | required |
centre_sc | SkyCoord | SkyCoord to calculate offsets from | required |
ra_units | Unit | Right Ascension axis ticklabel units | arcsec |
dec_units | Unit | Declination axis ticklabel units | arcsec |
ra_label | str | Right Ascension axis label | 'R.A. Offset' |
dec_label | str | Declination axis label | 'Dec. Offset' |
major_tick_length | Union[int, float] | Major tick length in points | 6 |
minor_tick_length | Union[int, float] | Minor tick length in points | 3 |
Returns:
Type | Description |
---|---|
None | None |
Raises:
Type | Description |
---|---|
Exception | R.A. and Dec. units must be angles. |
Source code in vasttools/tools.py
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 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 |
|
skymap2moc(filename, cutoff)
¶
Creates a MOC of the specified credible region of a given skymap.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename | str | Path to the healpix skymap file. | required |
cutoff | float | Credible level cutoff. | required |
Returns:
Type | Description |
---|---|
MOC | A MOC containing the credible region. |
Raises:
Type | Description |
---|---|
ValueError | Credible level cutoff must be between 0 and 1. |
Exception | Skymap path does not exist. |
Source code in vasttools/tools.py
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 |
|
wise_color_color_plot(patch_style_overrides=None, annotation_text_size='x-small')
¶
Make an empty WISE color-color plot with common object classes drawn as patches. The patches have default styles that may be overridden. To override a patch style, pass in a dict containing the desired style and annotation settings. The overrides must be complete, i.e. a complete WisePatchConfig
object must be provided for each WiseClass
you wish to modify. Partial updates to the style or annotation of individual patches is not supported.
For example, to change the color of the stars patch to blue:
fig = wise_color_color_plot({
WiseClass.STARS: WisePatchConfig(
style=dict(fc="blue", ec="none"),
annotation_text="Stars",
annotation_position=(0.5, 0.4),
)
})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
patch_style_overrides | Optional[Dict[WiseClass, WisePatchConfig]] | Override the default patch styles for the given WISE object class. If None, use defaults for each patch. Defaults to None. | None |
annotation_text_size | Union[float, str] | Font size for the patch annotations. Accepts a font size (float) or a matplotlib font scale string (e.g. "xx-small", "medium", "xx-large"). Defaults to "x-small". | 'x-small' |
Returns:
Type | Description |
---|---|
Figure | The WISE color-color figure. The axes can be accessed via |
Source code in vasttools/tools.py
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 |
|