Changeset 38390 for trunk/psphot/src
- Timestamp:
- Jun 5, 2015, 12:44:18 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotSourceMatch.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotSourceMatch.c
r34795 r38390 700 700 701 701 702 psArray *psphotLinkSources (pmConfig *config, const pmFPAview *view, const char *filerule) 703 { 704 705 int num = psphotFileruleCount(config, filerule); 706 707 psArray *sourcesArrays = psArrayAlloc(num); 708 709 // loop over inputs find the maximum sequence number and save pointers to the arrays 710 int seqMax = -1; 711 for (int i = 0; i < num; i++) { 712 713 // find the currently selected readout 714 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest 715 psAssert (file, "missing file?"); 716 717 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 718 psAssert (readout, "missing readout?"); 719 720 pmDetections *detections = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.DETECTIONS"); 721 psAssert (detections, "missing detections?"); 722 psAssert (detections->allSources, "all sources not defined?"); 723 724 // allSources value won't change but should be careful 725 detections->allSources = psArraySort(detections->allSources, pmSourceSortBySeq); 726 727 sourcesArrays->data[i] = psMemIncrRefCounter(detections->allSources); 728 pmSource *lastSrc = detections->allSources->data[detections->allSources->n -1 ]; 729 int thisSeq = lastSrc->seq; 730 if (thisSeq > seqMax) { 731 seqMax = thisSeq; 732 } 733 } 734 735 if (seqMax < 0) { 736 psError (PSPHOT_ERR_UNKNOWN, true, "failed to find maximum sequence number\n"); 737 return NULL; 738 } 739 740 // allocate objects array 741 psArray *objects = psArrayAlloc(seqMax + 1); 742 // loop over inputs and create objects that reference all of the sources 743 for (int i = 0; i < num; i++) { 744 // sources for this input 745 psArray *sources = sourcesArrays->data[i]; 746 for (int j = 0; j < sources->n ; j++) { 747 pmSource *src = sources->data[j]; 748 // XXX This is no longer needed I think. I added it to work around something else. Check 749 src->imageID = i; 750 int seq = src->seq; 751 pmPhotObj *obj = objects->data[seq]; 752 if (!obj) { 753 // first source for this object 754 obj = objects->data[seq] = pmPhotObjAlloc(); 755 } 756 pmPhotObjAddSource(obj, src); 757 } 758 } 759 psFree(sourcesArrays); 760 761 return objects; 762 }
Note:
See TracChangeset
for help on using the changeset viewer.
