johanmazoyer / Asterix

https://asterix-hci.readthedocs.io/
2 stars 0 forks source link

Increasing pixel in pupil diameter breaks THD correction #153

Open johanmazoyer opened 1 year ago

johanmazoyer commented 1 year ago

We noted that if we increase the parameter diam_pup_in_pix from 100 (which was the order of values used up to end of 2022) to 256, this lead to a severe loss in performance on the testbed. We hypothesized that this was due to a slight change in the calculation in determination of which actuator should be used in the Matrix (what we call the "WhichInPup" array, measured by id_in_pupil_actuators function in Asterix/optics/deformable_mirror.py). The measurement of this array is using a threshold parameter MinimumSurfaceRatioInThePupil which measure the percentage of the actuator value inside of the pupil and reject them if they are too off pupil (below the MinimumSurfaceRatioInThePupil threshold). Changing the number of pixel in pupil lead to change of the "WhichInPup" that we think broke the correction.

@ivalaginja could you add picture of the resulting DH ?

Our tests shows that in both case the whichinpup did not change for DM1, all actuators are used in both case (see print of our codes reproduce at the end of the issue). Number of actuators WhichInPup on DM1 with pupil diameter to 100: (952,) Number of actuators WhichInPup on DM1 with pupil diameter to 256: (952,) This is probably due to

  1. The actuator in DM1 are already organized in a circular fashion
  2. Pupil size is slighly extended when out of the pupil plane

For DM3, 5 more actuators were added in the which in pup : Number of actuators WhichInPup on DM3 with pupil diameter to 100: (714,) Number of actuators WhichInPup on DM3 with pupil diameter to 256: (719,) Actuators added in WhichInPup on DM3 when going from 100 to 256 in pupil diameter: [609 804 837 870 972 979]

We note that none of the added actuators correspond to problematic actuators identified on DM3, which are the link couple (197, 888), the broken 769 and the link couple (841, 967). I am fairly sure that the numbering in which in pup correspond to the numbering we have been using for the actuators (to be checked next meeting).


import numpy as np
from astropy.io import fits

directory_wip = '/Users/jmazoyer/asterix_data/Model_local/'

# DM3
wip_dm3_prad50 = fits.getdata(directory_wip + 'WhichInPup_DM3_Nact1024_dimPP200_prad50_thres0.03.fits')
wip_dm3_prad128 = fits.getdata(directory_wip + 'WhichInPup_DM3_Nact1024_dimPP512_prad128_thres0.03.fits')

# DM1
wip_dm1_prad50 = fits.getdata(directory_wip + 'WhichInPup_DM1_Nact952_dimPP200_prad50_thres0.03.fits')
wip_dm1_prad128 = fits.getdata(directory_wip + 'WhichInPup_DM1_Nact952_dimPP512_prad128_thres0.03.fits')

print("Number of actuators WhichInPup on DM1 with pupil diameter to 100: ", wip_dm1_prad50.shape)
print("Number of actuators WhichInPup on DM1 with pupil diameter to 256: ", wip_dm1_prad128.shape)
print("")
print("Number of actuators WhichInPup on DM3 with pupil diameter to 100: ", wip_dm3_prad50.shape)
print("Number of actuators WhichInPup on DM3 with pupil diameter to 256: ", wip_dm3_prad128.shape)
print("")

for i in wip_dm3_prad50:
    if i in wip_dm3_prad128:
        wip_dm3_prad128 = np.delete(wip_dm3_prad128, np.where(wip_dm3_prad128 == i), axis=0)

print("Actuators added in WhichInPup on DM3 when going from 100 to 256 in pupil diameter: ", wip_dm3_prad128)
ivalaginja commented 1 year ago

I think the DM1 simply always uses all actuators because we are unsure about its distance to DM3 in the first place, and there are no major issues with any of the actuators on that DM so there is no risk of just leaving all of them unmasked.

Note how we were testing this with the FQPM. Below are testbed images of EFC DHs when matrices are computed with Asterix for each of the two numbers of pixels per pupil diameter.

Screenshot 2023-01-19 at 13 16 30
johanmazoyer commented 1 year ago

Actuators WhichInPup on DM3 for pupil diameter to 100 thres 0.03: [ 43 44 45 46 47 48 49 50 51 52 73 74 75 76 77 78 79 80 81 82 83 84 85 86 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 938 939 940 941 942 943 944 945 946 947 948 949 973 974 975 976 977 978]

Number of actuators WhichInPup on DM3 with pupil diameter to 100 thres 0.03: (714,) Number of actuators WhichInPup on DM3 with pupil diameter to 200 thres 0.03: (717,) Actuators that are in WhichInPup on DM3 with pupil diameter to 200 thres 0.03 but not in WhichInPup on DM3 with pupil diameter to 100 thres 0.03: 609 837 972 979

Actuators that are in WhichInPup on DM3 with pupil diameter to 100 thres 0.03 but not in WhichInPup on DM3 with pupil diameter to 200 thres 0.03: 382

Number of actuators WhichInPup on DM3 with pupil diameter to 100 thres 0.03: (714,) Number of actuators WhichInPup on DM3 with pupil diameter to 256 thres 0.03: (719,) Actuators that are in WhichInPup on DM3 with pupil diameter to 256 thres 0.03 but not in WhichInPup on DM3 with pupil diameter to 100 thres 0.03: 609 804 837 870 972 979

Actuators that are in WhichInPup on DM3 with pupil diameter to 100 thres 0.03 but not in WhichInPup on DM3 with pupil diameter to 256 thres 0.03: 382

Number of actuators WhichInPup on DM3 with pupil diameter to 200 thres 0.033: (714,) Actuators that are in WhichInPup on DM3 with pupil diameter to 200 thres 0.033 but not in WhichInPup on DM3 with pupil diameter to 100 thres 0.03: 609 837 979

Actuators that are in WhichInPup on DM3 with pupil diameter to 100 thres 0.03 but not in WhichInPup on DM3 with pupil diameter to 200 thres 0.033: 227 382 733

johanmazoyer commented 1 year ago

pup_init copy

johanmazoyer commented 1 year ago

The Original (worked for a long time)

which_in_pup_100pix_thresh003 copy

johanmazoyer commented 1 year ago

The one that broke it which_in_pup_256pix_thresh003 copy

johanmazoyer commented 1 year ago

With 200 same threshold (untested on THD2) : which_in_pup_200pix_thresh003 pdf copy

johanmazoyer commented 1 year ago

Increasing the threshold (currently working on THD2) which_in_pup_200pix_thresh0033 pdf copy 2

johanmazoyer commented 1 year ago

The one that breaks (pix 256 thresh 0.03) has actuator 609, 804, 837, 870, 972, 979 in addition to pix 100 thresh 0.03 The one that works (pix 200 thresh 0.033) has actuator 609 837 979 in addition to pix 100 thresh 0.03 Could it be a problem with 804, 870 or 972 ?