IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19123


Ignore:
Timestamp:
Aug 18, 2008, 2:53:41 PM (18 years ago)
Author:
Paul Price
Message:

Enabling threads. So far, only using the threaded parts of pmSubtraction*.

Location:
trunk/ppStack/src
Files:
2 edited

Legend:

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

    r19045 r19123  
    175175    psMetadataAddBool(arguments, PS_LIST_TAIL, "-temp-delete", 0,
    176176                      "Delete temporary files on completion?", false);
     177    psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Number of threads to use", 0);
    177178
    178179    if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 3) {
     
    194195
    195196    valueArgStr(arguments, "-stats", "STATS", arguments);
     197
     198    int numThreads = psMetadataLookupS32(NULL, arguments, "-threads"); // Number of threads
     199    if (numThreads > 0 && !psThreadPoolInit(numThreads)) {
     200        psError(PS_ERR_UNKNOWN, false, "Unable to setup %d threads", numThreads);
     201        return false;
     202    }
    196203
    197204    return true;
  • trunk/ppStack/src/ppStackMatch.c

    r18918 r19123  
    4343    int renormWidth = psMetadataLookupS32(&mdok, recipe, "RENORM.WIDTH"); // Width for renormalisation box
    4444    float penalty = psMetadataLookupF32(NULL, ppsub, "PENALTY"); // Penalty for wideness
     45    int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads
    4546
    4647    if (!pmReadoutMaskNonfinite(readout, maskIn)) {
     
    8384        }
    8485
     86        float minFlux = INFINITY;       // Minimum flux for fake image
     87        {
     88            psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for bg
     89            if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskIn, rng)) {
     90                psWarning("Can't measure background for image.");
     91                psErrorClear();
     92            } else {
     93                minFlux = bg->robustStdev;
     94            }
     95            psFree(bg);
     96        }
     97
    8598        // Generate a fake image to match to
    86         float maxMag = -INFINITY;           // Maximum magnitude of sources
    87         for (int i = 0; i < sources->n; i++) {
    88             pmSource *source = sources->data[i]; // Source of interest
    89             if (source->psfMag > maxMag && source->psfMag <= MAG_IGNORE && !(source->mode & SOURCE_MASK)) {
    90                 maxMag = source->psfMag;
     99        if (!isfinite(minFlux)) {
     100            float maxMag = -INFINITY;   // Maximum magnitude of sources
     101            for (int i = 0; i < sources->n; i++) {
     102                pmSource *source = sources->data[i]; // Source of interest
     103                if (source->psfMag > maxMag && source->psfMag <= MAG_IGNORE &&
     104                    !(source->mode & SOURCE_MASK)) {
     105                    maxMag = source->psfMag;
     106                }
    91107            }
     108            minFlux = 0.1 * powf(10.0, -0.4 * maxMag);
    92109        }
    93110
     
    95112
    96113        if (!pmReadoutFakeFromSources(fake, readout->image->numCols, readout->image->numRows, sources, NULL,
    97                                       NULL, psf, powf(10.0, -0.4 * maxMag), 0, false)) {
     114                                      NULL, psf, minFlux, 0, false)) {
    98115            psError(PS_ERR_UNKNOWN, false, "Unable to generate fake image with target PSF.");
    99116            psFree(fake);
     
    110127        }
    111128#endif
     129
     130        if (threads > 0) {
     131            pmSubtractionThreadsInit(output, NULL, readout, fake);
     132        }
    112133
    113134        // Do the image matching
     
    124145        psFree(fake);
    125146        psFree(optWidths);
     147
     148        if (threads > 0) {
     149            pmSubtractionThreadsFinalize(output, NULL, readout, fake);
     150        }
    126151
    127152        // Set the variance factor
Note: See TracChangeset for help on using the changeset viewer.