IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25383


Ignore:
Timestamp:
Sep 15, 2009, 12:45:01 PM (17 years ago)
Author:
Paul Price
Message:

Merging branches/pap (detection efficiency development) into trunk.

Location:
trunk
Files:
35 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/archive/ducttape

  • trunk/catalyst

  • trunk/catalyst/2007.0-specs

  • trunk/catalyst/2008.0-specs

  • trunk/catalyst/2008.0-specs/hardened

  • trunk/doc/misc/docgen.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/hardware

  • trunk/ippScripts/scripts/magic_destreak_revert.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippTests/tap

  • trunk/ippconfig/gpc1/camera.config

    r23820 r25383  
    132132  CMF.XSRC STR {CHIP.NAME}.xsrc # use .PSF and .EXT?
    133133  CMF.XFIT STR {CHIP.NAME}.xfit # use .PSF and .EXT?
     134  CMF.DETEFF STR {CHIP.NAME}.deteff
    134135
    135136  PSF.HEAD  STR {CHIP.NAME}.hdr
  • trunk/ippconfig/recipes/psphot.config

    r24879 r25383  
    265265PSPHOT.CR.NSIGMA.SOFTEN             F32   0.0025          # Softening parameter for weights
    266266
     267# Detection efficiency
     268EFF.NUM                             S32   500                   # Number of fake sources per bin
     269@EFF.MAG                            F32   -2.0 -1.0 -0.5 -0.25 -0.1 -0.05 0.0 0.05 0.1 0.25 0.5 1.0 2.0 # Magnitude of fake sources relative to limit
    267270
    268271# Recipe overrides for CHIP
  • trunk/psLib/src/fits/psFits.c

    r25049 r25383  
    344344// Therefore, we implement our own version of moving to an extension specified by name.  The pure cfitsio
    345345// version is used if "conventions.compression" handling is turned off in the psFits structure.
    346 bool psFitsMoveExtName(const psFits* fits,
    347                        const char* extname)
     346static bool fitsMoveExtName(const psFits* fits, // FITS file
     347                            const char* extname, // Extension name
     348                            bool errors // Generate errors?
     349    )
    348350{
    349351    PS_ASSERT_FITS_NON_NULL(fits, false);
     
    356358        // User wants to use cfitsio.  Good luck to them!
    357359        if (fits_movnam_hdu(fits->fd, ANY_HDU, (char*)extname, 0, &status) != 0) {
    358             psFitsError(status, true, _("Could not find HDU '%s'"), extname);
     360            if (errors) {
     361                psFitsError(status, true, _("Could not find HDU '%s'"), extname);
     362            }
    359363            return false;
    360364        }
     
    378382        if (fits_movabs_hdu(fits->fd, i, &hdutype, &status)) {
    379383            // We've run off the end
    380             psFitsError(status, true, _("Could not find HDU with %s = '%s'"), extword, extname);
     384            if (errors) {
     385                psFitsError(status, true, _("Could not find HDU with %s = '%s'"), extword, extname);
     386            }
    381387            return false;
    382388        }
     
    406412    }
    407413    psAbort("Should never reach here.");
     414}
     415
     416
     417bool psFitsMoveExtName(const psFits* fits, const char* extname)
     418{
     419    return fitsMoveExtName(fits, extname, true);
     420}
     421
     422bool psFitsMoveExtNameClean(const psFits* fits, const char* extname)
     423{
     424    return fitsMoveExtName(fits, extname, false);
    408425}
    409426
  • trunk/psLib/src/fits/psFits.h

    r19035 r25383  
    245245);
    246246
     247/** Moves the FITS HDU to the specified extension name without generating errors.
     248 *
     249 *  @return bool        TRUE if the extension name was found and move was
     250 *                      successful, otherwise FALSE
     251 */
     252bool psFitsMoveExtNameClean(
     253    const psFits* fits,                ///< the psFits object to move
     254    const char* extname                ///< the extension name
     255);
     256
    247257/** Moves the FITS HDU to the specified extension number
    248258 *
  • trunk/psLib/src/imageops/psImageConvolve.c

    r24272 r25383  
    678678}
    679679
     680static bool imageSmoothMaskPixels(psVector *out, const psImage *image, const psImage *mask,
     681                                  psImageMaskType maskVal, const psVector *x, const psVector *y,
     682                                  const psVector *gaussNorm, float minGauss, int size, int start, int stop)
     683{
     684    const psF32 *gauss = &gaussNorm->data.F32[size]; // Gaussian convolution kernel
     685    int numCols = image->numCols, numRows = image->numRows; // Size of image
     686    int xLast = numCols - 1, yLast = numRows - 1; // Last index
     687    for (int i = start; i < stop; i++) {
     688        int xPix = x->data.S32[i], yPix = y->data.S32[i]; // Pixel coordinates for smoothing
     689
     690        int yMin = PS_MAX(yPix - size, 0);
     691        int yMax = PS_MIN(yPix + size, yLast);
     692        int xMin = PS_MAX(xPix - size, 0);
     693        int xMax = PS_MIN(xPix + size, xLast);
     694
     695        const float *yGauss = &gauss[yMin - yPix];
     696
     697        double ySumIG = 0.0, ySumG = 0.0;
     698        for (int v = yMin; v <= yMax; v++, yGauss++) {
     699            const float *xGauss = &gauss[xMin - xPix];
     700            double xSumIG = 0.0, xSumG = 0.0;
     701            const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[v][xMin];
     702            const psF32 *imageData = &image->data.F32[v][xMin];
     703            for (int u = xMin; u <= xMax; u++, xGauss++, imageData++, maskData++) {
     704                if (*maskData & maskVal) {
     705                    continue;
     706                }
     707                xSumIG += *imageData * *xGauss;
     708                xSumG += *xGauss;
     709            }
     710            if (xSumG > minGauss) {
     711                ySumIG += xSumIG * *yGauss;
     712                ySumG += xSumG * *yGauss;
     713            }
     714        }
     715
     716        out->data.F32[i] = ySumG > minGauss ? ySumIG / ySumG : NAN;
     717    }
     718
     719    return true;
     720}
     721
     722static bool psImageSmoothMaskPixelsThread(psThreadJob *job)
     723{
     724    PS_ASSERT_THREAD_JOB_NON_NULL(job, false);
     725    psAssert(job->args, "programming error: no job arguments");
     726    psAssert(job->args->n == 11, "programming error: wrong number of job arguments");
     727
     728    psVector *out = job->args->data[0]; // Output vector
     729    const psImage *image  = job->args->data[1]; // Input image
     730    const psImage *mask   = job->args->data[2]; // Input mask
     731    psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3], PS_TYPE_IMAGE_MASK_DATA);
     732    const psVector *x = job->args->data[4];
     733    const psVector *y = job->args->data[5];
     734    const psVector *gaussNorm = job->args->data[6];
     735    float minGauss = PS_SCALAR_VALUE(job->args->data[7], F32);
     736    int size = PS_SCALAR_VALUE(job->args->data[8], S32);
     737    int start = PS_SCALAR_VALUE(job->args->data[9], S32);
     738    int stop = PS_SCALAR_VALUE(job->args->data[10], S32);
     739    return imageSmoothMaskPixels(out, image, mask, maskVal, x, y, gaussNorm,
     740                                 minGauss, size, start, stop);
     741}
     742
     743
     744psVector *psImageSmoothMaskPixels(const psImage *image, const psImage *mask, psImageMaskType maskVal,
     745                                  const psVector *x, const psVector *y,
     746                                  float sigma, float numSigma, float minGauss)
     747{
     748    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
     749    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
     750    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
     751    PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL);
     752    PS_ASSERT_VECTOR_NON_NULL(x, NULL);
     753    PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_S32, NULL);
     754    PS_ASSERT_VECTOR_NON_NULL(y, NULL);
     755    PS_ASSERT_VECTOR_TYPE(y, PS_TYPE_S32, NULL);
     756    PS_ASSERT_VECTORS_SIZE_EQUAL(x, y, NULL);
     757
     758    int size = sigma * numSigma + 0.5;  // Half-size of kernel
     759
     760    int num = x->n;                     // Number of pixels to smooth
     761    psVector *out = psVectorAlloc(num, PS_TYPE_F32); // Output results
     762
     763    // Generate normalized gaussian
     764    IMAGE_SMOOTH_GAUSS(gaussNorm, size, sigma, F32);
     765
     766    // Columns
     767    if (threaded) {
     768        int numThreads = psThreadPoolSize(); // Number of threads
     769        int delta = (numThreads) ? num / numThreads + 1 : num; // Block of cols to do at once
     770        for (int start = 0; start < num; start += delta) {
     771            int stop = PS_MIN(start + delta, num);  // End of block
     772
     773            psThreadJob *job = psThreadJobAlloc("PSLIB_IMAGE_SMOOTHMASK_PIXELS");
     774            psArrayAdd(job->args, 1, out);
     775            psArrayAdd(job->args, 1, (psImage*)image);
     776            psArrayAdd(job->args, 1, (psImage*)mask);
     777            PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);
     778            psArrayAdd(job->args, 1, (psVector*)x);
     779            psArrayAdd(job->args, 1, (psVector*)y);
     780            psArrayAdd(job->args, 1, gaussNorm);
     781            PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32);
     782            PS_ARRAY_ADD_SCALAR(job->args, size, PS_TYPE_S32);
     783            PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32);
     784            PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32);
     785            if (!psThreadJobAddPending(job)) {
     786                psFree(job);
     787                psFree(gaussNorm);
     788                psFree(out);
     789                return NULL;
     790            }
     791            psFree(job);
     792        }
     793    } else if (!imageSmoothMaskPixels(out, image, mask, maskVal, x, y,
     794                                      gaussNorm, minGauss, size, 0, num)) {
     795        psError(PS_ERR_UNKNOWN, false, "Unable to smooth pixels.");
     796        psFree(gaussNorm);
     797        psFree(out);
     798        return NULL;
     799    }
     800
     801    if (threaded && !psThreadPoolWait(true)) {
     802        psError(PS_ERR_UNKNOWN, false, "Error waiting for threads.");
     803        psFree(gaussNorm);
     804        psFree(out);
     805        return NULL;
     806    }
     807
     808    psFree(gaussNorm);
     809    return out;
     810}
     811
     812
    680813// Smooth an image with masked pixels
    681814// The calculation and calcMask images are *deliberately* backwards (row,col instead of col,row or
     
    13251458    if (threaded) {
    13261459        int numThreads = psThreadPoolSize(); // Number of threads
    1327         int deltaRows = (numThreads) ? numRows / numThreads : numRows; // Block of rows to do at once
     1460        int deltaRows = (numThreads) ? numRows / numThreads + 1 : numRows; // Block of rows to do at once
    13281461        for (int start = 0; start < numRows; start += deltaRows) {
    1329             int stop = PS_MIN (start + deltaRows, numRows);  // end of row block
     1462            int stop = PS_MIN(start + deltaRows, numRows);  // end of row block
    13301463
    13311464            psThreadJob *job = psThreadJobAlloc("PSLIB_IMAGE_CONVOLVE_MASK");
     
    13631496    if (threaded) {
    13641497        int numThreads = psThreadPoolSize(); // Number of threads
    1365         int deltaCols = (numThreads) ? numCols / numThreads : numCols; // Block of cols to do at once
     1498        int deltaCols = (numThreads) ? numCols / numThreads + 1 : numCols; // Block of cols to do at once
    13661499        for (int start = 0; start < numCols; start += deltaCols) {
    1367             int stop = PS_MIN (start + deltaCols, numCols);  // end of col block
     1500            int stop = PS_MIN(start + deltaCols, numCols);  // end of col block
    13681501
    13691502            psThreadJob *job = psThreadJobAlloc("PSLIB_IMAGE_CONVOLVE_MASK");
     
    14861619            psFree(task);
    14871620        }
     1621        {
     1622            psThreadTask *task = psThreadTaskAlloc("PSLIB_IMAGE_SMOOTHMASK_PIXELS", 9);
     1623            task->function = &psImageSmoothMaskPixelsThread;
     1624            psThreadTaskAdd(task);
     1625            psFree(task);
     1626        }
    14881627    } else if (!set && threaded) {
    14891628        psThreadTaskRemove("PSLIB_IMAGE_CONVOLVE_MASK");
  • trunk/psLib/src/imageops/psImageConvolve.h

    r24272 r25383  
    222222    );
    223223
     224/// Smooth particular pixels on an image, allowing for masked pixels
     225///
     226/// Applies a circularly symmetric Gaussian smoothing first in x and then in y
     227/// directions with just a vector.  This process is 2N faster than 2D convolutions (in general).
     228psVector *psImageSmoothMaskPixels(
     229    const psImage *image,               ///< Input image (F32)
     230    const psImage *mask,                ///< Mask image
     231    psImageMaskType maskVal,            ///< Value to mask
     232    const psVector *x,                  ///< x coordinates
     233    const psVector *y,                  ///< y coordinates
     234    float sigma,                        ///< Width of the smoothing kernel (pixels)
     235    float numSigma,                     ///< Size of the smoothing box (sigma)
     236    float minGauss                      ///< Minimum fraction of Gaussian to accept
     237    );
    224238
    225239psImage *psImageSmoothMask_Threaded(psImage *output,
  • trunk/psLib/src/types/psMetadata.c

    r21183 r25383  
    996996    if (metadataItem->type == PS_DATA_METADATA_MULTI) {
    997997        // if multiple keys found, use the first.
    998         //        metadataItem = (psMetadataItem*)((metadataItem->data.list)->head);
    999998        metadataItem = (psMetadataItem*)(metadataItem->data.list->head->data);
    1000999        if (status) {
     
    10821081    } \
    10831082    \
    1084     /* psFree(metadataItem); currently, the lookup doesn't increment the ref count */ \
    10851083    return value; \
    10861084}
     
    11011099psMetadataLookupNumTYPE(VectorMaskType,VectorMask)
    11021100psMetadataLookupNumTYPE(ImageMaskType,ImageMask)
     1101
     1102#define psMetadataLookupPtrTYPE(TYPENAME,NAME,TYPE,VAL) \
     1103TYPENAME psMetadataLookup##NAME(bool *status, const psMetadata *md, const char *key) \
     1104{ \
     1105    PS_ASSERT_METADATA_NON_NULL(md, NULL); \
     1106    PS_ASSERT_STRING_NON_EMPTY(key, NULL); \
     1107    psMetadataItem *item = psMetadataLookup((psMetadata*)md, key); /* The item of interest */ \
     1108    if (!item) { \
     1109        if (status) { \
     1110            *status = false; \
     1111        } else { \
     1112            psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n", key); \
     1113        } \
     1114        return NULL; \
     1115    } \
     1116    \
     1117    if (item->type == PS_DATA_METADATA_MULTI) { \
     1118        /* if multiple keys found, use the first. */ \
     1119        item = item->data.list->head->data; \
     1120    } \
     1121    if (item->type != TYPE) { \
     1122        if (status) { \
     1123            *status = false; \
     1124        } else { \
     1125            psLogMsg(__func__, PS_LOG_DETAIL, "%s isn't of type PS_DATA_META, as expected.\n", key); \
     1126        } \
     1127        return NULL; \
     1128    } \
     1129    \
     1130    if (status) { \
     1131        *status = true; \
     1132    } \
     1133    return item->data.VAL; \
     1134}
     1135
     1136psMetadataLookupPtrTYPE(psMetadata*, Metadata, PS_DATA_METADATA, md)
     1137psMetadataLookupPtrTYPE(psString, Str, PS_DATA_STRING, str)
     1138psMetadataLookupPtrTYPE(psTime*, Time, PS_DATA_TIME, V)
     1139psMetadataLookupPtrTYPE(psVector*, Vector, PS_DATA_VECTOR, V)
     1140
    11031141
    11041142psMetadataItem* psMetadataGet(const psMetadata *md,
     
    12571295}
    12581296
    1259 psMetadata *psMetadataLookupMetadata(bool *status,
    1260                                      const psMetadata *md,
    1261                                      const char *key)
    1262 {
    1263     PS_ASSERT_METADATA_NON_NULL(md,NULL);
    1264     psMetadataItem *item = psMetadataLookup((psMetadata*)md, key); // The metadata with instruments
    1265     psMetadata *value = NULL;  // The value to return
    1266     if (!item) {
    1267         // The given key isn't in the metadata
    1268         if (status) {
    1269             *status = false;
    1270         } else {
    1271             psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n", key);
    1272         }
    1273     } else if (item->type != PS_DATA_METADATA) {
    1274         // The value at the key isn't metadata
    1275         if (status) {
    1276             *status = false;
    1277         } else {
    1278             psLogMsg(__func__, PS_LOG_DETAIL, "%s isn't of type PS_DATA_META, as expected.\n", key);
    1279         }
    1280         //        value = NULL;
    1281     } else {
    1282         // We have the requested metadata
    1283         if (status) {
    1284             *status = true;
    1285         }
    1286         value = item->data.md; // The requested metadata
    1287     }
    1288     return value;
    1289 }
    1290 
    1291 psTime *psMetadataLookupTime(bool *status,
    1292                              const psMetadata *md,
    1293                              const char *key)
    1294 {
    1295     PS_ASSERT_METADATA_NON_NULL(md,NULL);
    1296 
    1297     psMetadataItem *item = psMetadataLookup((psMetadata*)md, key);
    1298     if (!item) {
    1299         // The given key isn't in the metadata
    1300         if (status) {
    1301             *status = false;
    1302         } else {
    1303             psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n", key);
    1304         }
    1305         return NULL;
    1306     }
    1307 
    1308     if (item->type != PS_DATA_TIME) {
    1309         // The value at the key isn't metadata
    1310         if (status) {
    1311             *status = false;
    1312         } else {
    1313             psLogMsg(__func__, PS_LOG_DETAIL, "%s isn't of type PS_DATA_TIME, as expected.\n", key);
    1314         }
    1315         return NULL;
    1316     }
    1317 
    1318     // We have the requested metadata
    1319     if (status) {
    1320         *status = true;
    1321     }
    1322 
    1323     return item->data.V;
    1324 }
    1325 
    1326 
    1327 psString psMetadataLookupStr(bool *status,
    1328                              const psMetadata *md,
    1329                              const char *key)
    1330 {
    1331     PS_ASSERT_METADATA_NON_NULL(md,NULL);
    1332 
    1333     psMetadataItem *item = psMetadataLookup((psMetadata*)md, key); // The metadata with instruments
    1334     //    char *value = NULL;   // The value to return
    1335     psString value = NULL;
    1336     if (!item) {
    1337         // The given key isn't in the metadata
    1338         if (status) {
    1339             *status = false;
    1340         } else {
    1341             psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n", key);
    1342         }
    1343     } else if (item->type != PS_DATA_STRING) {
    1344         // The value at the key isn't of the desired type
    1345         if (status) {
    1346             *status = false;
    1347         } else {
    1348             psLogMsg(__func__, PS_LOG_DETAIL, "%s isn't of type PS_DATA_STRING, as expected.\n", key);
    1349         }
    1350         //        value = NULL;
    1351     } else {
    1352         // We have the requested metadata
    1353         if (status) {
    1354             *status = true;
    1355         }
    1356         value = item->data.V;
    1357     }
    1358     return value;
    1359 }
     1297
     1298
     1299
    13601300
    13611301psList *psMetadataKeys(psMetadata *md)
  • trunk/psLib/src/types/psMetadata.h

    r23148 r25383  
    717717PS_METADATA_LOOKUP_TYPE_DECL(Ptr, psPtr);
    718718PS_METADATA_LOOKUP_TYPE_DECL(Str, psString);
     719PS_METADATA_LOOKUP_TYPE_DECL(Vector, psVector*);
    719720PS_METADATA_LOOKUP_TYPE_DECL(Metadata, psMetadata*);
    720721PS_METADATA_LOOKUP_TYPE_DECL(Time, psTime*);
  • trunk/psModules/src/camera/pmFPAMosaic.c

    r21363 r25383  
    740740static bool chipMosaic(psImage **mosaicImage, // The mosaic image, to be returned
    741741                       psImage **mosaicMask, // The mosaic mask, to be returned
    742                        psImage **mosaicVariances, // The mosaic variances, to be returned
     742                       psImage **mosaicVariance, // The mosaic variance, to be returned
    743743                       int *xBinChip, int *yBinChip, // The binning in x and y, to be returned
    744744                       const pmChip *chip, // Chip to mosaic
     
    749749    assert(mosaicImage);
    750750    assert(mosaicMask);
    751     assert(mosaicVariances);
     751    assert(mosaicVariance);
    752752    assert(xBinChip);
    753753    assert(yBinChip);
     
    826826    if (allGood) {
    827827        *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE);
    828         *mosaicVariances = imageMosaic(variances, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE);
     828        *mosaicVariance = imageMosaic(variances, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE);
    829829        *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, blank);
    830830    }
     
    847847static bool fpaMosaic(psImage **mosaicImage, // The mosaic image, to be returned
    848848                      psImage **mosaicMask, // The mosaic mask, to be returned
    849                       psImage **mosaicVariances, // The mosaic variances, to be returned
     849                      psImage **mosaicVariance, // The mosaic variance, to be returned
    850850                      int *xBinFPA, int *yBinFPA, // The binning in x and y, to be returned
    851851                      const pmFPA *fpa,  // FPA to mosaic
     
    857857    assert(mosaicImage);
    858858    assert(mosaicMask);
    859     assert(mosaicVariances);
     859    assert(mosaicVariance);
    860860    assert(xBinFPA);
    861861    assert(yBinFPA);
     
    960960    if (allGood) {
    961961        *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE);
    962         *mosaicVariances = imageMosaic(variances, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE);
     962        *mosaicVariance = imageMosaic(variances, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE);
    963963        *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, blank);
    964964    }
     
    10251025    psImage *mosaicImage   = NULL;      // The mosaic image
    10261026    psImage *mosaicMask    = NULL;      // The mosaic mask
    1027     psImage *mosaicVariances = NULL;      // The mosaic variances
     1027    psImage *mosaicVariance = NULL;      // The mosaic variances
    10281028
    10291029    // Find the HDU
     
    10521052        }
    10531053        if (hdu->variances) {
    1054             mosaicVariances = psImageSubset(hdu->variances->data[0], bounds);
    1055             if (!mosaicVariances) {
     1054            mosaicVariance = psImageSubset(hdu->variances->data[0], bounds);
     1055            if (!mosaicVariance) {
    10561056                psError(PS_ERR_UNKNOWN, false, "Unable to select variance pixels.\n");
    10571057                return false;
     
    10611061        // Case 2 --- we need to mosaic by cut and paste
    10621062        psTrace("psModules.camera", 1, "Case 2 mosaicking: cut and paste.\n");
    1063         if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicVariances, &xBin, &yBin, source, targetCell, blank)) {
     1063        if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicVariance, &xBin, &yBin, source, targetCell, blank)) {
    10641064            psError(PS_ERR_UNKNOWN, false, "Unable to mosaic cells.\n");
    10651065            return false;
     
    10691069    }
    10701070    psTrace("psModules.camera", 1, "xBin,yBin: %d,%d\n", xBin, yBin);
     1071
    10711072
    10721073    // Set the concepts for the target cell
     
    10901091    target->parent->concepts = psMetadataCopy(target->parent->concepts, source->parent->concepts); // FPA lvl
    10911092
     1093    // Average the covariances
     1094    psList *covariances = psListAlloc(NULL); // Input covariance matrices
     1095    for (int i = 0; i < source->cells->n; i++) {
     1096        pmCell *cell = source->cells->data[i]; // Cell of interest
     1097        if (!cell || !cell->data_exists) {
     1098            continue;
     1099        }
     1100        pmReadout *ro = cell->readouts->data[0]; // Readout of interest
     1101        if (!ro || !ro->covariance) {
     1102            continue;
     1103        }
     1104        psListAdd(covariances, PS_LIST_TAIL, ro->covariance);
     1105    }
     1106    psKernel *mosaicCovariance = NULL;  // Covariance for mosaic
     1107    if (psListLength(covariances) > 0) {
     1108        psArray *covarArray = psListToArray(covariances); // Array with covariances
     1109        mosaicCovariance = psImageCovarianceAverage(covarArray);
     1110        psFree(covarArray);
     1111    }
     1112    psFree(covariances);
     1113
    10921114    // Now make a new readout to go in the target cell
    10931115    pmReadout *newReadout = pmReadoutAlloc(targetCell); // New readout
    10941116    newReadout->image  = mosaicImage;
    10951117    newReadout->mask   = mosaicMask;
    1096     newReadout->variance = mosaicVariances;
     1118    newReadout->variance = mosaicVariance;
     1119    newReadout->covariance = mosaicCovariance;
    10971120    psFree(newReadout);                 // Drop reference
    10981121
     
    13341357    target->concepts = psMetadataCopy(target->concepts, source->concepts);
    13351358
     1359    // Average the covariances
     1360    psList *covariances = psListAlloc(NULL); // Input covariance matrices
     1361    for (int i = 0; i < covariances->n; i++) {
     1362        pmChip *chip = chips->data[i];  // Chip of interest
     1363        if (!chip || !chip->data_exists) {
     1364            continue;
     1365        }
     1366        psArray *cells = chip->cells;   // Cells in chip
     1367        for (long j = 0; j < cells->n; j++) {
     1368            pmCell *cell = cells->data[i]; // Cell of interest
     1369            if (!cell || !cell->data_exists) {
     1370                continue;
     1371            }
     1372            pmReadout *ro = cell->readouts->data[0]; // Readout of interest
     1373            if (!ro || !ro->covariance) {
     1374                continue;
     1375            }
     1376            psListAdd(covariances, PS_LIST_TAIL, ro->covariance);
     1377        }
     1378    }
     1379    psKernel *mosaicCovariances = NULL; // Covariance for mosaic
     1380    if (psListLength(covariances) > 0) {
     1381        psArray *covarArray = psListToArray(covariances); // Array with covariances
     1382        mosaicCovariances = psImageCovarianceAverage(covarArray);
     1383        psFree(covarArray);
     1384    }
     1385    psFree(covariances);
     1386
    13361387    // Now make a new readout to go in the new cell
    13371388    pmReadout *newReadout = pmReadoutAlloc(targetCell); // New readout
     
    13391390    newReadout->mask   = mosaicMask;
    13401391    newReadout->variance = mosaicVariances;
     1392    newReadout->covariance = mosaicCovariances;
    13411393    psFree(newReadout);                 // Drop reference
    13421394
  • trunk/psModules/src/camera/pmReadoutFake.c

    r25324 r25383  
    8282    }
    8383    PS_ASSERT_PTR_NON_NULL(psf, false);
    84     if (radius > 0 && isfinite(minFlux) && minFlux > 0.0) {
    85         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Cannot define both minimum flux and fixed radius.");
    86         return false;
    87     }
    8884
    8985    readout->image = psImageRecycle(readout->image, numCols, numRows, PS_TYPE_F32);
     
    128124        pmSource *fakeSource = pmSourceAlloc(); // Fake source to generate
    129125        fakeSource->peak = pmPeakAlloc(xSrc, ySrc, fakeModel->params->data.F32[PM_PAR_I0], PM_PEAK_LONE);
    130         float fakeRadius = radius > 0 ? radius :
    131             PS_MAX(1.0, fakeModel->modelRadius(fakeModel->params, minFlux)); // Radius of fake source
     126        float fakeRadius = 1.0;         // Radius of fake source
     127        if (isfinite(minFlux)) {
     128            fakeRadius = PS_MAX(fakeRadius, fakeModel->modelRadius(fakeModel->params, minFlux));
     129        }
     130        if (radius > 0) {
     131            fakeRadius = PS_MAX(fakeRadius, radius);
     132        }
    132133
    133134        if (xOffset) {
  • trunk/psModules/src/camera/pmReadoutFake.h

    r25313 r25383  
    1313#include <pmSourceMasks.h>
    1414
     15/// Generate a fake readout from vectors
     16bool pmReadoutFakeFromVectors(pmReadout *readout, ///< Output readout
     17                              int numCols, int numRows, ///< Dimension of image
     18                              const psVector *x, const psVector *y, ///< Source coordinates
     19                              const psVector *mag, ///< Source magnitudes
     20                              const psVector *xOffset, ///< x offsets for sources (source -> img), or NULL
     21                              const psVector *yOffset, ///< y offsets for sources (source -> img), or NULL
     22                              const pmPSF *psf, ///< PSF for sources
     23                              float minFlux, ///< Minimum flux to bother about; for setting source radius
     24                              int radius, ///< Fixed radius for sources
     25                              bool circularise, ///< Circularise PSF model?
     26                              bool normalisePeak ///< Normalise the peak value?
     27    );
     28
    1529/// Generate a fake readout from an array of sources
    16 bool pmReadoutFakeFromSources(pmReadout *readout, ///< Output readout, or NULL
     30bool pmReadoutFakeFromSources(pmReadout *readout, ///< Output readout
    1731                              int numCols, int numRows, ///< Dimension of image
    1832                              const psArray *sources, ///< Array of pmSource
  • trunk/psModules/src/objects/Makefile.am

    r24875 r25383  
    5353        pmGrowthCurveGenerate.c \
    5454        pmGrowthCurve.c \
    55         pmSourceMatch.c
     55        pmSourceMatch.c \
     56        pmDetEff.c
    5657
    5758EXTRA_DIST = \
     
    9091        pmTrend2D.h \
    9192        pmGrowthCurve.h \
    92         pmSourceMatch.h
     93        pmSourceMatch.h \
     94        pmDetEff.h
    9395
    9496CLEANFILES = *~
  • trunk/psModules/src/objects/pmSourceIO.c

    r24694 r25383  
    4242#include "pmSource.h"
    4343#include "pmModelClass.h"
     44#include "pmDetEff.h"
    4445#include "pmSourceIO.h"
    4546
    4647#define BLANK_HEADERS "BLANK.HEADERS"   // Name of metadata in camera configuration containing header names
    4748                                        // for putting values into a blank PHU
     49
     50// lookup the EXTNAME values used for table data and image header segments
     51static bool sourceExtensions(psString *headname, // Extension name for header
     52                             psString *dataname, // Extension name for data
     53                             psString *deteffname, // Extension name for detection efficiency
     54                             psString *xsrcname, // Extension name for extended sources
     55                             psString *xfitname, // Extension name for extended fits
     56                             const pmFPAfile *file, // File of interest
     57                             const pmFPAview *view // View to level of interest
     58                             )
     59{
     60    bool status;                        // Status of MD lookup
     61
     62    // Menu of EXTNAME rules
     63    psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
     64    if (!menu) {
     65        psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
     66        return false;
     67    }
     68
     69    // EXTNAME for image header
     70    if (headname) {
     71        const char *rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
     72        if (!rule) {
     73            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
     74            return false;
     75        }
     76        *headname = pmFPAfileNameFromRule(rule, file, view);
     77    }
     78
     79    // EXTNAME for table data
     80    if (dataname) {
     81        const char *rule = psMetadataLookupStr(&status, menu, "CMF.DATA");
     82        if (!rule) {
     83            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
     84            return false;
     85        }
     86        *dataname = pmFPAfileNameFromRule(rule, file, view);
     87    }
     88
     89    // EXTNAME for detection efficiency
     90    if (deteffname) {
     91        const char *rule = psMetadataLookupStr(&status, menu, "CMF.DETEFF");
     92        if (!rule) {
     93            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DETEFF in EXTNAME.RULES in camera.config");
     94            return false;
     95        }
     96        *deteffname = pmFPAfileNameFromRule(rule, file, view);
     97    }
     98
     99    // EXTNAME for extended source data table
     100    if (xsrcname) {
     101        const char *rule = psMetadataLookupStr(&status, menu, "CMF.XSRC");
     102        if (!rule) {
     103            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XSRC in EXTNAME.RULES in camera.config");
     104            return false;
     105        }
     106        *xsrcname = pmFPAfileNameFromRule (rule, file, view);
     107    }
     108
     109    if (xfitname) {
     110        // EXTNAME for extended source data table
     111        const char *rule = psMetadataLookupStr(&status, menu, "CMF.XFIT");
     112        if (!rule) {
     113            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XFIT in EXTNAME.RULES in camera.config");
     114            return false;
     115        }
     116        *xfitname = pmFPAfileNameFromRule (rule, file, view);
     117    }
     118
     119    return true;
     120}
     121
    48122
    49123// translations between psphot object types and dophot object types
     
    271345
    272346    char *exttype  = NULL;
    273     char *dataname = NULL;
    274     char *xsrcname = NULL;
    275     char *xfitname = NULL;
    276     char *headname = NULL;
    277347
    278348    // if sources is NULL, write out an empty table
     
    354424
    355425        // define the EXTNAME values for the different data segments:
    356         {
    357             // lookup the EXTNAME values used for table data and image header segments
    358             char *rule = NULL;
    359 
    360             // Menu of EXTNAME rules
    361             psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
    362             if (!menu) {
    363                 psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
    364                 return false;
    365             }
    366 
    367             // EXTNAME for image header
    368             rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
    369             if (!rule) {
    370                 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
    371                 return false;
    372             }
    373             headname = pmFPAfileNameFromRule (rule, file, view);
    374 
    375             // EXTNAME for table data
    376             rule = psMetadataLookupStr(&status, menu, "CMF.DATA");
    377             if (!rule) {
    378                 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
    379                 return false;
    380             }
    381             dataname = pmFPAfileNameFromRule (rule, file, view);
    382 
    383             if (XSRC_OUTPUT) {
    384               // EXTNAME for extended source data table
    385               rule = psMetadataLookupStr(&status, menu, "CMF.XSRC");
    386               if (!rule) {
    387                 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XSRC in EXTNAME.RULES in camera.config");
    388                 return false;
    389               }
    390               xsrcname = pmFPAfileNameFromRule (rule, file, view);
    391             }
    392             if (XFIT_OUTPUT) {
    393               // EXTNAME for extended source data table
    394               rule = psMetadataLookupStr(&status, menu, "CMF.XFIT");
    395               if (!rule) {
    396                 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XFIT in EXTNAME.RULES in camera.config");
    397                 return false;
    398               }
    399               xfitname = pmFPAfileNameFromRule (rule, file, view);
    400             }
     426        psString headname = NULL;
     427        psString dataname = NULL;
     428        psString deteffname = NULL;
     429        psString xsrcname = NULL;
     430        psString xfitname = NULL;
     431        if (!sourceExtensions(&headname, &dataname, &deteffname, XSRC_OUTPUT ? &xsrcname : NULL,
     432                              XFIT_OUTPUT ? &xfitname : NULL, file, view)) {
     433            return false;
    401434        }
    402435
     
    480513
    481514            // XXX these are case-sensitive since the EXTYPE is case-sensitive
    482             status = false;
     515            status = true;
    483516            if (!strcmp (exttype, "SMPDATA")) {
    484                 status = pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname);
     517                status &= pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname);
    485518            }
    486519            if (!strcmp (exttype, "PS1_DEV_0")) {
    487                 status = pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname);
     520                status &= pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname);
    488521            }
    489522            if (!strcmp (exttype, "PS1_DEV_1")) {
    490                 status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname);
     523                status &= pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname);
    491524            }
    492525            if (!strcmp (exttype, "PS1_CAL_0")) {
    493                 status = pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname);
     526                status &= pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname);
    494527            }
    495528            if (!strcmp (exttype, "PS1_V1")) {
    496                 status = pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname);
     529                status &= pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname);
    497530            }
    498531            if (!strcmp (exttype, "PS1_V2")) {
    499                 status = pmSourcesWrite_CMF_PS1_V2 (file->fits, readout, sources, file->header, outhead, dataname);
    500             }
     532                status &= pmSourcesWrite_CMF_PS1_V2 (file->fits, readout, sources, file->header, outhead, dataname);
     533            }
     534
     535            if (deteffname) {
     536                status &= pmReadoutWriteDetEff(file->fits, readout, outhead, deteffname);
     537            }
     538
    501539            if (xsrcname) {
    502540              if (!strcmp (exttype, "PS1_DEV_1")) {
    503                   status = pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname, recipe);
     541                  status &= pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname, recipe);
    504542              }
    505543              if (!strcmp (exttype, "PS1_CAL_0")) {
    506                   status = pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
     544                  status &= pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
    507545              }
    508546              if (!strcmp (exttype, "PS1_V1")) {
    509                   status = pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe);
     547                  status &= pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe);
    510548              }
    511549              if (!strcmp (exttype, "PS1_V2")) {
    512                   status = pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe);
     550                  status &= pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe);
    513551              }
    514552            }
    515553            if (xfitname) {
    516554              if (!strcmp (exttype, "PS1_DEV_1")) {
    517                   status = pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);
     555                  status &= pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);
    518556              }
    519557              if (!strcmp (exttype, "PS1_CAL_0")) {
    520                   status = pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname);
     558                  status &= pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname);
    521559              }
    522560              if (!strcmp (exttype, "PS1_V1")) {
    523                   status = pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname);
     561                  status &= pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname);
    524562              }
    525563              if (!strcmp (exttype, "PS1_V2")) {
    526                   status = pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname);
     564                  status &= pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname);
    527565              }
    528566            }
     
    572610    // not needed if only one chip
    573611    if (file->fpa->chips->n == 1) {
    574         pmSourceIO_WriteMatchedRefs (file->fits, file->fpa, config);
    575         return true;
     612        pmSourceIO_WriteMatchedRefs (file->fits, file->fpa, config);
     613        return true;
    576614    }
    577615
     
    885923        hdu = pmFPAviewThisHDU (view, file->fpa);
    886924
    887         // lookup the EXTNAME values used for table data and image header segments
    888         char *rule = NULL;
    889         // Menu of EXTNAME rules
    890         psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
    891         if (!menu) {
    892             psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
    893             return false;
    894         }
    895         // EXTNAME for image header
    896         rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
    897         if (!rule) {
    898             psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
    899             return false;
    900         }
    901         char *headname = pmFPAfileNameFromRule (rule, file, view);
    902         // EXTNAME for table data
    903         rule = psMetadataLookupStr(&status, menu, "CMF.DATA");
    904         if (!rule) {
    905             psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
    906             return false;
    907         }
    908         char *dataname = pmFPAfileNameFromRule (rule, file, view);
     925        // define the EXTNAME values for the different data segments:
     926        psString headname = NULL;
     927        psString dataname = NULL;
     928        psString deteffname = NULL;
     929        if (!sourceExtensions(&headname, &dataname, &deteffname, NULL, NULL, file, view)) {
     930            return false;
     931        }
    909932
    910933        // advance to the IMAGE HEADER extension
     
    958981                sources = pmSourcesRead_CMF_PS1_V2 (file->fits, hdu->header);
    959982            }
     983
     984            if (!pmReadoutReadDetEff(file->fits, readout, deteffname)) {
     985                psError(PS_ERR_IO, false, "Unable to read detection efficiency");
     986                return false;
     987            }
    960988        }
    961989
     
    10701098}
    10711099
    1072    
     1100
  • trunk/psModules/src/psmodules.h

    r24891 r25383  
    133133#include <pmSourceVisual.h>
    134134#include <pmSourceMatch.h>
     135#include <pmDetEff.h>
    135136
    136137// The following headers are from random locations, here because they cross bounds
  • trunk/psphot/doc/efficiency.txt

  • trunk/psphot/src/Makefile.am

    r24586 r25383  
    128128        psphotCheckStarDistribution.c  \
    129129        psphotThreadTools.c            \
    130         psphotAddNoise.c
     130        psphotAddNoise.c               \
     131        psphotEfficiency.c
    131132
    132133# dropped? psphotGrowthCurve.c
  • trunk/psphot/src/psphot.h

    r24890 r25383  
    4949bool            psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf);
    5050bool            psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources);
    51 bool            psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final);
     51bool            psphotFitSourcesLinear (pmReadout *readout, psArray *sources, const psMetadata *recipe, const pmPSF *psf, bool final);
    5252bool            psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal);
    5353
    5454bool            psphotReplaceAllSources (psArray *sources, psMetadata *recipe);
    55 bool            psphotRemoveAllSources (psArray *sources, psMetadata *recipe);
     55bool            psphotRemoveAllSources (const psArray *sources, const psMetadata *recipe);
    5656
    5757bool            psphotBlendFit (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);
     
    6464bool            psphotGuessModel_Threaded (psThreadJob *job);
    6565
    66 bool            psphotMagnitudes (pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, pmPSF *psf);
     66bool            psphotMagnitudes (pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, const pmPSF *psf);
    6767bool            psphotMagnitudes_Threaded (psThreadJob *job);
    6868
     
    7676bool            psphotExtendedSourceAnalysis (pmReadout *readout, psArray *sources, psMetadata *recipe);
    7777bool            psphotExtendedSourceFits (pmReadout *readout, psArray *sources, psMetadata *recipe);
     78bool            psphotEfficiency(pmConfig *config, pmReadout *readout, const pmFPAview *view, const pmPSF *psf, psMetadata *recipe, const psArray *realSources);
    7879
    7980// thread-related:
     
    147148pmPSF          *psphotLoadPSF (pmConfig *config, const pmFPAview *view, psMetadata *recipe);
    148149bool            psphotSetHeaderNstars (psMetadata *recipe, psArray *sources);
    149 bool            psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe);
    150 bool            psphotSubNoise (pmReadout *readout, psArray *sources, psMetadata *recipe);
    151 bool            psphotAddOrSubNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add);
     150bool            psphotAddNoise (pmReadout *readout, const psArray *sources, const psMetadata *recipe);
     151bool            psphotSubNoise (pmReadout *readout, const psArray *sources, const psMetadata *recipe);
     152bool            psphotAddOrSubNoise (pmReadout *readout, const psArray *sources, const psMetadata *recipe, bool add);
    152153bool            psphotRadialPlot (int *kapa, const char *filename, pmSource *source);
    153154bool            psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe);
  • trunk/psphot/src/psphotAddNoise.c

    r21519 r25383  
    11# include "psphotInternal.h"
    22
    3 bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe) {
     3bool psphotAddNoise (pmReadout *readout, const psArray *sources, const psMetadata *recipe) {
    44  return psphotAddOrSubNoise (readout, sources, recipe, true);
    55}
    66
    7 bool psphotSubNoise (pmReadout *readout, psArray *sources, psMetadata *recipe) {
     7bool psphotSubNoise (pmReadout *readout, const psArray *sources, const psMetadata *recipe) {
    88  return psphotAddOrSubNoise (readout, sources, recipe, false);
    99}
    1010
    11 bool psphotAddOrSubNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add) {
     11bool psphotAddOrSubNoise (pmReadout *readout, const psArray *sources, const psMetadata *recipe, bool add) {
    1212
    1313    bool status = false;
     
    4242    PS_ASSERT (status, false);
    4343    if (isfinite(GAIN)) {
    44         FACTOR /= GAIN;
     44        FACTOR /= GAIN;
    4545    }
    4646
     
    7070        oldshape.sxy = PAR[PM_PAR_SXY];
    7171
    72         // XXX can this be done more intelligently?
    73         if (oldI0 == 0.0) continue;
    74         if (!isfinite(oldI0)) continue;
     72        // XXX can this be done more intelligently?
     73        if (oldI0 == 0.0) continue;
     74        if (!isfinite(oldI0)) continue;
    7575
    7676        // increase size and height of source
  • trunk/psphot/src/psphotFake.c

  • trunk/psphot/src/psphotFitSourcesLinear.c

    r23445 r25383  
    1212static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psImageMaskType markVal);
    1313
    14 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final) {
     14bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, const psMetadata *recipe, const pmPSF *psf, bool final) {
    1515
    1616    bool status;
  • trunk/psphot/src/psphotMagnitudes.c

    r23349 r25383  
    11# include "psphotInternal.h"
    22
    3 bool psphotMagnitudes(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, pmPSF *psf) {
     3bool psphotMagnitudes(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, const pmPSF *psf) {
    44
    55    bool status = false;
     
    6464
    6565            psArrayAdd(job->args, 1, cells->data[j]); // sources
    66             psArrayAdd(job->args, 1, psf);
     66            psArrayAdd(job->args, 1, (pmPSF*)psf);    // Casting away const
    6767            psArrayAdd(job->args, 1, binning);
    6868            psArrayAdd(job->args, 1, backModel);
  • trunk/psphot/src/psphotReadout.c

    r24890 r25383  
    6161    // display the backsub and backgnd images
    6262    psphotVisualShowBackground (config, view, readout);
    63    
     63
    6464    // run a single-model test if desired (exits from here if test is run)
    6565    psphotModelTest (config, view, recipe);
     
    224224    psphotMagnitudes(config, readout, view, sources, psf);
    225225
     226    if (!psphotEfficiency(config, readout, view, psf, recipe, sources)) {
     227        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
     228        psErrorClear();
     229    }
     230
    226231    // replace failed sources?
    227232    // psphotReplaceUnfitSources (sources);
  • trunk/psphot/src/psphotReadoutMinimal.c

    r24890 r25383  
    9797    psphotMagnitudes(config, readout, view, sources, psf);
    9898
     99    if (!psphotEfficiency(config, readout, view, psf, recipe, sources)) {
     100        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
     101        psErrorClear();
     102    }
     103
    99104    // drop the references to the image pixels held by each source
    100105    psphotSourceFreePixels (sources);
  • trunk/psphot/src/psphotReplaceUnfit.c

    r21519 r25383  
    4747}
    4848
    49 bool psphotRemoveAllSources (psArray *sources, psMetadata *recipe) {
     49bool psphotRemoveAllSources (const psArray *sources, const psMetadata *recipe) {
    5050
    5151    bool status;
  • trunk/psphot/src/psphotSignificanceImage.c

    r21407 r25383  
    2222    }
    2323
    24     bool status_x, status_y;
    25     float FWHM_X = psMetadataLookupF32 (&status_x, recipe, "FWHM_X");
    26     float FWHM_Y = psMetadataLookupF32 (&status_y, recipe, "FWHM_Y");
    27     if (status_x && status_y) {
    28       // if we know the FHWM, use that to set the smoothing kernel (XXX allow an optional override?)
    29       SIGMA_SMTH  = 0.5*(FWHM_X + FWHM_Y) / (2.0*sqrt(2.0*log(2.0)));
    30       NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
    31       guess = false;
     24    bool statusMajor, statusMinor;
     25    float fwhmMajor = psMetadataLookupF32(&statusMajor, recipe, "FWHM_MAJ");
     26    float fwhmMinor = psMetadataLookupF32(&statusMinor, recipe, "FWHM_MIN");
     27    if (statusMajor && statusMinor) {
     28        // if we know the FHWM, use that to set the smoothing kernel (XXX allow an optional override?)
     29        if (!isfinite(fwhmMajor) || !isfinite(fwhmMinor) || fwhmMajor == 0.0 || fwhmMinor == 0.0) {
     30            psWarning("fwhmMajor (%f) or fwhmMinor (%f) is bad!", fwhmMajor, fwhmMinor);
     31        }
     32        SIGMA_SMTH  = 0.5*(fwhmMajor + fwhmMinor) / (2.0*sqrt(2.0*log(2.0)));
     33        NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
     34        guess = false;
    3235    } else {
    33       // if we do not know the FWHM, use the guess smoothing kernel supplied.
    34       // it is a configuration error if these are not supplied
    35       SIGMA_SMTH  = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA");
    36       PS_ASSERT (status, NULL);
    37       NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
    38       PS_ASSERT (status, NULL);
    39       guess = true;
     36        // if we do not know the FWHM, use the guess smoothing kernel supplied.
     37        // it is a configuration error if these are not supplied
     38        SIGMA_SMTH  = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA");
     39        PS_ASSERT (status, NULL);
     40        NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
     41        PS_ASSERT (status, NULL);
     42        guess = true;
    4043    }
    4144    // record the actual smoothing sigma
Note: See TracChangeset for help on using the changeset viewer.