IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 25, 2009, 2:00:56 PM (17 years ago)
Author:
eugene
Message:

merging changes from head

Location:
branches/eam_branches/20090522
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090522

  • branches/eam_branches/20090522/psModules

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/20090522/psModules/src/objects/Makefile.am

    r23990 r24557  
    3838        pmSourceIO_PS1_CAL_0.c \
    3939        pmSourceIO_CMF_PS1_V1.c \
     40        pmSourceIO_CMF_PS1_V2.c \
    4041        pmSourceIO_MatchedRefs.c \
    4142        pmSourcePlots.c \
  • branches/eam_branches/20090522/psModules/src/objects/pmFootprintArraysMerge.c

    r20937 r24557  
    2828 */
    2929psArray *pmFootprintArraysMerge(const psArray *footprints1, // one set of footprints
    30                                 const psArray *footprints2, // the other set
    31                                 const int includePeaks) { // which peaks to set? 0x1 => footprints1, 0x2 => 2
    32     assert (footprints1->n == 0 || pmFootprintTest(footprints1->data[0]));
    33     assert (footprints2->n == 0 || pmFootprintTest(footprints2->data[0]));
     30                                const psArray *footprints2, // the other set
     31                                const int includePeaks // which peaks to set? 0x1 => footprints1, 0x2 => 2
     32    )
     33{
     34    if (!footprints1 && !footprints2) {
     35        // No footprints in merged array
     36        return psArrayAllocEmpty(0);
     37    }
    3438
    35     if (footprints1->n == 0 || footprints2->n == 0) {           // nothing to do but put copies on merged
    36         const psArray *old = (footprints1->n == 0) ? footprints2 : footprints1;
     39    assert(!footprints1 || footprints1->n == 0 || pmFootprintTest(footprints1->data[0]));
     40    assert(!footprints2 || footprints2->n == 0 || pmFootprintTest(footprints2->data[0]));
    3741
    38         psArray *merged = psArrayAllocEmpty(old->n);
    39         for (int i = 0; i < old->n; i++) {
    40             psArrayAdd(merged, 1, old->data[i]);
    41         }
    42        
    43         return merged;
     42    if (!footprints1 || footprints1->n == 0 || !footprints2 || footprints2->n == 0) {
     43        // nothing to do but put copies on merged
     44        const psArray *old = (!footprints1 || footprints1->n == 0) ? footprints2 : footprints1;
     45
     46        psArray *merged = psArrayAllocEmpty(old->n);
     47        for (int i = 0; i < old->n; i++) {
     48            psArrayAdd(merged, 1, old->data[i]);
     49        }
     50
     51        return merged;
    4452    }
    4553    /*
     
    4856     */
    4957    {
    50         pmFootprint *fp1 = footprints1->data[0];
    51         pmFootprint *fp2 = footprints2->data[0];
    52         if (fp1->region.x0 != fp2->region.x0 ||
    53             fp1->region.x1 != fp2->region.x1 ||
    54             fp1->region.y0 != fp2->region.y0 ||
    55             fp1->region.y1 != fp2->region.y1) {
    56             psError(PS_ERR_BAD_PARAMETER_SIZE, true,
    57                     "The two pmFootprint arrays correspnond to different-sized regions");
    58             return NULL;
    59         }
     58        pmFootprint *fp1 = footprints1->data[0];
     59        pmFootprint *fp2 = footprints2->data[0];
     60        if (fp1->region.x0 != fp2->region.x0 ||
     61            fp1->region.x1 != fp2->region.x1 ||
     62            fp1->region.y0 != fp2->region.y0 ||
     63            fp1->region.y1 != fp2->region.y1) {
     64            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     65                    "The two pmFootprint arrays correspnond to different-sized regions");
     66            return NULL;
     67        }
    6068    }
    6169    /*
     
    7280     * Now assign the peaks appropriately.  We could do this more efficiently
    7381     * using idImage (which we just freed), but this is easy and probably fast enough
    74      */ 
     82     */
    7583    if (includePeaks & 0x1) {
    76         psArray *peaks = pmFootprintArrayToPeaks(footprints1);
    77         pmFootprintsAssignPeaks(merged, peaks);
    78         psFree(peaks);
     84        psArray *peaks = pmFootprintArrayToPeaks(footprints1);
     85        pmFootprintsAssignPeaks(merged, peaks);
     86        psFree(peaks);
    7987    }
    8088
    8189    if (includePeaks & 0x2) {
    82         psArray *peaks = pmFootprintArrayToPeaks(footprints2);
    83         pmFootprintsAssignPeaks(merged, peaks);
    84         psFree(peaks);
     90        psArray *peaks = pmFootprintArrayToPeaks(footprints2);
     91        pmFootprintsAssignPeaks(merged, peaks);
     92        psFree(peaks);
    8593    }
    86    
     94
    8795    return merged;
    8896}
  • branches/eam_branches/20090522/psModules/src/objects/pmMoments.c

    r23487 r24557  
    5151    tmp->Sky = 0.0;
    5252    tmp->nPixels = 0;
     53    tmp->SN = 0;
    5354
    5455    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
  • branches/eam_branches/20090522/psModules/src/objects/pmSource.c

    r24529 r24557  
    480480
    481481        if (!psVectorStats (stats, tmpSx, NULL, NULL, 0)) {
    482             psError(PS_ERR_UNKNOWN, false, "failed to measure Sx stats");
     482            psError(PS_ERR_UNKNOWN, false, "failed to measure Sx stats");
    483483            return (emptyClump);
    484         }
     484        }
    485485        psfClump.X  = stats->clippedMean;
    486486        psfClump.dX = stats->clippedStdev;
    487487
    488488        if (!psVectorStats (stats, tmpSy, NULL, NULL, 0)) {
    489             psError(PS_ERR_UNKNOWN, false, "failed to measure Sy stats");
     489            psError(PS_ERR_UNKNOWN, false, "failed to measure Sy stats");
    490490            return (emptyClump);
    491         }
     491        }
    492492        psfClump.Y  = stats->clippedMean;
    493493        psfClump.dY = stats->clippedStdev;
     
    548548        pmSource *source = (pmSource *) sources->data[i];
    549549
    550         // psf clumps are found for image subregions:
    551         // skip sources not in this region
     550        // psf clumps are found for image subregions:
     551        // skip sources not in this region
    552552        if (source->peak->x <  region->x0) continue;
    553553        if (source->peak->x >= region->x1) continue;
    554554        if (source->peak->y <  region->y0) continue;
    555         if (source->peak->y >= region->y1) continue;
    556 
    557         // should be set by pmSourceAlloc
     555        if (source->peak->y >= region->y1) continue;
     556
     557        // should be set by pmSourceAlloc
    558558        psAssert (source->type == PM_SOURCE_TYPE_UNKNOWN, "source type was not init-ed?");
    559559
     
    561561        if (!source->moments) {
    562562            source->type = PM_SOURCE_TYPE_STAR;
    563             psAssert (source->mode & noMoments, "why is this source missing moments?");
     563            psAssert (source->mode & noMoments, "why is this source missing moments?");
    564564            Nstar++;
    565565            continue;
     
    596596        }
    597597
    598         // likely defect (too small to be stellar) (push out to 3 sigma)
    599         // low S/N objects which are small are probably stellar
    600         // only set candidate defects if
    601         // XXX these limits are quite arbitrary
    602         if ((sigX < 0.05) || (sigY < 0.05)) {
    603             source->type = PM_SOURCE_TYPE_DEFECT;
    604             source->mode |= PM_SOURCE_MODE_DEFECT;
    605             Ncr ++;
    606             continue;
    607         }
    608 
    609         // likely unsaturated extended source (too large to be stellar)
    610         if ((sigX > (clump.X + 3*clump.dX)) || (sigY > (clump.Y + 3*clump.dY))) {
    611             source->type = PM_SOURCE_TYPE_EXTENDED;
    612             Next ++;
    613             continue;
    614         }
    615 
    616         // the rest are probable stellar objects
    617         starsn_moments->data.F32[starsn_moments->n] = source->moments->SN;
    618         starsn_moments->n ++;
    619         starsn_peaks->data.F32[starsn_peaks->n] = source->peak->SN;
    620         starsn_peaks->n ++;
    621         Nstar ++;
    622 
    623         // PSF star (within 1.5 sigma of clump center, S/N > limit)
    624         psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY);
    625         if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) {
    626             source->type = PM_SOURCE_TYPE_STAR;
    627             source->mode |= PM_SOURCE_MODE_PSFSTAR;
    628             Npsf ++;
    629             continue;
     598        // The following determinations require the use of moments
     599        if (!(source->mode & noMoments)) {
     600            // likely defect (too small to be stellar) (push out to 3 sigma)
     601            // low S/N objects which are small are probably stellar
     602            // XXX these limits are quite arbitrary
     603            if (sigX < 0.05 || sigY < 0.05) {
     604                source->type = PM_SOURCE_TYPE_DEFECT;
     605                source->mode |= PM_SOURCE_MODE_DEFECT;
     606                Ncr ++;
     607                continue;
     608            }
     609
     610            // likely unsaturated extended source (too large to be stellar)
     611            if (sigX > clump.X + 3*clump.dX || sigY > clump.Y + 3*clump.dY) {
     612                source->type = PM_SOURCE_TYPE_EXTENDED;
     613                Next ++;
     614                continue;
     615            }
     616
     617            // the rest are probable stellar objects
     618            starsn_moments->data.F32[starsn_moments->n] = source->moments->SN;
     619            starsn_moments->n ++;
     620            starsn_peaks->data.F32[starsn_peaks->n] = source->peak->SN;
     621            starsn_peaks->n ++;
     622            Nstar ++;
     623
     624            // PSF star (within 1.5 sigma of clump center, S/N > limit)
     625            psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY);
     626            if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) {
     627                source->type = PM_SOURCE_TYPE_STAR;
     628                source->mode |= PM_SOURCE_MODE_PSFSTAR;
     629                Npsf ++;
     630                continue;
     631            }
    630632        }
    631633
     
    642644
    643645        if (!psVectorStats (stats, starsn_moments, NULL, NULL, 0)) {
    644             psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats");
    645             psFree (stats);
    646             psFree (starsn_peaks);
    647             return false;
     646            psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats");
     647            psFree (stats);
     648            psFree (starsn_peaks);
     649            return false;
    648650        }
    649651        psLogMsg ("pmObjects", 3, "SN range (moments): %f - %f\n", stats->min, stats->max);
     
    656658        stats = psStatsAlloc (PS_STAT_MIN | PS_STAT_MAX);
    657659        if (!psVectorStats (stats, starsn_peaks, NULL, NULL, 0)) {
    658             psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats");
    659             psFree (stats);
    660             psFree (starsn_peaks);
    661             return false;
     660            psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats");
     661            psFree (stats);
     662            psFree (starsn_peaks);
     663            return false;
    662664        }
    663665        psLogMsg ("psModules.objects", 3, "SN range (peaks)  : %f - %f (%ld)\n",
  • branches/eam_branches/20090522/psModules/src/objects/pmSourceIO.c

    r23990 r24557  
    496496                status = pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname);
    497497            }
     498            if (!strcmp (exttype, "PS1_V2")) {
     499                status = pmSourcesWrite_CMF_PS1_V2 (file->fits, readout, sources, file->header, outhead, dataname);
     500            }
    498501            if (xsrcname) {
    499502              if (!strcmp (exttype, "PS1_DEV_1")) {
     
    506509                  status = pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe);
    507510              }
     511              if (!strcmp (exttype, "PS1_V2")) {
     512                  status = pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe);
     513              }
    508514            }
    509515            if (xfitname) {
     
    517523                  status = pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname);
    518524              }
     525              if (!strcmp (exttype, "PS1_V2")) {
     526                  status = pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname);
     527              }
    519528            }
    520529            if (!status) {
     
    944953                sources = pmSourcesRead_CMF_PS1_V1 (file->fits, hdu->header);
    945954            }
     955            if (!strcmp (exttype, "PS1_V2")) {
     956                sources = pmSourcesRead_CMF_PS1_V2 (file->fits, hdu->header);
     957            }
    946958        }
    947959
  • branches/eam_branches/20090522/psModules/src/objects/pmSourceIO.h

    r23990 r24557  
    3939bool pmSourcesWrite_CMF_PS1_V1_XFIT (psFits *fits, psArray *sources, char *extname);
    4040
     41bool pmSourcesWrite_CMF_PS1_V2 (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname);
     42bool pmSourcesWrite_CMF_PS1_V2_XSRC (psFits *fits, psArray *sources, char *extname, psMetadata *recipe);
     43bool pmSourcesWrite_CMF_PS1_V2_XFIT (psFits *fits, psArray *sources, char *extname);
     44
    4145bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config);
    4246
     
    4852psArray *pmSourcesRead_PS1_CAL_0 (psFits *fits, psMetadata *header);
    4953psArray *pmSourcesRead_CMF_PS1_V1 (psFits *fits, psMetadata *header);
     54psArray *pmSourcesRead_CMF_PS1_V2 (psFits *fits, psMetadata *header);
    5055
    5156bool pmSourcesWritePSFs (psArray *sources, char *filename);
  • branches/eam_branches/20090522/psModules/src/objects/pmSourceIO_MatchedRefs.c

    r24025 r24557  
    4949    pmCell *cell = NULL;
    5050    pmReadout *readout = NULL;
    51     pmFPAview *view = pmFPAviewAlloc (0);
    5251
    5352    // first, check if there are any matches to be written
     
    5756    psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSASTRO");
    5857    if (!status) {
    59         psError(PS_ERR_UNKNOWN, true, "missing recipe PSASTRO in config data");
    60         return false;
     58        psError(PS_ERR_UNKNOWN, true, "missing recipe PSASTRO in config data");
     59        return false;
    6160    }
    6261
     
    6564
    6665    psArray *table = psArrayAllocEmpty (0x1000);
     66    pmFPAview *view = pmFPAviewAlloc (0);
    6767
    6868    // this loop selects the matched stars for all chips
     
    7070        psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    7171        if (!chip->process || !chip->file_exists) continue;
    72        
    73         char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
    7472
    75         while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
     73        char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
     74
     75        while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
    7676            psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    7777            if (!cell->process || !cell->file_exists) continue;
    7878
    79             // process each of the readouts
    80             // XXX there can only be one readout per chip, right?
    81             while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
    82                 if (! readout->data_exists) continue;
     79            // process each of the readouts
     80            // XXX there can only be one readout per chip, right?
     81            while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
     82                if (! readout->data_exists) continue;
    8383
    84                 // select the raw objects for this readout
    85                 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");
    86                 if (rawstars == NULL) continue;
     84                // select the raw objects for this readout
     85                psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");
     86                if (rawstars == NULL) continue;
    8787
    88                 // select the raw objects for this readout
    89                 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");
    90                 if (refstars == NULL) continue;
    91                 psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n);
     88                // select the raw objects for this readout
     89                psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");
     90                if (refstars == NULL) continue;
     91                psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n);
    9292
    93                 psArray *matches = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.MATCH");
    94                 if (matches == NULL) continue;
     93                psArray *matches = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.MATCH");
     94                if (matches == NULL) continue;
    9595
    96                 for (int i = 0; i < matches->n; i++) {
    97                     pmAstromMatch *match = matches->data[i];
     96                for (int i = 0; i < matches->n; i++) {
     97                    pmAstromMatch *match = matches->data[i];
    9898
    99                     pmAstromObj *raw = rawstars->data[match->raw];
    100                     pmAstromObj *ref = refstars->data[match->ref];
     99                    pmAstromObj *raw = rawstars->data[match->raw];
     100                    pmAstromObj *ref = refstars->data[match->ref];
    101101
    102                     psMetadata *row = psMetadataAlloc ();
    103                     psMetadataAdd (row, PS_LIST_TAIL, "RA",       PS_DATA_F64, "right ascension (deg, J2000)", PM_DEG_RAD*ref->sky->r);
    104                     psMetadataAdd (row, PS_LIST_TAIL, "DEC",      PS_DATA_F64, "declination (deg, J2000)",     PM_DEG_RAD*ref->sky->d);
    105                     psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP",   PS_DATA_F32, "x coord on chip",              raw->chip->x);
    106                     psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP",   PS_DATA_F32, "y coord on chip",              raw->chip->y);   
    107                     psMetadataAdd (row, PS_LIST_TAIL, "X_FPA",    PS_DATA_F32, "x coord on focal plane",       raw->FP->x);
    108                     psMetadataAdd (row, PS_LIST_TAIL, "Y_FPA",    PS_DATA_F32, "y coord on focal plane",       raw->FP->y);
    109                     psMetadataAdd (row, PS_LIST_TAIL, "MAG_INST", PS_DATA_F32, "instrumental magnitude",       raw->Mag);
    110                     psMetadataAdd (row, PS_LIST_TAIL, "MAG_REF",  PS_DATA_F32, "reference star magnitude",     ref->Mag);
    111                     psMetadataAdd (row, PS_LIST_TAIL, "COLOR_REF",PS_DATA_F32, "reference star color",         ref->Color);
    112                     psMetadataAdd (row, PS_LIST_TAIL, "CHIP_ID",  PS_DATA_STRING, "chip identifier",           chipName);
    113                     // XXX need to add the reference color, but this needs getstar / dvo.photcodes for the reference to be refined.
     102                    psMetadata *row = psMetadataAlloc ();
     103                    psMetadataAdd (row, PS_LIST_TAIL, "RA",       PS_DATA_F64, "right ascension (deg, J2000)", PM_DEG_RAD*ref->sky->r);
     104                    psMetadataAdd (row, PS_LIST_TAIL, "DEC",      PS_DATA_F64, "declination (deg, J2000)",     PM_DEG_RAD*ref->sky->d);
     105                    psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP",   PS_DATA_F32, "x coord on chip",              raw->chip->x);
     106                    psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP",   PS_DATA_F32, "y coord on chip",              raw->chip->y);
     107                    psMetadataAdd (row, PS_LIST_TAIL, "X_FPA",    PS_DATA_F32, "x coord on focal plane",       raw->FP->x);
     108                    psMetadataAdd (row, PS_LIST_TAIL, "Y_FPA",    PS_DATA_F32, "y coord on focal plane",       raw->FP->y);
     109                    psMetadataAdd (row, PS_LIST_TAIL, "MAG_INST", PS_DATA_F32, "instrumental magnitude",       raw->Mag);
     110                    psMetadataAdd (row, PS_LIST_TAIL, "MAG_REF",  PS_DATA_F32, "reference star magnitude",     ref->Mag);
     111                    psMetadataAdd (row, PS_LIST_TAIL, "COLOR_REF",PS_DATA_F32, "reference star color",         ref->Color);
     112                    psMetadataAdd (row, PS_LIST_TAIL, "CHIP_ID",  PS_DATA_STRING, "chip identifier",           chipName);
     113                    // XXX need to add the reference color, but this needs getstar / dvo.photcodes for the reference to be refined.
    114114
    115                     psArrayAdd (table, 100, row);
    116                     psFree (row);
    117                 }
    118             }
    119         }
     115                    psArrayAdd (table, 100, row);
     116                    psFree (row);
     117                }
     118            }
     119        }
    120120    }
    121121    psFree (view);
    122122
    123123    if (table->n == 0) {
    124         psFree(table);
    125         return true;
     124        psFree(table);
     125        return true;
    126126    }
    127127
  • branches/eam_branches/20090522/psModules/src/objects/pmSourceMatch.c

    r23989 r24557  
    4545                         psVector **x, psVector **y, // Coordinate vectors to return
    4646                         psVector **mag, psVector **magErr, // Magnitude and error vectors to return
     47                         psVector **indices, // Indices for sources
    4748                         const psArray *sources // Input sources
    4849    )
     
    5859    *mag = psVectorRecycle(*mag, numSources, PS_TYPE_F32);
    5960    *magErr = psVectorRecycle(*magErr, numSources, PS_TYPE_F32);
     61    *indices = psVectorRecycle(*indices, numSources, PS_TYPE_S32);
    6062    float xMin = INFINITY, xMax = -INFINITY, yMin = INFINITY, yMax = -INFINITY; // Bounds of sources
    6163    long num = 0;                       // Number of valid sources
    6264    for (long i = 0; i < numSources; i++) {
    6365        pmSource *source = sources->data[i]; // Source of interest
    64         if (!source) continue;
    65         if (source->mode & SOURCE_MASK) continue;
    66         if (!isfinite(source->psfMag)) continue;
    67         if (!isfinite(source->errMag)) continue;
    68         if (source->psfMag > SOURCE_FAINTEST) continue;
     66        if (!source || (source->mode & SOURCE_MASK) || !isfinite(source->psfMag) ||
     67            !isfinite(source->errMag) || source->psfMag > SOURCE_FAINTEST) {
     68            continue;
     69        }
    6970
    7071        float xSrc, ySrc;               // Coordinates of source
     
    7879        (*y)->data.F32[num] = ySrc;
    7980        (*mag)->data.F32[num] = source->psfMag;
    80         (*magErr)->data.F32[num] = source->errMag ;
     81        (*magErr)->data.F32[num] = source->errMag;
     82        (*indices)->data.S32[num] = i;
    8183        num++;
    8284    }
     
    8587    (*mag)->n = num;
    8688    (*magErr)->n = num;
     89    (*indices)->n = num;
    8790
    8891    if (*bounds) {
     
    175178        psVector *xImage = NULL, *yImage = NULL; // Coordinates of sources
    176179        psVector *magImage = NULL, *magErrImage = NULL; // Magnitude and mag
    177 
    178         int numSources = sourcesParse(&boundsImage, &xImage, &yImage, &magImage, &magErrImage,
     180        psVector *indices = NULL;     // Indices for sources
     181
     182        int numSources = sourcesParse(&boundsImage, &xImage, &yImage, &magImage, &magErrImage, &indices,
    179183                                      sources); // Number of sources
    180184
     
    187191            for (int j = 0; j < numSources; j++) {
    188192                pmSourceMatch *match = pmSourceMatchAlloc(); // Match data
    189                 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
     193                pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j],
     194                                 i, indices->data.S32[j]);
    190195                matches->data[j] = match;
    191196            }
     
    206211            for (int j = 0, k = numMaster; j < numSources; j++, k++) {
    207212                pmSourceMatch *match = pmSourceMatchAlloc(); // Match data
    208                 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
     213                pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j],
     214                                 i, indices->data.S32[j]);
    209215                matches->data[k] = match;
    210216            }
     
    231237                    // Record the match
    232238                    pmSourceMatch *match = matches->data[index]; // Match data
    233                     pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
     239                    pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j],
     240                                     i, indices->data.S32[j]);
    234241                    numMatch++;
    235242                } else {
    236243                    // Add to the master list
    237244                    pmSourceMatch *match = pmSourceMatchAlloc(); // Match data
    238                     pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
     245                    pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j],
     246                                     i, indices->data.S32[j]);
    239247                    xMaster->data.F32[numMaster] = xImage->data.F32[j];
    240248                    yMaster->data.F32[numMaster] = yImage->data.F32[j];
Note: See TracChangeset for help on using the changeset viewer.