Changeset 41618
- Timestamp:
- May 26, 2021, 4:30:37 PM (5 years ago)
- Location:
- tags/ipp-ps1-20210510/psastro/src
- Files:
-
- 4 edited
-
Makefile.am (modified) (1 diff)
-
psastro.h (modified) (1 diff)
-
psastroLoadCrosstalk.c (modified) (8 diffs)
-
psastroMaskUpdates.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-ps1-20210510/psastro/src/Makefile.am
r38040 r41618 109 109 psastroMosaicSetMatch.c \ 110 110 psastroFindChip.c \ 111 psastroFindChipGPC.c \ 111 112 psastroZeroPoint.c \ 112 113 psastroDemoDump.c \ -
tags/ipp-ps1-20210510/psastro/src/psastro.h
r41500 r41618 184 184 bool psastroFPAtoChip (double *xChip, double *yChip, pmFPA *fpa, int nChip, double xFPA, double yFPA); 185 185 186 pmChip *psastroFindChipGPC (double *xChip, double *yChip, pmFPA *fpa, double xFPA, double yFPA); 187 bool psastroChipBoundsGPC (pmFPA *fpa); 188 pmChip *psastroCheckChip (double *xChip, double *yChip, pmFPA *fpa, int nChip, double xFPA, double yFPA); 189 bool psastroExtractFreeChipBoundsGPC(void); 190 186 191 //bool psastroMaskStats(pmConfig *config, psMetadata *stats); 187 192 -
tags/ipp-ps1-20210510/psastro/src/psastroLoadCrosstalk.c
r41597 r41618 12 12 13 13 # include "psastroInternal.h" 14 #include <time.h> 14 15 15 16 # define ESCAPE { \ … … 135 136 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 136 137 psTrace ("psastro.crosstalk", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 137 138 138 if (!cell->process || !cell->file_exists) { continue; } 139 139 … … 398 398 399 399 int crossChip = psMetadataLookupS32 (&status, crossItem->data.md, "CHIP.SRC"); 400 int crossCell = psMetadataLookupS32 (&status, crossItem->data.md, "CELL.SRC");401 int crossChipOffset = psMetadataLookupS32 (&status, crossItem->data.md, "CHIP.OFFSET");402 int crossCellOffset = psMetadataLookupS32 (&status, crossItem->data.md, "CELL.OFFSET");403 float crossMagOff = psMetadataLookupF32 (&status, crossItem->data.md, "CROSS.MAGDIFF");404 if (!status) {405 psWarning ("CROSSTALK.RULE entry is missing necessary entry");406 continue;407 }408 409 400 if (!(X == crossChip)) { 410 401 psTrace ("psastro.crosstalk",2,"Chip (%d%d) not a known crosstalk source.",X,Y); … … 412 403 } 413 404 405 int crossCell = psMetadataLookupS32 (&status, crossItem->data.md, "CELL.SRC"); 406 char *strChipOffset = psMetadataLookupStr (&status, crossItem->data.md, "CHIP.OFFSET"); 407 char *strCellOffset = psMetadataLookupStr (&status, crossItem->data.md, "CELL.OFFSET"); 408 char *strMagOffset = psMetadataLookupStr (&status, crossItem->data.md, "CROSS.MAGDIFF"); 409 410 //Parse the strings into individual entries 411 int crossChipOffset[40]; 412 int crossCellOffset[40]; 413 float crossMagOffset[40]; 414 415 int nrul = 0; 416 char *p = strtok (strChipOffset, "/"); 417 while (p != NULL) { 418 crossChipOffset[nrul++] = atoi(p); 419 p = strtok (NULL, "/"); 420 } 421 int nrul2 = 0; 422 char *p2 = strtok (strCellOffset, "/"); 423 while (p2 != NULL) { 424 crossCellOffset[nrul2++] = atoi(p2); 425 p2 = strtok (NULL, "/"); 426 } 427 int nrul3 = 0; 428 char *p3 = strtok (strMagOffset, "/"); 429 while (p3 != NULL) { 430 crossMagOffset[nrul3++] = atof(p3); 431 p3 = strtok (NULL, "/"); 432 } 433 434 if ((nrul != nrul2) | (nrul != nrul3)) { 435 psWarning ("CROSSTALK.RULE entry is not correctly formatted or incomplete"); 436 continue; 437 } 438 439 414 440 //the source star needs to be bright enough to produce a crosstalk feature on the target chip/cell that is above the refmag 415 float INSTR_CROSS_MAX_MAG = de->magRef - crossMagOff; 441 //float INSTR_CROSS_MAX_MAG = de->magRef - crossMagOff; 442 float INSTR_CROSS_MAX_MAG = de->magRef; 416 443 float CROSS_MAX_MAG = INSTR_CROSS_MAX_MAG + MagOffset; 417 444 … … 423 450 for (int i = 0; i < calstars->n; i++) { 424 451 pmAstromObj *cal = calstars->data[i]; 425 //kick out stars too faint to produce crosstalk with this rule 426 if (cal->Mag > INSTR_CROSS_MAX_MAG) { continue; } 452 //kick out stars too faint to produce crosstalk with any rule 453 //if (cal->Mag > INSTR_CROSS_MAX_MAG) { continue; } 454 if (cal->Mag > (INSTR_CROSS_MAX_MAG-11.)) { continue; } 427 455 428 456 // Identify which cell holds the star … … 454 482 } 455 483 456 int chipTarget = chipNum + crossChipOffset ; 457 int cellTarget = cellNum + crossCellOffset ; 458 459 // Convert target cell coordinates to target chip coordinates 460 psString targetChipName = NULL; 461 if(chipTarget > 8) { 462 psStringAppend(&targetChipName,"XY%2d",chipTarget); 463 } 464 if(chipTarget < 8) { 465 psStringAppend(&targetChipName,"XY0%1d",chipTarget); 466 } 467 psString targetCellName = NULL; 468 if(cellTarget > 8) { 469 psStringAppend(&targetCellName,"xy%2d",cellTarget); 470 } 471 if(cellTarget < 8) { 472 psStringAppend(&targetCellName,"xy0%1d",cellTarget); 473 } 474 475 psTrace ("psastro.crosstalk",2,"CTsource from DETEC @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%2dxy%2d@%f,%f [%s %s]", 484 for (int k = 0 ; k < nrul; k++) { 485 int chipTarget = chipNum + crossChipOffset[k] ; 486 int cellTarget = cellNum + crossCellOffset[k] ; 487 if (cal->Mag > (INSTR_CROSS_MAX_MAG-crossMagOffset[k])) { continue; } 488 489 // Convert target cell coordinates to target chip coordinates 490 psString targetChipName = NULL; 491 if(chipTarget > 8) { 492 psStringAppend(&targetChipName,"XY%2d",chipTarget); 493 } 494 if(chipTarget < 8) { 495 psStringAppend(&targetChipName,"XY0%1d",chipTarget); 496 } 497 psString targetCellName = NULL; 498 if(cellTarget > 8) { 499 psStringAppend(&targetCellName,"xy%2d",cellTarget); 500 } 501 if(cellTarget < 8) { 502 psStringAppend(&targetCellName,"xy0%1d",cellTarget); 503 } 504 505 psTrace ("psastro.crosstalk",2,"CTsource from DETEC @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%2dxy%2d@%f,%f [%s %s]", 476 506 X,Y,U,V,x_cell,y_cell,chipTarget,cellTarget,x_t_cell,y_t_cell, 477 507 targetChipName,targetCellName); 478 508 479 pmCell *CTtargetCell = getCellByName (CTsourceChip,targetCellName);480 if (!CTtargetCell) continue;481 482 pmChipCoordsForCell(&x_t_chip,&y_t_chip,CTtargetCell,x_t_cell,y_t_cell);483 484 psTrace ("psastro.crosstalk",2,"CTsource from DETEC @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%2dxy%2d@%f,%f ChipLoc: (%f,%f)",509 pmCell *CTtargetCell = getCellByName (CTsourceChip,targetCellName); 510 if (!CTtargetCell) continue; 511 512 pmChipCoordsForCell(&x_t_chip,&y_t_chip,CTtargetCell,x_t_cell,y_t_cell); 513 514 psTrace ("psastro.crosstalk",2,"CTsource from DETEC @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%2dxy%2d@%f,%f ChipLoc: (%f,%f)", 485 515 X,Y,U,V,x_cell,y_cell,chipTarget,cellTarget,x_t_cell,y_t_cell,x_t_chip,y_t_chip); 486 516 487 // Hunt down the readout for the target, and save the chip position and magnitude of source star. 488 pmChip *targetChip = getChipByName(fpa,targetChipName); 489 if (!targetChip) continue; 490 if (!targetChip->cells) continue; 491 if (!targetChip->cells->n) continue; 492 493 pmCell *targetCell = targetChip->cells->data[0]; 494 if (!targetCell) continue; 495 if (!targetCell->readouts) continue; 496 if (!targetCell->readouts->n) continue; 497 pmReadout *targetReadout = targetCell->readouts->data[0]; 498 if (!targetReadout) continue; 499 500 //check if the crosstalk is above the target chip background level 501 pmDetEff *tarde = psMetadataLookupPtr(NULL, targetReadout->analysis, PM_DETEFF_ANALYSIS); // Detection efficiency 502 if (isnan(tarde->magRef)) { continue; } 503 504 float TARGET_CROSS_MAX_MAG = tarde->magRef-crossMagOff; 505 506 if (cal->Mag > TARGET_CROSS_MAX_MAG) { continue; } 507 508 pmAstromObj *crosstalk = pmAstromObjAlloc(); 517 // Hunt down the readout for the target, and save the chip position and magnitude of source star. 518 pmChip *targetChip = getChipByName(fpa,targetChipName); 519 if (!targetChip) continue; 520 if (!targetChip->cells) continue; 521 if (!targetChip->cells->n) continue; 522 523 pmCell *targetCell = targetChip->cells->data[0]; 524 if (!targetCell) continue; 525 if (!targetCell->readouts) continue; 526 if (!targetCell->readouts->n) continue; 527 pmReadout *targetReadout = targetCell->readouts->data[0]; 528 if (!targetReadout) continue; 529 530 //check again if the crosstalk is above the target chip background level 531 pmDetEff *tarde = psMetadataLookupPtr(NULL, targetReadout->analysis, PM_DETEFF_ANALYSIS); // Detection efficiency 532 if (isnan(tarde->magRef)) { continue; } 533 534 float TARGET_CROSS_MAX_MAG = tarde->magRef-crossMagOffset[k]; 535 if (cal->Mag > TARGET_CROSS_MAX_MAG) { continue; } 536 537 pmAstromObj *crosstalk = pmAstromObjAlloc(); 509 538 510 crosstalk->Mag = cal->Mag;511 crosstalk->chip->x = x_t_chip;512 crosstalk->chip->y = y_t_chip;513 514 psArray *crosstalks = psMetadataLookupPtr (&status, targetReadout->analysis, "PSASTRO.CROSSTALKS");515 if (crosstalks == NULL) {516 crosstalks = psArrayAllocEmpty(100);517 if (!psMetadataAdd(targetReadout->analysis,PS_LIST_TAIL,"PSASTRO.CROSSTALKS", PS_DATA_ARRAY, "crosstalk locations", crosstalks)) {518 psError(PSASTRO_ERR_CONFIG, false, "failure to add crosstalks to readout");519 goto escape;520 }521 psFree(crosstalks);522 }523 psArrayAdd(crosstalks,100,crosstalk);539 crosstalk->Mag = cal->Mag; 540 crosstalk->chip->x = x_t_chip; 541 crosstalk->chip->y = y_t_chip; 542 543 psArray *crosstalks = psMetadataLookupPtr (&status, targetReadout->analysis, "PSASTRO.CROSSTALKS"); 544 if (crosstalks == NULL) { 545 crosstalks = psArrayAllocEmpty(100); 546 if (!psMetadataAdd(targetReadout->analysis,PS_LIST_TAIL,"PSASTRO.CROSSTALKS", PS_DATA_ARRAY, "crosstalk locations", crosstalks)) { 547 psError(PSASTRO_ERR_CONFIG, false, "failure to add crosstalks to readout"); 548 goto escape; 549 } 550 psFree(crosstalks); 551 } 552 psArrayAdd(crosstalks,100,crosstalk); 524 553 525 psFree(targetChipName);526 psFree(targetCellName);527 psFree(crosstalk);528 529 // Determine if we need to add a spike mask.530 // TdB20210304: This should not be relevant for faint crosstalk rules. Do this rather ad hoc right now by placing a limit at 8 mags of difference531 if( crossMagOff> 8.) { continue; }532 if (cal->Mag < SPIKE_MAX_MAG) {533 int Xt = X;534 int Yt = Y;535 int Vt = V;554 psFree(targetChipName); 555 psFree(targetCellName); 556 psFree(crosstalk); 557 558 // Determine if we need to add a spike mask. 559 // TdB20210304: This should not be relevant for faint crosstalk rules. Do this rather ad hoc right now by placing a limit at 8 mags of difference 560 if( crossMagOffset[k] > 8.) { continue; } 561 if (cal->Mag < SPIKE_MAX_MAG) { 562 int Xt = X; 563 int Yt = Y; 564 int Vt = V; 536 565 537 for (int Ut = 0; Ut < 8; Ut++) {538 psString targetChipName = NULL;539 psStringAppend(&targetChipName,"XY%d%d",Xt,Yt);540 psString targetCellName = NULL;541 psStringAppend(&targetCellName,"xy%d%d",Ut,Vt);542 543 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f [%s %s]",566 for (int Ut = 0; Ut < 8; Ut++) { 567 psString targetChipName = NULL; 568 psStringAppend(&targetChipName,"XY%d%d",Xt,Yt); 569 psString targetCellName = NULL; 570 psStringAppend(&targetCellName,"xy%d%d",Ut,Vt); 571 572 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f [%s %s]", 544 573 X,Y,U,V,x_cell,y_cell,Xt,Yt,Ut,Vt,x_t_cell,y_t_cell, 545 574 targetChipName,targetCellName); 546 575 547 pmCell *CTtargetCell = getCellByName (CTsourceChip,targetCellName);548 if (!CTtargetCell) continue;549 550 pmChipCoordsForCell(&x_t_chip,&y_t_chip,CTtargetCell,x_t_cell,y_t_cell);551 552 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f ChipLoc: (%f,%f)",576 pmCell *CTtargetCell = getCellByName (CTsourceChip,targetCellName); 577 if (!CTtargetCell) continue; 578 579 pmChipCoordsForCell(&x_t_chip,&y_t_chip,CTtargetCell,x_t_cell,y_t_cell); 580 581 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f ChipLoc: (%f,%f)", 553 582 X,Y,U,V,x_cell,y_cell,Xt,Yt,Ut,Vt,x_t_cell,y_t_cell,x_t_chip,y_t_chip); 554 583 555 // Hunt down the readout for the target, and save the chip position and magnitude of source star.556 pmChip *targetChip = getChipByName(fpa,targetChipName);557 if (!targetChip) continue;558 if (!targetChip->cells) continue;559 if (!targetChip->cells->n) continue;584 // Hunt down the readout for the target, and save the chip position and magnitude of source star. 585 pmChip *targetChip = getChipByName(fpa,targetChipName); 586 if (!targetChip) continue; 587 if (!targetChip->cells) continue; 588 if (!targetChip->cells->n) continue; 560 589 561 pmCell *targetCell = targetChip->cells->data[0]; 562 if (!targetCell) continue; 563 if (!targetCell->readouts) continue; 564 if (!targetCell->readouts->n) continue; 565 pmReadout *targetReadout = targetCell->readouts->data[0]; 566 if (!targetReadout) continue; 567 568 pmAstromObj *crosstalk = pmAstromObjAlloc(); 569 570 crosstalk->Mag = cal->Mag; 571 crosstalk->chip->x = x_t_chip; 572 crosstalk->chip->y = y_t_chip; 573 574 psArray *crosstalks = psMetadataLookupPtr (&status, targetReadout->analysis, "PSASTRO.CROSSTALKS.SPIKES"); 575 if (crosstalks == NULL) { 576 crosstalks = psArrayAllocEmpty(100); 577 if (!psMetadataAdd(targetReadout->analysis,PS_LIST_TAIL,"PSASTRO.CROSSTALKS.SPIKES", PS_DATA_ARRAY, "crosstalk locations", crosstalks)) { 578 psError(PSASTRO_ERR_CONFIG, false, "failure to add crosstalks to readout"); 579 goto escape; 580 } 581 psFree(crosstalks); 582 } 583 psArrayAdd(crosstalks,100,crosstalk); 584 585 psFree(targetChipName); 586 psFree(targetCellName); 587 psFree(crosstalk); 588 } 589 } // End satspike crosstalks 590 pmCell *targetCell = targetChip->cells->data[0]; 591 if (!targetCell) continue; 592 if (!targetCell->readouts) continue; 593 if (!targetCell->readouts->n) continue; 594 pmReadout *targetReadout = targetCell->readouts->data[0]; 595 if (!targetReadout) continue; 596 597 pmAstromObj *crosstalk = pmAstromObjAlloc(); 598 599 crosstalk->Mag = cal->Mag; 600 crosstalk->chip->x = x_t_chip; 601 crosstalk->chip->y = y_t_chip; 602 603 psArray *crosstalks = psMetadataLookupPtr (&status, targetReadout->analysis, "PSASTRO.CROSSTALKS.SPIKES"); 604 if (crosstalks == NULL) { 605 crosstalks = psArrayAllocEmpty(100); 606 if (!psMetadataAdd(targetReadout->analysis,PS_LIST_TAIL,"PSASTRO.CROSSTALKS.SPIKES", PS_DATA_ARRAY, "crosstalk locations", crosstalks)) { 607 psError(PSASTRO_ERR_CONFIG, false, "failure to add crosstalks to readout"); 608 goto escape; 609 } 610 psFree(crosstalks); 611 } 612 psArrayAdd(crosstalks,100,crosstalk); 613 614 psFree(targetChipName); 615 psFree(targetCellName); 616 psFree(crosstalk); 617 } 618 } // End satspike crosstalks 619 } //end of rules block 590 620 } // End calMags 591 621 592 593 622 // We also want to use the refstars to check for crosstalk. In particular, the detections 594 623 // do not do well for bright stars, and saturated detections will underestimate the size of the crostalk … … 602 631 pmAstromObj *ref = refstars->data[i]; 603 632 604 if (ref->Mag > CROSS_MAX_MAG ) { continue; }633 if (ref->Mag > CROSS_MAX_MAG-11.) { continue; } 605 634 606 635 // Identify which cell holds the star … … 633 662 } 634 663 635 int chipTarget = chipNum + crossChipOffset ; 636 int cellTarget = cellNum + crossCellOffset ; 637 638 // Convert target cell coordinates to target chip coordinates 639 psString targetChipName = NULL; 640 if(chipTarget > 8) { 641 psStringAppend(&targetChipName,"XY%2d",chipTarget); 642 } 643 if(chipTarget < 8) { 644 psStringAppend(&targetChipName,"XY0%1d",chipTarget); 645 } 646 psString targetCellName = NULL; 647 if(cellTarget > 8) { 648 psStringAppend(&targetCellName,"xy%2d",cellTarget); 649 } 650 if(cellTarget < 8) { 651 psStringAppend(&targetCellName,"xy0%1d",cellTarget); 652 } 653 654 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%2dxy%2d@%f,%f [%s %s]", 664 for (int k = 0 ; k < nrul; k++) { 665 int chipTarget = chipNum + crossChipOffset[k] ; 666 int cellTarget = cellNum + crossCellOffset[k] ; 667 if (ref->Mag > (CROSS_MAX_MAG-crossMagOffset[k])) { continue; } 668 669 // Convert target cell coordinates to target chip coordinates 670 psString targetChipName = NULL; 671 if(chipTarget > 8) { 672 psStringAppend(&targetChipName,"XY%2d",chipTarget); 673 } 674 if(chipTarget < 8) { 675 psStringAppend(&targetChipName,"XY0%1d",chipTarget); 676 } 677 psString targetCellName = NULL; 678 if(cellTarget > 8) { 679 psStringAppend(&targetCellName,"xy%2d",cellTarget); 680 } 681 if(cellTarget < 8) { 682 psStringAppend(&targetCellName,"xy0%1d",cellTarget); 683 } 684 685 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%2dxy%2d@%f,%f [%s %s]", 655 686 X,Y,U,V,x_cell,y_cell,chipTarget,cellTarget,x_t_cell,y_t_cell, 656 687 targetChipName,targetCellName); 657 688 658 pmCell *CTtargetCell = getCellByName (CTsourceChip,targetCellName);659 if (!CTtargetCell) continue;660 661 pmChipCoordsForCell(&x_t_chip,&y_t_chip,CTtargetCell,x_t_cell,y_t_cell);662 663 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%2dxy%2d@%f,%f ChipLoc: (%f,%f)",689 pmCell *CTtargetCell = getCellByName (CTsourceChip,targetCellName); 690 if (!CTtargetCell) continue; 691 692 pmChipCoordsForCell(&x_t_chip,&y_t_chip,CTtargetCell,x_t_cell,y_t_cell); 693 694 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%2dxy%2d@%f,%f ChipLoc: (%f,%f)", 664 695 X,Y,U,V,x_cell,y_cell,chipTarget,cellTarget,x_t_cell,y_t_cell,x_t_chip,y_t_chip); 665 696 666 // Hunt down the readout for the target, and save the chip position and magnitude of source star.667 pmChip *targetChip = getChipByName(fpa,targetChipName);668 if (!targetChip) continue;669 if (!targetChip->cells) continue;670 if (!targetChip->cells->n) continue;671 672 pmCell *targetCell = targetChip->cells->data[0];673 if (!targetCell) continue;674 if (!targetCell->readouts) continue;675 if (!targetCell->readouts->n) continue;676 pmReadout *targetReadout = targetCell->readouts->data[0];677 if (!targetReadout) continue;678 679 //check if the crosstalk is above the target chip background level680 pmDetEff *tarde = psMetadataLookupPtr(NULL, targetReadout->analysis, PM_DETEFF_ANALYSIS); // Detection efficiency681 if (isnan(tarde->magRef)) { continue; }682 683 float TARGET_CROSS_MAX_MAG = tarde->magRef-crossMagOff+ MagOffset;684 if (ref->Mag > TARGET_CROSS_MAX_MAG) { continue; }685 686 pmAstromObj *crosstalk = pmAstromObjAlloc();697 // Hunt down the readout for the target, and save the chip position and magnitude of source star. 698 pmChip *targetChip = getChipByName(fpa,targetChipName); 699 if (!targetChip) continue; 700 if (!targetChip->cells) continue; 701 if (!targetChip->cells->n) continue; 702 703 pmCell *targetCell = targetChip->cells->data[0]; 704 if (!targetCell) continue; 705 if (!targetCell->readouts) continue; 706 if (!targetCell->readouts->n) continue; 707 pmReadout *targetReadout = targetCell->readouts->data[0]; 708 if (!targetReadout) continue; 709 710 //check if the crosstalk is above the target chip background level 711 pmDetEff *tarde = psMetadataLookupPtr(NULL, targetReadout->analysis, PM_DETEFF_ANALYSIS); // Detection efficiency 712 if (isnan(tarde->magRef)) { continue; } 713 714 float TARGET_CROSS_MAX_MAG = tarde->magRef-crossMagOffset[k] + MagOffset; 715 if (ref->Mag > TARGET_CROSS_MAX_MAG) { continue; } 716 717 pmAstromObj *crosstalk = pmAstromObjAlloc(); 687 718 688 crosstalk->Mag = ref->Mag - MagOffset;689 crosstalk->chip->x = x_t_chip;690 crosstalk->chip->y = y_t_chip;691 692 psArray *crosstalks = psMetadataLookupPtr (&status, targetReadout->analysis, "PSASTRO.CROSSTALKS");693 if (crosstalks == NULL) {694 crosstalks = psArrayAllocEmpty(100);695 if (!psMetadataAdd(targetReadout->analysis,PS_LIST_TAIL,"PSASTRO.CROSSTALKS", PS_DATA_ARRAY, "crosstalk locations", crosstalks)) {696 psError(PSASTRO_ERR_CONFIG, false, "failure to add crosstalks to readout");697 goto escape;698 }699 psFree(crosstalks);700 }701 psArrayAdd(crosstalks,100,crosstalk);719 crosstalk->Mag = ref->Mag - MagOffset; 720 crosstalk->chip->x = x_t_chip; 721 crosstalk->chip->y = y_t_chip; 722 723 psArray *crosstalks = psMetadataLookupPtr (&status, targetReadout->analysis, "PSASTRO.CROSSTALKS"); 724 if (crosstalks == NULL) { 725 crosstalks = psArrayAllocEmpty(100); 726 if (!psMetadataAdd(targetReadout->analysis,PS_LIST_TAIL,"PSASTRO.CROSSTALKS", PS_DATA_ARRAY, "crosstalk locations", crosstalks)) { 727 psError(PSASTRO_ERR_CONFIG, false, "failure to add crosstalks to readout"); 728 goto escape; 729 } 730 psFree(crosstalks); 731 } 732 psArrayAdd(crosstalks,100,crosstalk); 702 733 703 psFree(targetChipName);704 psFree(targetCellName);705 psFree(crosstalk);706 707 // Determine if we need to add a spike mask.708 // TdB20210304: This should not be relevant for faint crosstalk rules. Do this rather ad hoc right now by placing a limit at 8 mags of difference709 if( crossMagOff> 8.) { continue; }710 if (ref->Mag < SPIKE_MAX_MAG) {711 int Xt = X;712 int Yt = Y;713 int Vt = V;734 psFree(targetChipName); 735 psFree(targetCellName); 736 psFree(crosstalk); 737 738 // Determine if we need to add a spike mask. 739 // TdB20210304: This should not be relevant for faint crosstalk rules. Do this rather ad hoc right now by placing a limit at 8 mags of difference 740 if( crossMagOffset[k] > 8.) { continue; } 741 if (ref->Mag < SPIKE_MAX_MAG) { 742 int Xt = X; 743 int Yt = Y; 744 int Vt = V; 714 745 715 for (int Ut = 0; Ut < 8; Ut++) {716 psString targetChipName = NULL;717 psStringAppend(&targetChipName,"XY%d%d",Xt,Yt);718 psString targetCellName = NULL;719 psStringAppend(&targetCellName,"xy%d%d",Ut,Vt);720 721 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f [%s %s]",746 for (int Ut = 0; Ut < 8; Ut++) { 747 psString targetChipName = NULL; 748 psStringAppend(&targetChipName,"XY%d%d",Xt,Yt); 749 psString targetCellName = NULL; 750 psStringAppend(&targetCellName,"xy%d%d",Ut,Vt); 751 752 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f [%s %s]", 722 753 X,Y,U,V,x_cell,y_cell,Xt,Yt,Ut,Vt,x_t_cell,y_t_cell, 723 754 targetChipName,targetCellName); 724 755 725 pmCell *CTtargetCell = getCellByName (CTsourceChip,targetCellName);726 if (!CTtargetCell) continue;727 728 pmChipCoordsForCell(&x_t_chip,&y_t_chip,CTtargetCell,x_t_cell,y_t_cell);729 730 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f ChipLoc: (%f,%f)",756 pmCell *CTtargetCell = getCellByName (CTsourceChip,targetCellName); 757 if (!CTtargetCell) continue; 758 759 pmChipCoordsForCell(&x_t_chip,&y_t_chip,CTtargetCell,x_t_cell,y_t_cell); 760 761 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f ChipLoc: (%f,%f)", 731 762 X,Y,U,V,x_cell,y_cell,Xt,Yt,Ut,Vt,x_t_cell,y_t_cell,x_t_chip,y_t_chip); 732 763 733 // Hunt down the readout for the target, and save the chip position and magnitude of source star.734 pmChip *targetChip = getChipByName(fpa,targetChipName);735 if (!targetChip) continue;736 if (!targetChip->cells) continue;737 if (!targetChip->cells->n) continue;764 // Hunt down the readout for the target, and save the chip position and magnitude of source star. 765 pmChip *targetChip = getChipByName(fpa,targetChipName); 766 if (!targetChip) continue; 767 if (!targetChip->cells) continue; 768 if (!targetChip->cells->n) continue; 738 769 739 pmCell *targetCell = targetChip->cells->data[0]; 740 if (!targetCell) continue; 741 if (!targetCell->readouts) continue; 742 if (!targetCell->readouts->n) continue; 743 pmReadout *targetReadout = targetCell->readouts->data[0]; 744 if (!targetReadout) continue; 745 746 pmAstromObj *crosstalk = pmAstromObjAlloc(); 747 748 crosstalk->Mag = ref->Mag - MagOffset; 749 crosstalk->chip->x = x_t_chip; 750 crosstalk->chip->y = y_t_chip; 751 752 psArray *crosstalks = psMetadataLookupPtr (&status, targetReadout->analysis, "PSASTRO.CROSSTALKS.SPIKES"); 753 if (crosstalks == NULL) { 754 crosstalks = psArrayAllocEmpty(100); 755 if (!psMetadataAdd(targetReadout->analysis,PS_LIST_TAIL,"PSASTRO.CROSSTALKS.SPIKES", PS_DATA_ARRAY, "crosstalk locations", crosstalks)) { 756 psError(PSASTRO_ERR_CONFIG, false, "failure to add crosstalks to readout"); 757 goto escape; 758 } 759 psFree(crosstalks); 760 } 761 psArrayAdd(crosstalks,100,crosstalk); 762 763 psFree(targetChipName); 764 psFree(targetCellName); 765 psFree(crosstalk); 766 } 767 } // End satspike crosstalks 770 pmCell *targetCell = targetChip->cells->data[0]; 771 if (!targetCell) continue; 772 if (!targetCell->readouts) continue; 773 if (!targetCell->readouts->n) continue; 774 pmReadout *targetReadout = targetCell->readouts->data[0]; 775 if (!targetReadout) continue; 776 777 pmAstromObj *crosstalk = pmAstromObjAlloc(); 778 779 crosstalk->Mag = ref->Mag - MagOffset; 780 crosstalk->chip->x = x_t_chip; 781 crosstalk->chip->y = y_t_chip; 782 783 psArray *crosstalks = psMetadataLookupPtr (&status, targetReadout->analysis, "PSASTRO.CROSSTALKS.SPIKES"); 784 if (crosstalks == NULL) { 785 crosstalks = psArrayAllocEmpty(100); 786 if (!psMetadataAdd(targetReadout->analysis,PS_LIST_TAIL,"PSASTRO.CROSSTALKS.SPIKES", PS_DATA_ARRAY, "crosstalk locations", crosstalks)) { 787 psError(PSASTRO_ERR_CONFIG, false, "failure to add crosstalks to readout"); 788 goto escape; 789 } 790 psFree(crosstalks); 791 } 792 psArrayAdd(crosstalks,100,crosstalk); 793 794 psFree(targetChipName); 795 psFree(targetCellName); 796 psFree(crosstalk); 797 } 798 } // End satspike crosstalks 799 } // End rules block 768 800 } // End refMags 769 770 801 } 771 802 } -
tags/ipp-ps1-20210510/psastro/src/psastroMaskUpdates.c
r41551 r41618 127 127 } 128 128 psLogMsg ("psastro", PS_LOG_INFO, "generating a bright-star mask"); 129 129 130 130 bool REFSTAR_MASK_BLEED = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_BLEED"); 131 131 bool REFSTAR_MASK_BLEED_ORIENTATION_X = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_BLEED_ORIENTATION_X");
Note:
See TracChangeset
for help on using the changeset viewer.
