IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 5:06:01 PM (16 years ago)
Author:
watersc1
Message:

Almost working version of the mask-stats/software revision code.

Almost.

Location:
branches/czw_branch/20100427
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20100427

  • branches/czw_branch/20100427/pswarp/src/pswarpLoop.c

    r27387 r28017  
    266266        goto DONE;
    267267    }
    268 
    269     // Correct image for change in the plate scale
    270     {
    271         psAssert(input && input->fpa && input->fpa->toSky, "Require astrometry for input");
    272         psAssert(outFPA && outFPA && outFPA->toSky, "Require astrometry for output");
    273 
    274         double inScale = input->fpa->toSky->Xs + input->fpa->toSky->Ys; // Plate scale for input
    275         double outScale = outFPA->toSky->Xs + outFPA->toSky->Ys; // Plate scale for output
    276         float correction = PS_SQR(outScale / inScale); // Correction factor to apply to image
    277         psLogMsg("pswarp", PS_LOG_INFO, "Correcting flux by %f to account for pixel scales", correction);
    278 
    279         psBinaryOp(output->image, output->image, "*", psScalarAlloc(correction, PS_TYPE_F32));
    280         if (output->variance) {
    281             psBinaryOp(output->variance, output->variance, "*",
    282                        psScalarAlloc(PS_SQR(correction), PS_TYPE_F32));
    283         }
    284     }
    285 
    286 
     268    bool doStats = psMetadataLookupBool(&mdok,recipe,"MASK.STATS");
     269    if (doStats) {
     270      if (!pswarpMaskStats(output, stats, config)) {
     271        psError(psErrorCodeLast(), false, "Unable to calculate mask stats.");
     272        psFree(cells);
     273        psFree(view);
     274        goto DONE;
     275      }
     276    }
    287277    // Set covariance matrix for output
    288278    {
     
    291281        psAssert(covariances, "Should be there");
    292282        psArray *covars = psListToArray(covariances); // Array of covariance matrices
    293         output->covariance = psImageCovarianceAverage(covars);
     283        psKernel *covar = psImageCovarianceAverage(covars);
    294284        psFree(covars);
    295285        psMetadataRemoveKey(output->analysis, PSWARP_ANALYSIS_COVARIANCES);
     286
     287        // Correct covariance matrix scale for the mean (square root of the) Jacobian
     288        double jacobian = psMetadataLookupF64(NULL, output->analysis, PSWARP_ANALYSIS_JACOBIAN); // Jacobian
     289        int goodPixels = psMetadataLookupS32(NULL, output->analysis, PSWARP_ANALYSIS_GOODPIX);   // Good pixels
     290        jacobian /= goodPixels;
     291        output->covariance = psImageCovarianceScale(covar, jacobian);
     292        psFree(covar);
     293
    296294        psImageCovarianceTransfer(output->variance, output->covariance);
    297295    }
     
    340338
    341339    pswarpVersionHeader(hdu->header);
    342 
     340   
    343341    if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) {
    344342        psError(psErrorCodeLast(), false, "Unable to generate WCS header.");
     
    355353    pswarpFileActivation(config, detectorFiles, false);
    356354    pswarpFileActivation(config, independentFiles, false);
     355
    357356
    358357    // We need a new PSF model for the warped frame.  It would be good to generate this analytically, but
     
    429428        }
    430429    }
     430   
    431431
    432432    // Add MD5 information for readout
Note: See TracChangeset for help on using the changeset viewer.