IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41538 for trunk


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)

Location:
trunk/pswarp/src
Files:
3 edited

Legend:

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

    r35563 r41538  
    145145        }
    146146    }
    147 
    148147   
    149148    view->chip = view->cell = view->readout = -1;
    150149    pmFPAAddSourceFromView(output->fpa, view, output->format);
    151150
    152 
    153151    psFree (view);
    154152    return true;
  • 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:
  • trunk/pswarp/src/pswarpMapGrid.c

    r31878 r41538  
    1313# include "pswarp.h"
    1414
     15FILE *fout = NULL;
     16
    1517/**
    1618 * pswarpMapGridFromImage builds a set (a grid) of locally-linear maps which convert the source
     
    4648    }
    4749
     50    if (0) {
     51        // test the transformation sky<->chip for chip in smf:
     52        if (fout == NULL) { fout = fopen ("map.grid.txt", "w"); }
     53
     54        pmCell *cell = dest->parent;
     55        pmChip *chip = cell->parent;
     56        pmFPA *fpa = chip->parent;
     57
     58        int NxChip = dest->image->numCols;
     59        int NyChip = dest->image->numRows;
     60
     61        // XXX save these as static for speed?
     62        psPlane *CH0 = psPlaneAlloc();
     63        psPlane *CH1 = psPlaneAlloc();
     64       
     65        psPlane *FP0 = psPlaneAlloc();
     66        psPlane *TP0 = psPlaneAlloc();
     67
     68        psPlane *FP1 = psPlaneAlloc();
     69        psPlane *TP1 = psPlaneAlloc();
     70
     71        psSphere *sky = psSphereAlloc();
     72
     73        // measure the map for the center of each superpixel
     74        for (i = 0; i < NxChip; i += 100) {
     75            for (j = 0; j < NyChip; j += 100) {
     76               
     77                CH0->x = i;
     78                CH0->y = j;
     79                psPlaneTransformApply(FP0, chip->toFPA, CH0);
     80                psPlaneTransformApply (TP0, fpa->toTPA, FP0);
     81                psDeproject (sky, TP0, fpa->toSky);
     82                psProject (TP1, sky, fpa->toSky);
     83                psPlaneTransformApply (FP1, fpa->fromTPA, TP1);
     84                psPlaneTransformApply (CH1, chip->fromFPA, FP1);
     85
     86                fprintf (fout, "%f %f > %f %f > %f %f > %f %f | ", CH0->x, CH0->y, FP0->x, FP0->y, TP0->x, TP0->y, sky->r*180/M_PI, sky->d*180/M_PI);
     87                fprintf (fout, "%f %f < %f %f < %f %f \n", TP1->x, TP1->y, FP1->x, FP1->y, CH1->x, CH1->y);
     88
     89            }
     90        }
     91        fclose (fout);
     92
     93        psFree (CH0);
     94        psFree (FP0);
     95        psFree (TP0);
     96
     97        psFree (CH1);
     98        psFree (FP1);
     99        psFree (TP1);
     100
     101        psFree (sky);
     102    }
     103
    48104    grid->nXpix = nXpix;
    49105    grid->nYpix = nYpix;
     
    164220
    165221    // XXX need to include readout->cell->chip offsets
     222    // XXX note that 'dest' is the SMF and 'src' is the skycell CMF
     223    // this is the lower accuracy direction...
    166224
    167225    /** V(0,0) position */
     
    205263    map->xo = ix;
    206264    map->yo = iy;
    207 
     265   
    208266    psFree (offset);
    209267    psFree (FP);
Note: See TracChangeset for help on using the changeset viewer.