IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 10, 2007, 11:31:25 AM (19 years ago)
Author:
Paul Price
Message:

Candidate stamps (or stamp regions, if no stamp list is provided) for the region are now generated in a single step before the iteration is performed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmSubtractionMatch.c

    r14801 r14802  
    4747
    4848static bool getStamps(pmSubtractionStampList **stamps, // Stamps to read
    49                       const psArray *stampsData, // Stamp data from a file
    5049                      const pmReadout *reference, // Reference readout
    5150                      const pmReadout *input, // Input readout, or NULL to generate fake stamps
     
    6059    )
    6160{
    62     if (stampsData && *stamps) {
    63         // We've already previously read all the stamps
    64         return true;
    65     }
    66 
    67     psImage *inImage = NULL; // Input image
    68     if (input) {
    69         inImage = input->image;
    70     }
    71 
    72     if (stampsData) {
    73         psVector *xStamp = NULL, *yStamp = NULL, *fluxStamp = NULL; // Stamp positions and fluxes
    74         if (input) {
    75             // We have x, y because the target is provided by the input image
    76             xStamp = stampsData->data[0];
    77             yStamp = stampsData->data[1];
    78         } else {
    79             // We have x, y and flux in order to generate a target
    80             xStamp = stampsData->data[0];
    81             yStamp = stampsData->data[1];
    82             fluxStamp = stampsData->data[2];
    83         }
    84 
    85         psFree(*stamps);
    86         // Apply exclusion zone if we're matching to a nominated PSF; otherwise don't care
    87         *stamps = pmSubtractionSetStamps(xStamp, yStamp, fluxStamp, reference->image, subMask,
    88                                          region, stampSpacing, input ? 0 : footprint);
    89     }
    9061    psTrace("psModules.imcombine", 3, "Finding stamps...\n");
    91     *stamps = pmSubtractionFindStamps(*stamps, reference->image, subMask, region,
    92                                       threshold, stampSpacing);
     62    *stamps = pmSubtractionStampsFind(*stamps, reference->image, subMask, region, threshold, stampSpacing);
    9363    if (!*stamps) {
    9464        psError(PS_ERR_UNKNOWN, false, "Unable to find stamps.");
     
    9868    memCheck("  find stamps");
    9969
    100     if (!input && !pmSubtractionGenerateStamps(*stamps, targetWidth, footprint, size)) {
     70    if (!input && !pmSubtractionStampsGenerate(*stamps, targetWidth, footprint, size)) {
    10171        psError(PS_ERR_UNKNOWN, false, "Unable to generate target stamps.");
    10272        return false;
    10373    }
    10474
     75    memCheck("   generate stamps");
     76
    10577    psTrace("psModules.imcombine", 3, "Extracting stamps...\n");
    106     if (!pmSubtractionExtractStamps(*stamps, reference->image, inImage, weight, footprint, size)) {
     78    if (!pmSubtractionStampsExtract(*stamps, reference->image, input ? input->image : NULL,
     79                                    weight, footprint, size)) {
    10780        psError(PS_ERR_UNKNOWN, false, "Unable to extract stamps.");
    10881        return false;
     
    225198    pmSubtractionKernels *kernels = NULL; // Kernel basis functions
    226199
    227     // Read stamps from file
    228     psArray *stampsData = NULL;         // Stamps data read from file
    229     if (stampsName && strlen(stampsName) > 0) {
    230         psTrace("psModules.imcombine", 3, "Reading stamps from %s...\n", stampsName);
    231         if (input) {
    232             // We have x, y because the target is provided by the input image
    233             stampsData = psVectorsReadFromFile(stampsName, "%f %f"); // Stamp positions
    234         } else {
    235             // We have x, y and flux in order to generate a target
    236             stampsData = psVectorsReadFromFile(stampsName, "%f %f %f"); // Stamp positions
    237         }
    238         if (!stampsData) {
    239             psError(PS_ERR_IO, false, "Unable to read stamps file %s", stampsName);
    240             return false;
    241         }
    242 
    243         // Correct for IRAF/FITS (unit-offset) positions to C (zero-offset) positions
    244         psVector *xStamp = stampsData->data[0]; // x positions
    245         psVector *yStamp = stampsData->data[1]; // y positions
    246         psBinaryOp(xStamp, xStamp, "-", psScalarAlloc(1.0, PS_TYPE_F32));
    247         psBinaryOp(yStamp, yStamp, "-", psScalarAlloc(1.0, PS_TYPE_F32));
    248     }
    249 
    250200    int numCols = reference->image->numCols, numRows = reference->image->numRows; // Image dimensions
    251201
     
    281231            }
    282232
     233            // Read stamps from file
     234            if (stampsName && strlen(stampsName) > 0) {
     235                psTrace("psModules.imcombine", 3, "Reading stamps from %s...\n", stampsName);
     236                psVector *xStamp = NULL, *yStamp = NULL, *fluxStamp = NULL; // Stamp positions and fluxes
     237                if (input) {
     238                    // We have x, y because the target is provided by the input image
     239                    psArray *stampsData = psVectorsReadFromFile(stampsName, "%f %f"); // Stamp positions
     240                    if (!stampsData) {
     241                        psError(PS_ERR_IO, false, "Unable to read stamps file %s", stampsName);
     242                        goto ERROR;
     243                    }
     244                    xStamp = psMemIncrRefCounter(stampsData->data[0]);
     245                    yStamp = psMemIncrRefCounter(stampsData->data[1]);
     246                    psFree(stampsData);
     247                } else {
     248                    // We have x, y and flux in order to generate a target
     249                    psArray *stampsData = psVectorsReadFromFile(stampsName, "%f %f %f"); // Stamp positions
     250                    if (!stampsData) {
     251                        psError(PS_ERR_IO, false, "Unable to read stamps file %s", stampsName);
     252                        goto ERROR;
     253                    }
     254                    xStamp = psMemIncrRefCounter(stampsData->data[0]);
     255                    yStamp = psMemIncrRefCounter(stampsData->data[1]);
     256                    fluxStamp = psMemIncrRefCounter(stampsData->data[2]);
     257                    psFree(stampsData);
     258                }
     259
     260                // Correct for IRAF/FITS (unit-offset) positions to C (zero-offset) positions
     261                psBinaryOp(xStamp, xStamp, "-", psScalarAlloc(1.0, PS_TYPE_F32));
     262                psBinaryOp(yStamp, yStamp, "-", psScalarAlloc(1.0, PS_TYPE_F32));
     263
     264                stamps = pmSubtractionStampsSet(xStamp, yStamp, fluxStamp, reference->image, subMask,
     265                                                region, stampSpacing, input ? 0 : 2 * footprint);
     266            }
     267
    283268            // Define kernel basis functions
    284269            if (optimum && (type == PM_SUBTRACTION_KERNEL_ISIS || type == PM_SUBTRACTION_KERNEL_GUNK)) {
    285                 if (!getStamps(&stamps, stampsData, reference, input, subMask, weight, NULL,
     270                if (!getStamps(&stamps, reference, input, subMask, weight, NULL,
    286271                               threshold, stampSpacing, targetWidth, size, footprint)) {
    287272                    goto ERROR;
     
    308293                psTrace("psModules.imcombine", 2, "Iteration %d...\n", k);
    309294
    310                 if (!getStamps(&stamps, stampsData, reference, input, subMask, weight, region,
     295                if (!getStamps(&stamps, reference, input, subMask, weight, region,
    311296                               threshold, stampSpacing, targetWidth, size, footprint)) {
    312297                    goto ERROR;
     
    457442    psFree(subMask);
    458443    subMask = NULL;
    459     psFree(stampsData);
    460     stampsData = NULL;
    461444
    462445    if (!pmSubtractionBorder(convolved->image, convolved->weight, convolved->mask, size, maskBlank)) {
     
    477460    psFree(stamps);
    478461    psFree(solution);
    479     psFree(stampsData);
    480462    psFree(stamps);
    481463    return false;
Note: See TracChangeset for help on using the changeset viewer.