IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 2:34:09 PM (16 years ago)
Author:
eugene
Message:

merging changes from PAP branch with modifications to the covariance matrix calculation

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/pswarp/src/pswarpLoop.c

    r27387 r28006  
    267267    }
    268268
    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 
    287269    // Set covariance matrix for output
    288270    {
     
    291273        psAssert(covariances, "Should be there");
    292274        psArray *covars = psListToArray(covariances); // Array of covariance matrices
    293         output->covariance = psImageCovarianceAverage(covars);
     275        psKernel *covar = psImageCovarianceAverage(covars);
    294276        psFree(covars);
    295277        psMetadataRemoveKey(output->analysis, PSWARP_ANALYSIS_COVARIANCES);
     278
     279        // Correct covariance matrix scale for the mean (square root of the) Jacobian
     280        double jacobian = psMetadataLookupF64(NULL, output->analysis, PSWARP_ANALYSIS_JACOBIAN); // Jacobian
     281        int goodPixels = psMetadataLookupS32(NULL, output->analysis, PSWARP_ANALYSIS_GOODPIX);   // Good pixels
     282        jacobian /= goodPixels;
     283        output->covariance = psImageCovarianceScale(covar, jacobian);
     284        psFree(covar);
     285
    296286        psImageCovarianceTransfer(output->variance, output->covariance);
    297287    }
Note: See TracChangeset for help on using the changeset viewer.