ami_function
Matched-filter utilities for aperture-masking interferometry.
The module builds Fourier-plane matched filters, aperture-mask index mappings, and closure-triangle pixel combinations used by the AMICAL bispectrum pipeline.
bs_multi_triangle(i, bs_arr, ft_frame, bs2bl_ix, mf, closing_tri_pix)
Accumulate a bispectrum sample using multiple closing triangles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
int
|
Frame index in |
required |
bs_arr
|
numpy.ndarray of complex, shape (n_frames, n_bispectra)
|
Bispectrum accumulator. |
required |
ft_frame
|
numpy.ndarray of complex, shape (ny, nx)
|
Fourier transform of the current image frame. |
required |
bs2bl_ix
|
numpy.ndarray of int, shape (3, n_bispectra)
|
Baseline indices forming each bispectrum. |
required |
mf
|
object
|
Matched-filter object returned by |
required |
closing_tri_pix
|
ndarray
|
Flattened-pixel combinations that close within a splodge. |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray of complex, shape (n_frames, n_bispectra)
|
|
Source code in src/amical/mf_pipeline/ami_function.py
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 | |
clos_unique(closing_tri_pix)
Remove duplicate closure triangles independent of pixel ordering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
closing_tri_pix
|
numpy.ndarray of shape (3, n_triangles)
|
Flattened Fourier-pixel indices for candidate triangle vertices. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Columns of |
Source code in src/amical/mf_pipeline/ami_function.py
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 | |
compute_index_mask(n_holes, verbose=False)
Build aperture-mask baseline, bispectrum, and covariance indices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_holes
|
int
|
Number of apertures in the mask. |
required |
verbose
|
bool
|
Whether to print the generated index arrays. |
False
|
Returns:
| Type | Description |
|---|---|
object
|
Index mappings with |
Source code in src/amical/mf_pipeline/ami_function.py
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 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | |
find_bad_BL_BS(bad_holes, bs)
Find observables affected by a set of rejected apertures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bad_holes
|
array-like of int
|
Aperture indices identified as bad. |
required |
bs
|
object
|
Extracted AMI observables containing mask baseline and bispectrum indices. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bad_baselines |
numpy.ndarray of int
|
Baseline indices containing a bad aperture. |
bad_bispect |
numpy.ndarray of int
|
Bispectrum indices containing a bad baseline. |
good_baselines |
array-like of int
|
Baseline indices not rejected. |
good_bispectrum |
array-like of int
|
Bispectrum indices not rejected. |
Source code in src/amical/mf_pipeline/ami_function.py
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 | |
find_bad_holes(bs, bmax=6, verbose=False, display=False)
Identify apertures with anomalously low calibrated visibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bs
|
object
|
Extracted AMI observables with baseline coordinates, wavelength, squared visibilities, and mask indices. |
required |
bmax
|
float
|
Maximum baseline length in metres shown in the diagnostic fit. |
6
|
verbose
|
bool
|
Whether to print linear-fit information. |
False
|
display
|
bool
|
Whether to display the visibility-fit diagnostic. |
False
|
Returns:
| Type | Description |
|---|---|
numpy.ndarray of int
|
Indices of apertures whose associated visibility ratio is at most 0.3. |
Source code in src/amical/mf_pipeline/ami_function.py
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 | |
give_peak_info2d(mf, n_baselines, dim1, dim2)
Convert flattened matched-filter peak indices to image coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mf
|
object
|
Matched-filter object returned by |
required |
n_baselines
|
int
|
Number of mask baselines. |
required |
dim1
|
int
|
Image dimensions in pixels. |
required |
dim2
|
int
|
Image dimensions in pixels. |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray of shape (n_baselines,)
|
Object array whose element for each baseline has rows |
Source code in src/amical/mf_pipeline/ami_function.py
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 | |
make_mf(maskname, instrument, filtname, npix, i_wl=None, peakmethod='fft', n_wl=3, theta_detector=0, cutoff=0.0001, hole_diam=0.8, fw_splodge=0.7, scaling=1, diag_plot=False, verbose=False, display=True, save_to=None, filename=None, index_mask=None)
Construct the Fourier-plane matched filter for an aperture mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maskname
|
str
|
Aperture-mask identifier. |
required |
instrument
|
str
|
Instrument identifier used to obtain mask coordinates and pixel scale. |
required |
filtname
|
str
|
Filter identifier. |
required |
npix
|
int
|
Square detector image size in pixels. |
required |
i_wl
|
int or sequence of int
|
Spectral-channel selector for SPHERE-IFS data. |
None
|
peakmethod
|
(fft, square, unique, gauss)
|
Method used to sample each Fourier splodge. |
"fft"
|
n_wl
|
int
|
Number of wavelengths used to sample the filter bandwidth. |
3
|
theta_detector
|
float
|
Mask rotation relative to the detector in degrees. |
0
|
cutoff
|
float
|
Minimum simulated matched-filter weight retained for a peak pixel. |
1e-4
|
hole_diam
|
float
|
Aperture-hole diameter in metres. |
0.8
|
fw_splodge
|
float
|
Relative Fourier-splodge size; also sets the Gaussian-method FWHM. |
0.7
|
scaling
|
float
|
Multiplicative scale applied to aperture-mask coordinates. |
1
|
diag_plot
|
bool
|
Whether to display the matched-filter overlap matrix. |
False
|
verbose
|
bool
|
Whether to print mask-index information. |
False
|
display
|
bool
|
Whether to display mask and Fourier-plane figures. |
True
|
save_to
|
str or path - like
|
Directory in which the mask-coordinate figure is saved. |
None
|
filename
|
str or path - like
|
Source filename used to name the saved figure. |
None
|
index_mask
|
object
|
Precomputed |
None
|
Returns:
| Type | Description |
|---|---|
object or None
|
Matched-filter data containing Fourier-pixel vectors and gains, baseline
coordinates in metres, wavelength information in metres, pixel scale in
radians per pixel, and overlap-correction matrices. Returns |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an SPHERE-IFS spectral channel is not specified. |
Source code in src/amical/mf_pipeline/ami_function.py
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 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 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 579 580 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 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | |
phase_chi2(p, fitmat, ph_mn, ph_err)
Evaluate the wrapped phase chi-square for a piston model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
numpy.ndarray of shape (n_holes,)
|
Fitted aperture-piston parameters in radians. |
required |
fitmat
|
numpy.ndarray of shape (n_holes, n_baselines + 1)
|
Matrix mapping aperture pistons to baseline phases plus a reference term. |
required |
ph_mn
|
numpy.ndarray of shape (n_baselines,)
|
Mean baseline phases in radians. |
required |
ph_err
|
numpy.ndarray of shape (n_baselines,)
|
Uncertainties on mean baseline phases in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Sum of squared wrapped phase residuals weighted by phase variance. |
Source code in src/amical/mf_pipeline/ami_function.py
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 | |
tri_pix(array_size, sampledisk_r, verbose=True, display=True)
Enumerate pixel triangles that close within a Fourier splodge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array_size
|
int
|
Size of the square Fourier image in pixels. |
required |
sampledisk_r
|
float
|
Radius of the sampled splodge in pixels. |
required |
verbose
|
bool
|
Whether to print the number of candidate triangles. |
True
|
display
|
bool
|
Whether to display sampled unique triangles. |
True
|
Returns:
| Type | Description |
|---|---|
numpy.ndarray of shape (3, n_triangles)
|
Flattened Fourier-pixel indices for all candidate closing triangles. |
Source code in src/amical/mf_pipeline/ami_function.py
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 | |