IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 3, 2021, 2:31:34 PM (5 years ago)
Author:
eugene
Message:

minor whitespace change; attempt to plug leaks in pswarpLoopSkycell, but it is not actually used, add some test code for transformation (inactive)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarpLoopSkycell.c

    r35563 r41538  
    11/** @file pswarpLoop.c
    22 *
     3 *  ** this function is not used... **
    34 *  @brief mail processing loop for pswarp
    45 *  @ingroup pswarp
     
    6364
    6465    // select the output readout
    65     pmFPAview *view = pmFPAviewAlloc(0);
    66     view->chip = 0;
    67     view->cell = 0;
    68     view->readout = 0;
    69     pmReadout *output = pmFPAfileThisReadout(config->files, view, "PSWARP.OUTPUT");
     66    pmFPAview *viewT0 = pmFPAviewAlloc(0);
     67    viewT0->chip = 0;
     68    viewT0->cell = 0;
     69    viewT0->readout = 0;
     70    pmReadout *output = pmFPAfileThisReadout(config->files, viewT0, "PSWARP.OUTPUT");
    7071    if (!output) {
    7172        psError(PSWARP_ERR_CONFIG, true, "Can't find output data!\n");
     73        psFree (viewT0);
    7274        return false;
    7375    }
    74     psFree (view);
    75 
     76    psFree (viewT0);
    7677
    7778    // Turn all skycell files on to generate them, and then turn them off for the loop over the input images
     
    9798
    9899        pmChip *chip;
    99         pmFPAview *view = pmFPAviewAlloc(0);
    100         if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     100        pmFPAview *viewT1 = pmFPAviewAlloc(0);
     101        if (!pmFPAfileIOChecks(config, viewT1, PM_FPA_BEFORE)) {
    101102            psError(psErrorCodeLast(), false, "Unable to read files.");
    102             goto DONE;
    103         }
    104         while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
    105             psTrace ("pswarp", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     103            psFree(viewT1);
     104            goto DONE;
     105        }
     106        while ((chip = pmFPAviewNextChip (viewT1, input->fpa, 1)) != NULL) {
     107            psTrace ("pswarp", 4, "Chip %d: %x %x\n", viewT1->chip, chip->file_exists, chip->process);
    106108            if (!chip->process || !chip->file_exists) { continue; }
    107             if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     109            if (!pmFPAfileIOChecks(config, viewT1, PM_FPA_BEFORE)) {
    108110                psError(psErrorCodeLast(), false, "Unable to read files.");
     111                psFree(viewT1);
    109112                goto DONE;
    110113            }
    111114            pmCell *cell;
    112             while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    113                 psTrace ("pswarp", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     115            while ((cell = pmFPAviewNextCell (viewT1, input->fpa, 1)) != NULL) {
     116                psTrace ("pswarp", 4, "Cell %d: %x %x\n", viewT1->cell, cell->file_exists, cell->process);
    114117                if (!cell->process || !cell->file_exists) { continue; }
    115                 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE) ||
    116                     !pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
     118                if (!pmFPAfileIOChecks (config, viewT1, PM_FPA_BEFORE) ||
     119                    !pmFPAfileIOChecks (config, viewT1, PM_FPA_AFTER)) {
    117120                    psError(psErrorCodeLast(), false, "Unable to read files.");
     121                    psFree(viewT1);
    118122                    goto DONE;
    119123                }
    120124            }
    121             if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
     125            if (!pmFPAfileIOChecks (config, viewT1, PM_FPA_AFTER)) {
    122126                psError(psErrorCodeLast(), false, "Unable to write files.");
    123                 goto DONE;
    124             }
    125         }
    126         if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
     127                psFree(viewT1);
     128                goto DONE;
     129            }
     130        }
     131        if (!pmFPAfileIOChecks (config, viewT1, PM_FPA_AFTER)) {
    127132            psError(psErrorCodeLast(), false, "Unable to write files.");
    128             goto DONE;
    129         }
    130         psFree(view);
     133            psFree(viewT1);
     134            goto DONE;
     135        }
     136        psFree(viewT1);
    131137
    132138        pswarpFileActivation(config, detectorFiles, true);
     
    139145    // Don't care about the skycell anymore --- we've read it, and that's all we need to do.
    140146    pmFPAfileActivate(config->files, false, "PSWARP.SKYCELL");
    141     view = pmFPAviewAlloc(0);
     147    pmFPAview *viewT2 = pmFPAviewAlloc(0);
    142148
    143149    // find the FPA phu
    144150    bool bilevelAstrometry = false;
    145     pmHDU *phu = pmFPAviewThisPHU(view, astrom->fpa);
     151    pmHDU *phu = pmFPAviewThisPHU(viewT2, astrom->fpa);
    146152    if (phu) {
    147153        char *ctype = psMetadataLookupStr(NULL, phu->header, "CTYPE1");
     
    153159        if (!pmAstromReadBilevelMosaic(input->fpa, phu->header)) {
    154160            psError(psErrorCodeLast(), false, "Unable to read bilevel mosaic astrometry for input FPA.");
    155             psFree(view);
     161            psFree(viewT2);
    156162            goto DONE;
    157163        }
     
    161167
    162168    // files associated with the science image
    163     if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
     169    if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_BEFORE)) {
    164170        psError(psErrorCodeLast(), false, "Unable to read files.");
     171            psFree(viewT2);
    165172        goto DONE;
    166173    }
     
    168175    // *** main transformation block
    169176    pmChip *chip;
    170     while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
    171         psTrace ("pswarp", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     177    while ((chip = pmFPAviewNextChip (viewT2, input->fpa, 1)) != NULL) {
     178        psTrace ("pswarp", 4, "Chip %d: %x %x\n", viewT2->chip, chip->file_exists, chip->process);
    172179        if (!chip->process || !chip->file_exists) { continue; }
    173         if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
     180        if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_BEFORE)) {
    174181            psError(psErrorCodeLast(), false, "Unable to read files.");
     182            psFree(viewT2);
    175183            goto DONE;
    176184        }
    177185
    178186        // read WCS data from the corresponding header
    179         pmHDU *hdu = pmFPAviewThisHDU (view, astrom->fpa);
     187        pmHDU *hdu = pmFPAviewThisHDU (viewT2, astrom->fpa);
    180188
    181189       
     
    183191            if (!pmAstromReadBilevelChip (chip, hdu->header)) {
    184192                psError(psErrorCodeLast(), false, "Unable to read bilevel chip astrometry for input FPA.");
    185                 psFree(view);
     193                psFree(viewT2);
    186194                goto DONE;
    187195            }
     
    190198            if (!pmAstromReadWCS (input->fpa, chip, hdu->header, 1.0)) {
    191199                psError(psErrorCodeLast(), false, "Unable to read WCS astrometry for input FPA.");
    192                 psFree(view);
     200                psFree(viewT2);
    193201                goto DONE;
    194202            }
     
    196204       
    197205        pmCell *cell;
    198         while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    199             psTrace ("pswarp", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     206        while ((cell = pmFPAviewNextCell (viewT2, input->fpa, 1)) != NULL) {
     207            psTrace ("pswarp", 4, "Cell %d: %x %x\n", viewT2->cell, cell->file_exists, cell->process);
    200208            if (!cell->process || !cell->file_exists) { continue; }
    201209            if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    202210                psError(psErrorCodeLast(), false, "Unable to read files.");
     211            psFree(viewT2);
    203212                goto DONE;
    204213            }
     
    211220                if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    212221                    psError(psErrorCodeLast(), false, "Unable to read files.");
     222            psFree(viewT2);
    213223                    goto DONE;
    214224                }
     
    229239                if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    230240                    psError(psErrorCodeLast(), false, "Unable to write files.");
     241            psFree(viewT2);
    231242                    goto DONE;
    232243                }
     
    234245            if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    235246                psError(psErrorCodeLast(), false, "Unable to write files.");
     247            psFree(viewT2);
    236248                goto DONE;
    237249            }
     
    239251        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    240252            psError(psErrorCodeLast(), false, "Unable to write files.");
     253            psFree(viewT2);
    241254            goto DONE;
    242255        }
     
    251264        psphotFilesActivate(config, false);
    252265        psFree(cells);
    253         psFree(view);
     266        psFree(viewT2);
    254267        goto DONE;
    255268    }
     
    262275        psError(psErrorCodeLast(), false, "Unable to calculate pixel regions.");
    263276        psFree(cells);
    264         psFree(view);
     277        psFree(viewT2);
    265278        goto DONE;
    266279    }
     
    270283        psError(psErrorCodeLast(), false, "Unable to calculate mask stats.");
    271284        psFree(cells);
    272         psFree(view);
     285        psFree(viewT2);
    273286        goto DONE;
    274287      }
     
    299312        psError(psErrorCodeLast(), false, "Unable to average cell concepts.");
    300313        psFree(cells);
    301         psFree(view);
     314        psFree(viewT2);
    302315        goto DONE;
    303316    }
     
    309322    if (!psMetadataCopy(outFPA->concepts, input->fpa->concepts)) {
    310323        psError(psErrorCodeLast(), false, "Unable to copy FPA concepts from input to output.");
    311         psFree(view);
     324        psFree(viewT2);
    312325        goto DONE;
    313326    }
     
    330343        if (!skyHDU) {
    331344            psError(PSWARP_ERR_DATA, false, "Unable to find skycell HDU.");
    332             psFree(view);
     345            psFree(viewT2);
    333346            goto DONE;
    334347        }
     
    340353    if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) {
    341354        psError(psErrorCodeLast(), false, "Unable to generate WCS header.");
    342         goto DONE;
    343     }
    344 
    345     if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     355            psFree(viewT2);
     356        goto DONE;
     357    }
     358
     359    if (!pmFPAfileIOChecks(config, viewT2, PM_FPA_AFTER)) {
    346360        psError(psErrorCodeLast(), false, "Unable to write files.");
     361            psFree(viewT2);
    347362        goto DONE;
    348363    }
     
    360375        if (!pswarpIOChecksBefore(config)) {
    361376            psError(psErrorCodeLast(), false, "Unable to read files.");
     377            psFree(viewT2);
    362378            goto DONE;
    363379        }
     
    367383        pmFPACopy(photFile->fpa, outFPA);
    368384
    369         pmFPAview *view = pmFPAviewAlloc(0); ///< View into skycell
    370         view->chip = view->cell = view->readout = 0;
     385        pmFPAview *viewT3 = pmFPAviewAlloc(0); ///< View into skycell
     386        viewT3->chip = viewT3->cell = viewT3->readout = 0;
    371387
    372388        // grab the sources of interest from the storage location (pmFPAfile PSPHOT.INPUT.CMF)
     
    374390        if (!sources) {
    375391            psError(psErrorCodeLast(), false, "No sources supplied to measure PSF");
     392            psFree(viewT2);
    376393            goto DONE;
    377394        }
     
    432449    const char *cellName = psMetadataLookupStr(NULL, output->parent->concepts, "CELL.NAME");
    433450    psString headerName = NULL; ///< Header name for MD5
    434     psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, view->readout);
     451    psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, viewT2->readout);
    435452    psVector *md5 = psImageMD5(output->image); ///< md5 hash
    436453    psString md5string = psMD5toString(md5); ///< String
     
    440457    psFree(md5string);
    441458    psFree(headerName);
    442     psFree(view);
     459    psFree(viewT2);
    443460
    444461 DONE:
Note: See TracChangeset for help on using the changeset viewer.