IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 7, 2013, 12:01:01 PM (13 years ago)
Author:
eugene
Message:

pswarp can now take an input.mdc file with multiple input images listed to generate a warp for a collection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarpUpdateStatistics.c

    r35524 r35527  
    1515// for each readout
    1616bool pswarpUpdateStatistics (pmFPA *output, psMetadata *fpaStats, pmFPA *input, pmFPA *astrom, pmConfig *config)  {
     17
     18    if (!fpaStats) {
     19        psLogMsg("pswarp", PS_LOG_INFO, "stats not requested, skipping");
     20        return true;
     21    }
    1722
    1823    // load the recipe
     
    95100                }
    96101
    97                 // Set covariance matrix for output
    98                 // XXX is this the right place for the covariance calculation?
    99 # if (0)
    100                 psList *covariances = psMetadataLookupPtr(&mdok, output->analysis, PSWARP_ANALYSIS_COVARIANCES); // Covariance matrices
    101                 psAssert(covariances, "Should be there");
    102                 psArray *covars = psListToArray(covariances); // Array of covariance matrices
    103                 psKernel *covar = psImageCovarianceAverage(covars);
    104                 psFree(covars);
    105                 psMetadataRemoveKey(output->analysis, PSWARP_ANALYSIS_COVARIANCES);
    106 
    107                 // Correct covariance matrix scale for the mean (square root of the) Jacobian
    108                 double jacobian = psMetadataLookupF64(NULL, output->analysis, PSWARP_ANALYSIS_JACOBIAN); // Jacobian
    109                 int goodPixels = psMetadataLookupS32(NULL, output->analysis, PSWARP_ANALYSIS_GOODPIX);   // Good pixels
    110                 jacobian /= goodPixels;
    111                 output->covariance = psImageCovarianceScale(covar, jacobian);
    112                 psFree(covar);
    113 
    114                 if (output->variance) {
    115                   psImageCovarianceTransfer(output->variance, output->covariance);
    116                 }
    117 # endif
    118 
    119                 {
    120                   // Add MD5 information for readout
    121                   psString headerName = NULL; ///< Header name for MD5
    122                   psVector *md5 = psImageMD5(readout->image); ///< md5 hash
    123                   psString md5string = psMD5toString(md5); ///< String
    124 
    125                   pmHDU *hdu = pmHDUFromReadout(readout);
    126                   psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, view->readout);
    127                   psMetadataAddStr(hdu->header, PS_LIST_TAIL, headerName, PS_META_REPLACE, "Image MD5", md5string);
    128                   psFree(md5);
    129                   psFree(md5string);
    130                   psFree(headerName);
    131                 }
    132102                psFree (readoutName);
    133103            }
    134 
    135             psList *inputCells = psMetadataLookupPtr (NULL, cell->analysis, "INPUT.CELLS");
    136             if (!pmConceptsAverageCells(cell, inputCells, NULL, NULL, false)) {
    137                 psError(psErrorCodeLast(), false, "Unable to average cell concepts.");
    138                 psFree(view);
    139                 return false;
    140             }
    141 
    142             // XXX Is this too ad-hoc?
    143             psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); ///< Trim section
    144             trimsec->x0 = trimsec->x1 = trimsec->y0 = trimsec->y1 = 0; ///< All pixels
    145 
    146104        }
    147105    }
    148106
    149107    // Perform statistics on the output image (ppStatsFPA loops down the hierarchy)
    150     if (fpaStats) {
    151       pmFPAviewReset (view);
    152       if (!ppStatsFPA(fpaStats, output, view, maskValue, config)) {
     108    pmFPAviewReset (view);
     109    if (!ppStatsFPA(fpaStats, output, view, maskValue, config)) {
    153110        psWarning("Unable to perform statistics on warped image.");
    154       }
    155111    }
    156112    psFree(view);
    157 
    158     if (!psMetadataCopy(output->concepts, input->concepts)) {
    159         psError(psErrorCodeLast(), false, "Unable to copy FPA concepts from input to output.");
    160         return false;
    161     }
    162113
    163114    if (Nreadout == 0) {
     
    168119    }     
    169120
    170     // Update ZP from the astrometry
    171     {
    172         psMetadataItem *item = psMetadataLookup(output->concepts, "FPA.ZP");
    173         item->data.F32 = psMetadataLookupF32(NULL, astrom->concepts, "FPA.ZP");
    174     }
    175 
    176     // need to update the chip and fpa level astrometry appropriately, see
    177     // code in psastro
    178    
    179 # if (0)
    180     if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) {
    181         psError(psErrorCodeLast(), false, "Unable to generate WCS header.");
    182         return false;
    183     }
    184 # endif
    185 
    186121    return true;
    187122}
Note: See TracChangeset for help on using the changeset viewer.