IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19213


Ignore:
Timestamp:
Aug 26, 2008, 10:40:58 AM (18 years ago)
Author:
Paul Price
Message:

The input sources and the final product sources were being confused
--- the final merged list of sources had the same pointer as the first
input source array (which multiplies the number of spurious sources
and hence makes it difficult to match PSFs). To get around this, use
a completely new array in the source list instead of borrowing the
input. This may generate a memory leak somewhere, but I'm not worried
about that yet. Also added a function to print the sources to a ds9
region file --- useful for debugging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackSources.c

    r18918 r19213  
    117117    psMemSetDeallocator(list, (psFreeFunc)stackSourceListFree);
    118118
    119     list->sources = psMemIncrRefCounter(sources);
     119    // Copy the sources onto a new array, so there's no confusion between the inputs and outputs
     120    long num = sources->n;              // Number of sources
     121    list->sources = psArrayAlloc(num);
     122    for (long i = 0; i < num; i++) {
     123        list->sources->data[i] = psMemIncrRefCounter(sources->data[i]);
     124    }
     125
    120126    list->bounds = NULL;
    121127    list->indices = NULL;
     
    447453    return psMemIncrRefCounter(firstList->sources);
    448454}
     455
     456
     457
     458void ppStackSourcesPrint(const psArray *sources)
     459{
     460    static int num = 0;                 // Number of source array
     461    psString filename = NULL;           // Name of file
     462    psStringAppend(&filename, "sources_%d.reg", num++);
     463
     464    const char *goodColour = "green";   // Colour for good sources
     465    const char *badColour = "red";      // Colour for bad sources
     466    float radius = 5;                   // Radius for circle
     467
     468    FILE *file = fopen(filename, "w");  // File to which to write
     469    psFree(filename);
     470    for (int i = 0; i < sources->n; i++) {
     471        pmSource *source = sources->data[i]; // Source of interest
     472        if (!source) {
     473            continue;
     474        }
     475
     476        float x, y;                     // Source coordinates
     477        coordsFromSource(&x, &y, source);
     478
     479        bool bad = (source->mode & SOURCE_MASK) || !isfinite(source->psfMag) ||
     480            source->psfMag > SOURCE_FAINTEST; // Is this a bad source?
     481
     482        fprintf(file, "image; circle(%f,%f,%f) # color = %s\n", x, y, radius, bad ? badColour : goodColour);
     483    }
     484    fclose(file);
     485
     486    return;
     487}
Note: See TracChangeset for help on using the changeset viewer.