IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 19, 2013, 3:42:02 PM (13 years ago)
Author:
eugene
Message:

merged from trunk

Location:
branches/eam_branches/ipp-20130307
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130307

  • branches/eam_branches/ipp-20130307/pswarp/src/pswarpDefine.c

    r35373 r35413  
    3838    }
    3939   
    40     // open the full skycell file; no need to defer different depths. only load the header data
    41     pmFPAview *view = pmFPAviewAlloc (0);
    42     pmFPAfileOpen (skycell, view, config);
     40    // Read the output astrometry
     41    // XXX this section loops over the input skycell to load the header info
     42    {
     43        pmFPAview *view = pmFPAviewAlloc(0);
    4344
    44     // Read header and create target
    45     {
    46         if (!pmFPAReadHeaderSet(skycell->fpa, skycell->fits, config)) {
    47             psError(psErrorCodeLast(), false, "Unable to read headers for skycell.");
    48             psFree(view);
    49             return false;
    50         }
    51         view->chip = 0;
    52         view->cell = 0;
    53         view->readout = 0;
    54         pmCell *source = pmFPAfileThisCell(config->files, view, "PSWARP.SKYCELL"); ///< Source cell
    55         pmHDU *hdu = pmHDUFromCell(source); ///< HDU for source
    56         if (!hdu || !hdu->header) {
    57             psError(PM_ERR_PROG, false, "Unable to find header for sky cell.");
    58             psFree(view);
    59             return false;
    60         }
    61         int numCols = psMetadataLookupS32(NULL, hdu->header, "NAXIS1"); ///< Number of columns
    62         int numRows = psMetadataLookupS32(NULL, hdu->header, "NAXIS2"); ///< Number of rows
    63         if ((numCols == 0) || (numRows == 0)) {
    64             psError(PSWARP_ERR_DATA, false, "skycell has invalid dimensions %d x %d", numCols, numRows);
    65             psFree(view);
    66             return false;
    67         }
     45        pmChip *chip;
     46        if (!pmFPAfileRead (skycell, view, config)) {
     47            psError(PS_ERR_IO, false, "failed READ at FPA %s", skycell->name);
     48            psFree(view);
     49            return false;
     50        }
     51        while ((chip = pmFPAviewNextChip (view, skycell->fpa, 1)) != NULL) {
     52            psTrace ("pswarp", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     53            if (!chip->process || !chip->file_exists) { continue; }
     54            if (!pmFPAfileRead (skycell, view, config)) {
     55                psError(psErrorCodeLast(), false, "failed READ at CHIP %s", skycell->name);
     56                psFree(view);
     57                return false;
     58            }
     59            pmCell *cell;
     60            while ((cell = pmFPAviewNextCell (view, skycell->fpa, 1)) != NULL) {
     61                psTrace ("pswarp", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     62                if (!cell->process || !cell->file_exists) { continue; }
     63                if (!pmFPAfileRead (skycell, view, config)) {
     64                    psError(psErrorCodeLast(), false, "failed READ at CELL %s", skycell->name);
     65                    psFree(view);
     66                    return false;
     67                }
     68                if (!pmFPAfileClose(skycell, view)) {
     69                    psError(psErrorCodeLast(), false, "failed CLOSE at CELL %s", skycell->name);
     70                    psFree (view);
     71                    return false;
     72                }
    6873
    69         pmCell *target = pmFPAviewThisCell(view, output->fpa); ///< Target cell
    70         pmReadout *readout = pmReadoutAlloc(target); ///< Target readout
    71         readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    72         psImageInit(readout->image, NAN);
    73         psFree(readout);                // Drop reference
    74 
    75         bool status = false;
    76         psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XBIN");
    77         psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YBIN");
    78         psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XSIZE");
    79         psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YSIZE");
    80         psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XPARITY");
    81         psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YPARITY");
    82         psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.X0");
    83         psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.Y0");
     74                // we've got the output astrom header
     75                pmHDU *hdu = pmHDUFromCell(cell); ///< HDU for source
     76                if (!hdu || !hdu->header) {
     77                    psError(PM_ERR_PROG, false, "Unable to find header for sky cell.");
     78                    psFree(view);
     79                    return false;
     80                }
     81                int numCols = psMetadataLookupS32(NULL, hdu->header, "NAXIS1"); ///< Number of columns
     82                int numRows = psMetadataLookupS32(NULL, hdu->header, "NAXIS2"); ///< Number of rows
     83                if ((numCols == 0) || (numRows == 0)) {
     84                    psError(PSWARP_ERR_DATA, false, "skycell has invalid dimensions %d x %d", numCols, numRows);
     85                    psFree(view);
     86                    return false;
     87                }
     88               
     89                // XXX generate the output pixels
     90                pmCell *target = pmFPAviewThisCell(view, output->fpa); ///< Target cell
     91                pmReadout *readout = pmReadoutAlloc(target); ///< Target readout
     92                readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     93                psImageInit(readout->image, NAN);
     94                psFree(readout);                // Drop reference
     95               
     96                bool status = false;
     97                psMetadataItemSupplement(&status, target->concepts, cell->concepts, "CELL.XBIN");
     98                psMetadataItemSupplement(&status, target->concepts, cell->concepts, "CELL.YBIN");
     99                psMetadataItemSupplement(&status, target->concepts, cell->concepts, "CELL.XSIZE");
     100                psMetadataItemSupplement(&status, target->concepts, cell->concepts, "CELL.YSIZE");
     101                psMetadataItemSupplement(&status, target->concepts, cell->concepts, "CELL.XPARITY");
     102                psMetadataItemSupplement(&status, target->concepts, cell->concepts, "CELL.YPARITY");
     103                psMetadataItemSupplement(&status, target->concepts, cell->concepts, "CELL.X0");
     104                psMetadataItemSupplement(&status, target->concepts, cell->concepts, "CELL.Y0");
     105            }
     106            if (!pmFPAfileClose(skycell, view)) {
     107                psError(psErrorCodeLast(), false, "failed CLOSE at CHIP %s", skycell->name);
     108                psFree (view);
     109                return false;
     110            }
     111        }
     112        if (!pmFPAfileClose(skycell, view)) {
     113            psError(psErrorCodeLast(), false, "failed CLOSE at FPA %s", skycell->name);
     114            psFree (view);
     115            return false;
     116        }
     117        psFree(view);
    84118    }
    85119
    86     // XXX this is not a sufficient test
     120    // the section below converts the header astrometry info (in skycell) to the pmFPA
     121    // astrometry structures, saving them on the output fpa structure.
     122
     123    // XXX this block should be modified to loop over all chips
     124
     125    pmFPAview *view = pmFPAviewAlloc (0);
    87126    view->chip = 0;
    88127    view->cell = 0;
Note: See TracChangeset for help on using the changeset viewer.