legacy
Legacy CANDID and Pymask interface, computed with virgil.
AMICAL used to bundle CANDID (A. Merand & A. Gallenne) and Pymask (B. Pope & A. Cheetham) to analyse calibrated OIFITS files. The functions below keep the names, arguments and return values of the AMICAL wrappers around them, but do the work with virgil (https://benjaminpope.github.io/virgil/), so that existing scripts keep running:
candid_grid: grid search and least-squares fit of a binary (primary of uniform-disk diameterdiamplus a point-source companion);candid_cr_limit: detection limits (Absil et al. 2011) around the target, optionally after removing a fitted companion;pymask_grid: chi2 grid of a binary in separation, position angle and contrast ratio, on the closure phases only;pymask_mcmc: posterior of the same binary, sampled with NUTS (HMC);pymask_cr_limit: contrast limits versus separation, on the closure phases only.
The numbers are close to, but not identical with, those of the original
packages: CANDID's "injection" limits and Pymask's Monte Carlo limits are
replaced by the Absil limits (both give the companions that would have been
detected at 3 sigma), Pymask's emcee is replaced by NUTS, and virgil whitens
the correlated closure phases together, so uncertainties no longer need an
err_scale for their redundancy (and are wider than Pymask's were). For new
work, use virgil directly (see the companion search tutorial in the AMICAL
documentation).
virgil needs Python >= 3.11 and JAX: pip install amical[virgil].
candid_cr_limit(input_data, step=10, rmin=20, rmax=400, extra_error_cp=0, err_scale=1, extra_error_v2=0, obs=None, fitComp=None, ncore=1, diam=None, methods=None, instruments=None, save=False, outputfile=None)
Compute 3-sigma detection limits around the target, CANDID style (computed with virgil).
At each position of a map of step step out to rmax, the companion flux
ruled out at 3 sigma is found by the method of Absil et al. (2011)
(virgil.limits.absil_limits). CANDID's "injection" method is not
available: every requested method returns the Absil limits. A companion
fitted with candid_grid (its "comp" entry) can be removed first with
fitComp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
str or list of str
|
OIFITS file name or names. |
required |
step
|
int
|
Map step in milliarcseconds. |
10
|
rmin
|
float
|
Minimum separation in milliarcseconds. |
20
|
rmax
|
float
|
Maximum separation in milliarcseconds. |
400
|
extra_error_cp
|
float
|
Additional closure-phase uncertainty in degrees, added in quadrature. |
0
|
err_scale
|
float
|
Multiplicative closure-phase error-bar scale. |
1
|
extra_error_v2
|
float
|
Additional squared-visibility uncertainty, added in quadrature. |
0
|
obs
|
list of str or None
|
Observables to use. Defaults to |
None
|
fitComp
|
dict or None
|
Companion ( |
None
|
ncore
|
int
|
Unused; kept for compatibility. |
1
|
diam
|
float or None
|
Primary-star diameter in milliarcseconds. |
None
|
methods
|
list of str or None
|
Names under which the limits are returned. Defaults to
|
None
|
instruments
|
str or list of str
|
INSNAME(s) of the OIFITS tables to use. Uses all tables when omitted. |
None
|
save
|
bool
|
Whether to save the detection-limit map as a PDF. |
False
|
outputfile
|
str or None
|
Filename for the saved detection-limit map. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Separations ( |
Source code in src/amical/analysis/legacy.py
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 | |
candid_grid(input_data, step=10, rmin=20, rmax=400, diam=0, obs=None, extra_error_cp=0, err_scale=1, extra_error_v2=0, instruments=None, doNotFit=None, ncore=1, save=False, outputfile=None, verbose=False)
Fit a binary model to the calibrated data, CANDID style (computed with virgil).
The log-likelihood of a companion is mapped on a grid of offsets between
rmin and rmax (no coarser than step), and the best grid points are
refined by least squares (virgil.fitting.fit). The primary is a
uniform disk of diameter diam, fitted too unless "diam*" is in
doNotFit. Uncertainties come from the Fisher matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
str or list of str
|
OIFITS file name or names. |
required |
step
|
int
|
Grid step in milliarcseconds. |
10
|
rmin
|
float
|
Minimum grid separation in milliarcseconds. |
20
|
rmax
|
float
|
Maximum grid separation in milliarcseconds. |
400
|
diam
|
float
|
Primary-star diameter in milliarcseconds. |
0
|
obs
|
list of str or None
|
Observables to fit. Uses |
None
|
extra_error_cp
|
float
|
Additional closure-phase uncertainty in degrees, added in quadrature. |
0
|
err_scale
|
float
|
Multiplicative closure-phase error-bar scale. |
1
|
extra_error_v2
|
float
|
Additional squared-visibility uncertainty, added in quadrature. |
0
|
instruments
|
str or list of str
|
INSNAME(s) of the OIFITS tables to use. Uses all tables when omitted. |
None
|
doNotFit
|
list of str or None
|
Parameters excluded from fitting. Uses |
None
|
ncore
|
int
|
Unused; kept for compatibility (virgil vectorizes the grid). |
1
|
save
|
bool
|
Whether to save the detection map as a PDF. |
False
|
outputfile
|
str or None
|
Filename for the saved detection map. |
None
|
verbose
|
bool
|
Whether to print more information. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Best-fit parameters ( |
Source code in src/amical/analysis/legacy.py
177 178 179 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 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 260 261 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 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 | |
pymask_cr_limit(input_data, nsim=100, err_scale=1, extra_error_cp=0, ncore=1, cmax=500, nsep=60, ncrat=60, nth=30, smin=20, smax=250, cmin=1.0001, display=False)
Compute 3-sigma contrast limits versus separation, Pymask style (closure phases only; computed with virgil).
Pymask simulated nsim noise realizations; here the limit is computed
directly with the method of Absil et al. (2011) on a polar grid of nsep
separations and nth position angles. As in Pymask, the limit at each
separation is the one valid at every position angle (the brightest
companion flux ruled out everywhere).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
str
|
OIFITS file name. |
required |
nsim
|
int
|
Unused; kept for compatibility. |
100
|
err_scale
|
float
|
Multiplicative error-bar scale. |
1
|
extra_error_cp
|
float
|
Additional closure-phase uncertainty in degrees. |
0
|
ncore
|
int
|
Unused; kept for compatibility. |
1
|
cmax
|
float
|
Maximum contrast ratio. |
500
|
nsep
|
int
|
Number of separation samples. |
60
|
ncrat
|
int
|
Unused; kept for compatibility. |
60
|
nth
|
int
|
Number of position-angle samples. |
30
|
smin
|
float
|
Minimum separation in milliarcseconds. |
20
|
smax
|
float
|
Maximum separation in milliarcseconds. |
250
|
cmin
|
float
|
Minimum contrast ratio. |
1.0001
|
display
|
bool
|
Whether to display the contrast-limit plot. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Separations ( |
Source code in src/amical/analysis/legacy.py
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 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 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 | |
pymask_grid(input_data, ngrid=40, pa_prior=None, sep_prior=None, cr_prior=None, err_scale=1.0, extra_error_cp=0.0, ncore=1, verbose=False)
Compute a chi-square map of a binary model on a regular grid, Pymask style (closure phases only; computed with virgil).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
str
|
OIFITS file name. |
required |
ngrid
|
int
|
Number of grid points for each of position angle, separation and
contrast ratio ( |
40
|
pa_prior
|
list of float or None
|
Position-angle bounds in degrees. Defaults to |
None
|
sep_prior
|
list of float or None
|
Separation bounds in milliarcseconds. Defaults to |
None
|
cr_prior
|
list of float or None
|
Contrast-ratio bounds. Defaults to |
None
|
err_scale
|
float
|
Multiplicative error-bar scale. |
1.0
|
extra_error_cp
|
float
|
Additional closure-phase uncertainty in degrees. |
0.0
|
ncore
|
int
|
Unused; kept for compatibility. |
1
|
verbose
|
bool
|
Whether to print more information. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Source code in src/amical/analysis/legacy.py
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 | |
pymask_mcmc(input_data, initial_guess, niters=1000, pa_prior=None, sep_prior=None, cr_prior=None, err_scale=1, extra_error_cp=0, ncore=1, burn_in=500, walkers=100, display=True, verbose=True)
Sample the posterior of a binary model, Pymask style (closure phases only), with NUTS (numpyro and virgil).
The priors are uniform over sep_prior, pa_prior and cr_prior.
Pymask used emcee; the NUTS sampler needs no walkers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
str
|
OIFITS file name. |
required |
initial_guess
|
array_like
|
Initial separation (mas), position angle (deg) and contrast ratio. |
required |
niters
|
int
|
Number of samples after warm-up. |
1000
|
pa_prior
|
list of float or None
|
Position-angle bounds in degrees. Defaults to |
None
|
sep_prior
|
list of float or None
|
Separation bounds in milliarcseconds. Defaults to 0.5 to 2 times the initial separation. |
None
|
cr_prior
|
list of float or None
|
Contrast-ratio bounds. Defaults to 1 to 10 times the initial contrast ratio. |
None
|
err_scale
|
float
|
Multiplicative error-bar scale. |
1
|
extra_error_cp
|
float
|
Additional closure-phase uncertainty in degrees. |
0
|
ncore
|
int
|
Unused; kept for compatibility. |
1
|
burn_in
|
int
|
Number of warm-up steps. |
500
|
walkers
|
int
|
Unused; kept for compatibility. |
100
|
display
|
bool
|
Whether to plot the sample chains. |
True
|
verbose
|
bool
|
Whether to show a progress bar and print the fitted parameters. |
True
|
Returns:
| Type | Description |
|---|---|
dict
|
Best-fit binary parameters ( |
Source code in src/amical/analysis/legacy.py
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 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 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 | |