IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21374


Ignore:
Timestamp:
Feb 5, 2009, 5:20:02 PM (17 years ago)
Author:
Paul Price
Message:

Updating to work following merge of pap_branch_20090128. Compiles, but not tested.

Location:
trunk/ppSub/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/ppSubCamera.c

    r21360 r21374  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-06 01:37:17 $
     8 *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:20:02 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    3939    }
    4040
    41     // Input weight map
    42     pmFPAfile *inputWeight = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.WEIGHT", "INPUT.WEIGHT");
    43     if (!status) {
    44         psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.WEIGHT");
     41    // Input variance map
     42    pmFPAfile *inputVariance = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE");
     43    if (!status) {
     44        psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.VARIANCE");
    4545        return NULL;
    4646    }
    47     if (inputWeight && inputWeight->type != PM_FPA_FILE_WEIGHT) {
    48         psError(PS_ERR_IO, true, "PPSUB.INPUT.WEIGHT is not of type WEIGHT");
     47    if (inputVariance && inputVariance->type != PM_FPA_FILE_VARIANCE) {
     48        psError(PS_ERR_IO, true, "PPSUB.INPUT.VARIANCE is not of type VARIANCE");
    4949        return false;
    5050    }
     
    7373    }
    7474
    75     // Reference weight map
    76     pmFPAfile *refWeight = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.WEIGHT", "REF.WEIGHT");
    77     if (!status) {
    78         psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.WEIGHT");
     75    // Reference variance map
     76    pmFPAfile *refVariance = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.VARIANCE", "REF.VARIANCE");
     77    if (!status) {
     78        psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.VARIANCE");
    7979        return NULL;
    8080    }
    81     if (refWeight && refWeight->type != PM_FPA_FILE_WEIGHT) {
    82         psError(PS_ERR_IO, true, "PPSUB.REF.WEIGHT is not of type WEIGHT");
     81    if (refVariance && refVariance->type != PM_FPA_FILE_VARIANCE) {
     82        psError(PS_ERR_IO, true, "PPSUB.REF.VARIANCE is not of type VARIANCE");
    8383        return false;
    8484    }
     
    108108    outMask->save = true;
    109109
    110     // Output weight
    111     if (inputWeight && refWeight) {
    112         pmFPAfile *outWeight = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.OUTPUT.WEIGHT");
    113         if (!outWeight) {
    114             psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.WEIGHT"));
    115             return false;
    116         }
    117         if (outWeight->type != PM_FPA_FILE_WEIGHT) {
    118             psError(PS_ERR_IO, true, "PPSUB.OUTPUT.WEIGHT is not of type WEIGHT");
    119             return false;
    120         }
    121         outWeight->save = true;
     110    // Output variance
     111    if (inputVariance && refVariance) {
     112        pmFPAfile *outVariance = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.OUTPUT.VARIANCE");
     113        if (!outVariance) {
     114            psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.VARIANCE"));
     115            return false;
     116        }
     117        if (outVariance->type != PM_FPA_FILE_VARIANCE) {
     118            psError(PS_ERR_IO, true, "PPSUB.OUTPUT.VARIANCE is not of type VARIANCE");
     119            return false;
     120        }
     121        outVariance->save = true;
    122122    }
    123123
     
    146146    // XXX should be based on recipe : inConvMask->save = true;
    147147
    148     // Convolved input weight
    149     if (inputWeight) {
    150         pmFPAfile *inConvWeight = pmFPAfileDefineOutput(config, inConv->fpa, "PPSUB.INPUT.CONV.WEIGHT");
    151         if (!inConvWeight) {
    152             psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.WEIGHT"));
    153             return false;
    154         }
    155         if (inConvWeight->type != PM_FPA_FILE_WEIGHT) {
    156             psError(PS_ERR_IO, true, "PPSUB.INPUT.CONV.WEIGHT is not of type WEIGHT");
    157             return false;
    158         }
    159         // XXX should be based on recipe : inConvWeight->save = true;
     148    // Convolved input variance
     149    if (inputVariance) {
     150        pmFPAfile *inConvVariance = pmFPAfileDefineOutput(config, inConv->fpa, "PPSUB.INPUT.CONV.VARIANCE");
     151        if (!inConvVariance) {
     152            psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.VARIANCE"));
     153            return false;
     154        }
     155        if (inConvVariance->type != PM_FPA_FILE_VARIANCE) {
     156            psError(PS_ERR_IO, true, "PPSUB.INPUT.CONV.VARIANCE is not of type VARIANCE");
     157            return false;
     158        }
     159        // XXX should be based on recipe : inConvVariance->save = true;
    160160    }
    161161
     
    184184    // XXX should be based on recipe : refConvMask->save = true;
    185185
    186     // Convolved ref weight
    187     if (refWeight) {
    188         pmFPAfile *refConvWeight = pmFPAfileDefineOutput(config, refConv->fpa, "PPSUB.REF.CONV.WEIGHT");
    189         if (!refConvWeight) {
    190             psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.WEIGHT"));
    191             return false;
    192         }
    193         if (refConvWeight->type != PM_FPA_FILE_WEIGHT) {
    194             psError(PS_ERR_IO, true, "PPSUB.REF.CONV.WEIGHT is not of type WEIGHT");
    195             return false;
    196         }
    197         // XXX should be based on recipe : refConvWeight->save = true;
     186    // Convolved ref variance
     187    if (refVariance) {
     188        pmFPAfile *refConvVariance = pmFPAfileDefineOutput(config, refConv->fpa, "PPSUB.REF.CONV.VARIANCE");
     189        if (!refConvVariance) {
     190            psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.VARIANCE"));
     191            return false;
     192        }
     193        if (refConvVariance->type != PM_FPA_FILE_VARIANCE) {
     194            psError(PS_ERR_IO, true, "PPSUB.REF.CONV.VARIANCE is not of type VARIANCE");
     195            return false;
     196        }
     197        // XXX should be based on recipe : refConvVariance->save = true;
    198198    }
    199199
  • trunk/ppSub/src/ppSubReadoutPhotometry.c

    r21360 r21374  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-06 01:37:17 $
     8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:20:02 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    2525
    2626    if (!psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) {
    27         pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
    28         pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
    29         return true;
     27        pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
     28        pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
     29        return true;
    3030    }
    3131
     
    4040    pmPSF *psf = psMetadataLookupPtr(NULL, psfInputChip->analysis, "PSPHOT.PSF");
    4141    if (!psf) {
    42         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PSF from psphot");
    43         return false;
     42        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PSF from psphot");
     43        return false;
    4444    }
    4545    psMetadataAddPtr(psfLoadChip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE, "PSF from matched addition", psf);
     
    5555    pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources
    5656    if (!photRO) {
    57         pmCell *cell = pmFPAfileThisCell(config->files, view, "PSPHOT.RESID"); // Output cell
    58         photRO = pmReadoutAlloc(cell); // Output readout: subtraction
     57        pmCell *cell = pmFPAfileThisCell(config->files, view, "PSPHOT.RESID"); // Output cell
     58        photRO = pmReadoutAlloc(cell); // Output readout: subtraction
    5959    }
    6060    photRO->image = psImageCopy(photRO->image, outRO->image, PS_TYPE_F32);
    61     if (outRO->weight) {
    62         photRO->weight = psImageCopy(photRO->weight, outRO->weight, PS_TYPE_F32);
     61    if (outRO->variance) {
     62        photRO->variance = psImageCopy(photRO->variance, outRO->variance, PS_TYPE_F32);
    6363    } else {
    64         psFree (photRO->weight);
    65         photRO->weight = NULL;
     64        psFree (photRO->variance);
     65        photRO->variance = NULL;
    6666    }
    6767    if (outRO->mask) {
    68         photRO->mask = psImageCopy(photRO->mask, outRO->mask, PS_TYPE_IMAGE_MASK);
     68        photRO->mask = psImageCopy(photRO->mask, outRO->mask, PS_TYPE_IMAGE_MASK);
    6969    } else {
    70         psFree (photRO->mask);
    71         photRO->mask = NULL;
     70        psFree (photRO->mask);
     71        photRO->mask = NULL;
    7272    }
    7373
     
    7777    // old-style variance renormalization
    7878    if (!ppSubReadoutRenormPhot (config, recipe, photRO)) {
    79         psError(PS_ERR_UNKNOWN, false, "failure in renormalization");
    80         return false;
     79        psError(PS_ERR_UNKNOWN, false, "failure in renormalization");
     80        return false;
    8181    }
    8282
    8383    if (!psphotReadoutMinimal(config, view)) {
    84         psWarning("Unable to perform photometry on subtracted image.");
    85         psErrorStackPrint(stderr, "Error stack from photometry:");
    86         psErrorClear();
     84        psWarning("Unable to perform photometry on subtracted image.");
     85        psErrorStackPrint(stderr, "Error stack from photometry:");
     86        psErrorClear();
    8787    }
    8888
    8989    if (stats) {
    90         psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
    91         psMetadataAddS32(stats, PS_LIST_TAIL, "NUM_SOURCES", 0, "Number of sources detected",
    92                         sources ? sources->n : 0);
    93         psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_PHOT", 0, "Time to do photometry",
    94                         psTimerClear("PPSUB_PHOT"));
     90        psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
     91        psMetadataAddS32(stats, PS_LIST_TAIL, "NUM_SOURCES", 0, "Number of sources detected",
     92                        sources ? sources->n : 0);
     93        psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_PHOT", 0, "Time to do photometry",
     94                        psTimerClear("PPSUB_PHOT"));
    9595    }
    9696
     
    103103    // XXX not sure that this is still needed (only if psphotReadoutMinimal measures the background)
    104104    // if (!pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL") ||
    105     //  !pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV") ||
    106     //  !pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND")) {
    107     //  psError(PS_ERR_UNKNOWN, false, "Unable to drop PSPHOT internal files.");
    108     //  return false;
     105    //  !pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV") ||
     106    //  !pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND")) {
     107    //  psError(PS_ERR_UNKNOWN, false, "Unable to drop PSPHOT internal files.");
     108    //  return false;
    109109    // }
    110110
     
    116116    // Record data about sources: not everything gets into the output CMF files
    117117    {
    118         pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources
    119         psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
    120         FILE *sourceFile = fopen("sources.dat", "w"); // File for sources
    121         fprintf(sourceFile,
    122                 "# x y mag mag_err psf_chisq cr_nsigma ext_nsigma psf_qf flags m_x m_y m_xx m_xy m_yy\n");
    123         for (int i = 0; i < sources->n; i++) {
    124             pmSource *source = sources->data[i];
    125             if (!source) {
    126                 continue;
    127             }
     118        pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources
     119        psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
     120        FILE *sourceFile = fopen("sources.dat", "w"); // File for sources
     121        fprintf(sourceFile,
     122                "# x y mag mag_err psf_chisq cr_nsigma ext_nsigma psf_qf flags m_x m_y m_xx m_xy m_yy\n");
     123        for (int i = 0; i < sources->n; i++) {
     124            pmSource *source = sources->data[i];
     125            if (!source) {
     126                continue;
     127            }
    128128
    129             float x, y;             // Position of source
    130             float chi2;             // chi^2 for source
    131             if (source->modelPSF) {
    132                 x = source->modelPSF->params->data.F32[PM_PAR_XPOS];
    133                 y = source->modelPSF->params->data.F32[PM_PAR_YPOS];
    134                 chi2 = source->modelPSF->chisq;
    135             } else if (source->peak) {
    136                 x = source->peak->xf;
    137                 y = source->peak->yf;
    138                 chi2 = NAN;
    139             } else {
    140                 psWarning("No position available for source.");
    141                 continue;
    142             }
     129            float x, y;             // Position of source
     130            float chi2;             // chi^2 for source
     131            if (source->modelPSF) {
     132                x = source->modelPSF->params->data.F32[PM_PAR_XPOS];
     133                y = source->modelPSF->params->data.F32[PM_PAR_YPOS];
     134                chi2 = source->modelPSF->chisq;
     135            } else if (source->peak) {
     136                x = source->peak->xf;
     137                y = source->peak->yf;
     138                chi2 = NAN;
     139            } else {
     140                psWarning("No position available for source.");
     141                continue;
     142            }
    143143
    144             float xMoment = NAN, yMoment = NAN, xxMoment = NAN, xyMoment = NAN, yyMoment = NAN;
    145             if (source->moments) {
    146                 xMoment = source->moments->Mx;
    147                 yMoment = source->moments->My;
    148                 xxMoment = source->moments->Mxx;
    149                 xyMoment = source->moments->Mxy;
    150                 yyMoment = source->moments->Myy;
    151             }
     144            float xMoment = NAN, yMoment = NAN, xxMoment = NAN, xyMoment = NAN, yyMoment = NAN;
     145            if (source->moments) {
     146                xMoment = source->moments->Mx;
     147                yMoment = source->moments->My;
     148                xxMoment = source->moments->Mxx;
     149                xyMoment = source->moments->Mxy;
     150                yyMoment = source->moments->Myy;
     151            }
    152152
    153             fprintf(sourceFile, "%f %f %f %f %f %f %f %f %d %f %f %f %f %f\n",
    154                     x, y, source->psfMag, source->errMag, chi2, source->crNsigma, source->extNsigma,
    155                     source->pixWeight, source->mode, xMoment, yMoment, xxMoment, xyMoment, yyMoment);
    156         }
    157         fclose(sourceFile);
     153            fprintf(sourceFile, "%f %f %f %f %f %f %f %f %d %f %f %f %f %f\n",
     154                    x, y, source->psfMag, source->errMag, chi2, source->crNsigma, source->extNsigma,
     155                    source->pixWeight, source->mode, xMoment, yMoment, xxMoment, xyMoment, yyMoment);
     156        }
     157        fclose(sourceFile);
    158158    }
    159159#endif
  • trunk/ppSub/src/ppSubReadoutRenorm.c

    r21360 r21374  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-06 01:37:17 $
     8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:20:02 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    2323    psStatsOptions renormStdev = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe, "RENORM.STDEV"));
    2424    if (renormMean == PS_STAT_NONE || renormStdev == PS_STAT_NONE) {
    25         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    26                 "Unable to parse renormalisation statistics from recipe.");
    27         return false;
     25        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     26                "Unable to parse renormalisation statistics from recipe.");
     27        return false;
    2828    }
    2929    psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
    30     if (!pmReadoutWeightRenormPixels(readout, maskValue, renormMean, renormStdev, NULL)) {
    31         psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");
    32         return false;
     30    if (!pmReadoutVarianceRenormPixels(readout, maskValue, renormMean, renormStdev, NULL)) {
     31        psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");
     32        return false;
    3333    }
    3434    return true;
     
    4848    psStatsOptions renormStdev = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe, "RENORM.STDEV"));
    4949    if (renormMean == PS_STAT_NONE || renormStdev == PS_STAT_NONE) {
    50         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    51                 "Unable to parse renormalisation statistics from recipe.");
    52         return false;
     50        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     51                "Unable to parse renormalisation statistics from recipe.");
     52        return false;
    5353    }
    5454
     
    5858
    5959    psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
    60     if (!pmReadoutWeightRenormPhot(readout, maskValue, renormNum, renormWidth, renormMean, renormStdev, NULL)) {
    61         psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");
    62         return false;
     60    if (!pmReadoutVarianceRenormPhot(readout, maskValue, renormNum, renormWidth, renormMean, renormStdev, NULL)) {
     61        psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");
     62        return false;
    6363    }
    6464    return true;
  • trunk/ppSub/src/ppSubReadoutSubtract.c

    r21360 r21374  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-06 01:37:17 $
     8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:20:02 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    2828    pmReadout *subtrahend = NULL;
    2929    if (reverse) {
    30         minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV");
    31         subtrahend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV");
     30        minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV");
     31        subtrahend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV");
    3232    } else {
    33         minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV");
    34         subtrahend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV");
     33        minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV");
     34        subtrahend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV");
    3535    }
    3636
     
    5353    // Do the actual subtraction
    5454    pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT");
    55     outRO->image = (psImage *) psBinaryOp(outRO->image, minuend->image, "-", subtrahend->image);
    56     if (minuend->weight && subtrahend->weight) {
    57         outRO->weight = (psImage *) psBinaryOp(outRO->weight, minuend->weight, "+", subtrahend->weight);
     55    outRO->image = (psImage*)psBinaryOp(outRO->image, minuend->image, "-", subtrahend->image);
     56    if (minuend->variance && subtrahend->variance) {
     57        outRO->variance = (psImage*)psBinaryOp(outRO->variance, minuend->variance, "+", subtrahend->variance);
    5858    }
    59     outRO->mask = (psImage *) psBinaryOp(outRO->mask, minuend->mask, "|", subtrahend->mask);
     59    outRO->mask = (psImage*)psBinaryOp(outRO->mask, minuend->mask, "|", subtrahend->mask);
    6060
    6161    outRO->data_exists = true;
     
    8383    if (!outHDU || !inHDU) {
    8484        psError(PS_ERR_UNKNOWN, false, "Unable to find HDU at FPA level to copy astrometry.");
    85         return false;
    86     } 
     85        return false;
     86    }
    8787
    8888    // Copy astrometry over
     
    9090    if (!pmAstromReadWCS(outFPA, outChip, inHDU->header, 1.0)) {
    9191        psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry from input FPA.");
    92         return false;
    93     } 
     92        return false;
     93    }
    9494
    9595    if (!pmAstromWriteWCS(outHDU->header, outFPA, outChip, WCS_TOLERANCE)) {
    9696        psError(PS_ERR_UNKNOWN, false, "Unable to write WCS astrometry to output FPA.");
    97         return false;
     97        return false;
    9898    }
    9999
  • trunk/ppSub/src/ppSubVarianceFactors.c

    r21360 r21374  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-06 01:37:17 $
     8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:20:02 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    4040    pmSubtractionKernels *kernels = psMetadataLookupPtr(&mdok, outRO->analysis, PM_SUBTRACTION_ANALYSIS_KERNEL); // Kernels
    4141    if (!mdok) {
    42         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find subtraction kernels.");
    43         return false;
     42        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find subtraction kernels.");
     43        return false;
    4444    }
    4545
    4646    float vfIn = psMetadataLookupF32(NULL, inCell->concepts, "CELL.VARFACTOR"); // Variance factor for input
    4747    if (!isfinite(vfIn)) {
    48         vfIn = 1.0;
     48        vfIn = 1.0;
    4949    }
    5050    float vfRef = psMetadataLookupF32(NULL, refCell->concepts, "CELL.VARFACTOR"); // Variance factor for ref
    5151    if (!isfinite(vfRef)) {
    52         vfRef = 1.0;
     52        vfRef = 1.0;
    5353    }
    5454
    5555    if (kernels->mode == PM_SUBTRACTION_MODE_1) {
    56         vfIn *= pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false);
     56        vfIn *= pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false);
    5757    }
    5858    if (kernels->mode == PM_SUBTRACTION_MODE_2) {
    59         vfRef *= pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false);
    60     } 
     59        vfRef *= pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false);
     60    }
    6161    if (kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
    62         vfIn *= pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false);
    63         vfRef *= pmSubtractionVarianceFactor(kernels, 0.0, 0.0, true);
     62        vfIn *= pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false);
     63        vfRef *= pmSubtractionVarianceFactor(kernels, 0.0, 0.0, true);
    6464    }
    6565
     
    7272
    7373    // measure the mean of the convolved input variance image
    74     if (!psImageBackground(vfStats, NULL, inConv->weight, inConv->mask, maskVal | maskBad, rng)) {
    75         psError(PS_ERR_UNKNOWN, false, "Unable to measure mean variance for convolved input");
    76         psFree(vfStats);
    77         psFree(rng);
    78         return false;
     74    if (!psImageBackground(vfStats, NULL, inConv->variance, inConv->mask, maskVal | maskBad, rng)) {
     75        psError(PS_ERR_UNKNOWN, false, "Unable to measure mean variance for convolved input");
     76        psFree(vfStats);
     77        psFree(rng);
     78        return false;
    7979    }
    8080    float inMeanVar = vfStats->robustMedian; // Mean variance of input
    8181
    8282    // measure the mean of the convolved reference variance image
    83     if (!psImageBackground(vfStats, NULL, refConv->weight, refConv->mask, maskVal | maskBad, rng)) {
    84         psError(PS_ERR_UNKNOWN, false, "Unable to measure mean variance for convolved reference");
    85         psFree(vfStats);
    86         psFree(rng);
    87         return false;
     83    if (!psImageBackground(vfStats, NULL, refConv->variance, refConv->mask, maskVal | maskBad, rng)) {
     84        psError(PS_ERR_UNKNOWN, false, "Unable to measure mean variance for convolved reference");
     85        psFree(vfStats);
     86        psFree(rng);
     87        return false;
    8888    }
    8989    float refMeanVar = vfStats->robustMedian; // Mean variance of reference
     
    9898    // Statistics on the matching
    9999    if (stats) {
    100         psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MODE);
    101         psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_STAMPS);
    102         psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_DEV_MEAN);
    103         psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_DEV_RMS);
    104         psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_NORM);
    105         psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_BGDIFF);
    106         psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MX);
    107         psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MY);
    108         psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MXX);
    109         psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MXY);
    110         psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MYY);
     100        psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MODE);
     101        psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_STAMPS);
     102        psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_DEV_MEAN);
     103        psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_DEV_RMS);
     104        psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_NORM);
     105        psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_BGDIFF);
     106        psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MX);
     107        psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MY);
     108        psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MXX);
     109        psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MXY);
     110        psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MYY);
    111111
    112         psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_MATCH", 0, "Time to match PSFs",
    113                         psTimerClear("PPSUB_MATCH"));
     112        psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_MATCH", 0, "Time to match PSFs",
     113                        psTimerClear("PPSUB_MATCH"));
    114114    }
    115    
     115
    116116    return true;
    117117}
Note: See TracChangeset for help on using the changeset viewer.