IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30772


Ignore:
Timestamp:
Mar 1, 2011, 6:21:28 PM (15 years ago)
Author:
eugene
Message:

fix threading for psphotStack; use standard PS_ARGUMENTS_ macros for ppSub, ppStack, pswarp, ppImage, psphotStack; fix FPA.EXPOSURE in ppImageAddNoise; fix accounting for psf bad and poor weights; added flags for substantial poor masks due to each poor mask bit type; fix the measurement of the fwhm in pmPSFtoFWHM

Location:
branches/eam_branches/ipp-20110213
Files:
37 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/ippconfig/gpc1/camera.config

    r29921 r30772  
    133133  CMF.DATA STR {CHIP.NAME}.psf # use .PSF and .EXT?
    134134  CMF.XSRC STR {CHIP.NAME}.xsrc # use .PSF and .EXT?
     135  CMF.XRAD STR {CHIP.NAME}.xrad # use .PSF and .EXT?
    135136  CMF.XFIT STR {CHIP.NAME}.xfit # use .PSF and .EXT?
    136137  CMF.DETEFF STR {CHIP.NAME}.deteff
  • branches/eam_branches/ipp-20110213/ppImage/src/ppImageAddNoise.c

    r30680 r30772  
    9090  // Update the metadata about exposure time
    9191  psMetadataAddF32(inReadout->parent->concepts, PS_LIST_TAIL, "CELL.EXPOSURE", PS_META_REPLACE, "the modified exposure time", expTimes3Pi[band]);
     92  psMetadataAddF32(inReadout->parent->concepts, PS_LIST_TAIL, "FPA.EXPOSURE", PS_META_REPLACE, "the modified exposure time", expTimes3Pi[band]);
    9293  psMetadataAddF32(fpa->concepts, PS_LIST_TAIL, "EXPTIME", PS_META_REPLACE, "the modified exposure time", expTimes3Pi[band]);
    9394  ppImageRandomGaussianFree();
  • branches/eam_branches/ipp-20110213/ppImage/src/ppImageArguments.c

    r29833 r30772  
    5555    }
    5656
     57    // generic arguments (version -- ignored in this case, dumpconfig)
     58    PS_ARGUMENTS_GENERIC( psphot, config, argc, argv );
     59
     60    // thread arguments
     61    PS_ARGUMENTS_THREADS( psphot, config, argc, argv )
     62
    5763    // save the following additional recipe values based on command-line options
    5864    // these options override the PPIMAGE recipe values loaded from recipe files
     
    8490        psArgumentRemove(argnum, &argc, argv);
    8591        pmVisualSetVisual(true);
    86     }
    87 
    88     // Number of threads
    89     if ((argnum = psArgumentGet(argc, argv, "-threads"))) {
    90         psArgumentRemove(argnum, &argc, argv);
    91         int nThreads = atoi(argv[argnum]);
    92         psMetadataAddS32(config->arguments, PS_LIST_TAIL, "NTHREADS", 0, "number of warp threads", nThreads);
    93         psArgumentRemove(argnum, &argc, argv);
    94 
    95         // create the thread pool with number of desired threads, supplying our thread launcher function
    96         // XXX need to determine the number of threads from the config data
    97         psThreadPoolInit (nThreads);
    9892    }
    9993
     
    152146    }
    153147
    154     if ((argnum = psArgumentGet(argc, argv, "-dumpconfig"))) {
    155         psArgumentRemove(argnum, &argc, argv);
    156         psMetadataAddStr(config->arguments, PS_LIST_TAIL, "DUMP_CONFIG", PS_META_REPLACE,
    157                          "Filename for configuration dump", argv[argnum]);
    158         psArgumentRemove(argnum, &argc, argv);
    159     }
    160 
    161148    if (argc != 2) usage ();
    162149
  • branches/eam_branches/ipp-20110213/ppStack/src/ppStackArguments.c

    r30620 r30772  
    110110{
    111111    assert(config);
     112
     113    // generic arguments (version, dumpconfig)
     114    PS_ARGUMENTS_GENERIC( ppStack, config, argc, argv );
     115
     116    // thread arguments
     117    PS_ARGUMENTS_THREADS( ppStack, config, argc, argv )
    112118
    113119    {
     
    181187    psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-variance", 0, "Suffix for temporary variance maps", NULL);
    182188    psMetadataAddBool(arguments, PS_LIST_TAIL, "-temp-delete", 0, "Delete temporary files on completion?", false);
    183     psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Number of threads to use", 0);
    184189    psMetadataAddBool(arguments, PS_LIST_TAIL, "-visual", 0, "visualisation", false);
    185190
     
    238243    valueArgStr(arguments, "-stats", "STATS", arguments);
    239244
    240     int numThreads = psMetadataLookupS32(NULL, arguments, "-threads"); // Number of threads
    241     if (numThreads > 0 && !psThreadPoolInit(numThreads)) {
    242         psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to setup %d threads", numThreads);
    243         return false;
    244     }
    245 
    246245    psMetadataAddBool(arguments, PS_LIST_TAIL, "PPSTACK.DEBUG.STACK", 0,
    247246                      "Read old convolved images to debug stack?", debugStack);
  • branches/eam_branches/ipp-20110213/ppStack/src/ppStackFiles.c

    r30620 r30772  
    6565    for (int i = 0; i < numLeaks; i++) {
    6666        psMemBlock *mb = leaks[i];
    67         fprintf(memFile, "%12lu\t%12zd\t%s:%d\n", mb->id, mb->userMemorySize,
    68                 mb->file, mb->lineno);
     67        fprintf(memFile, "%12lu\t%12zd\t%s:%d\n", mb->id, mb->userMemorySize, mb->file, mb->lineno);
    6968        total += mb->userMemorySize;
    7069    }
     
    7574    num++;
    7675}
    77 
    78 
    7976
    8077// Activate/deactivate a list of files
  • branches/eam_branches/ipp-20110213/ppStack/src/ppStackLoop.c

    r30620 r30772  
    5555    }
    5656
    57     // Start threading
    58     ppStackThreadInit();
     57    // Define threading elements
    5958    ppStackThreadData *stack = ppStackThreadDataSetup(options, config, true);
    6059    if (!stack) {
  • branches/eam_branches/ipp-20110213/ppStack/src/ppStackMatch.c

    r30684 r30772  
    142142    bool mdok;                          // Status of MD lookup
    143143    float penalty = psMetadataLookupF32(NULL, ppsub, "PENALTY"); // Penalty for wideness
    144     int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads
     144    int threads = psMetadataLookupS32(NULL, config->arguments, "NTHREADS"); // Number of threads
    145145
    146146    // Replaced pmReadoutMaskNonfinite with pmReadoutMaskInvalid (tests for already masked pixels)
  • branches/eam_branches/ipp-20110213/ppStack/src/ppStackReject.c

    r30620 r30772  
    5555
    5656    // Reject bad pixels
    57     if (psMetadataLookupS32(NULL, config->arguments, "-threads") > 0) {
     57    if (psMetadataLookupS32(NULL, config->arguments, "NTHREADS") > 0) {
    5858        pmStackRejectThreadsInit();
    5959    }
  • branches/eam_branches/ipp-20110213/ppStack/src/ppStackThread.c

    r30620 r30772  
    101101    }
    102102
    103     int numThreads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads
     103    int numThreads = psMetadataLookupS32(NULL, config->arguments, "NTHREADS"); // Number of threads
    104104
    105105    // Generate readouts for each input file in each file group
     
    248248
    249249
    250 void ppStackThreadInit(void)
     250void ppStackSetThreads(void)
    251251{
    252252    static bool threaded = false;       // Are we running threaded?
  • branches/eam_branches/ipp-20110213/ppStack/src/ppStackThread.h

    r30620 r30772  
    4343
    4444// Initialise the threads
    45 void ppStackThreadInit(void);
     45void ppStackSetThreads(void);
    4646
    4747
  • branches/eam_branches/ipp-20110213/ppSub/src/ppSub.h

    r29937 r30772  
    128128void ppSubVersionPrint(void);
    129129
     130/// write the version info to a string
     131psString ppSubVersionLong(void);
     132
    130133/// Mark the data quality as bad and prepare to suspend processing
    131134void ppSubDataQuality(ppSubData *data,  ///< Processing data
     
    185188bool ppSubSetSourceImageIDs (psArray *sources, int imageID);
    186189
     190void ppSubSetThreads (void);
     191
    187192///@}
    188193#endif
  • branches/eam_branches/ipp-20110213/ppSub/src/ppSubArguments.c

    r29937 r30772  
    5757}
    5858
     59void ppSubSetThreads (void) {
     60    // ppSub does not have any of its own thread handlers
     61    return;
     62}
     63
    5964bool ppSubArguments(int argc, char *argv[], ppSubData *data)
    6065{
     
    6267    pmConfig *config = data->config;
    6368    assert(config);
     69
     70    // generic arguments (version, dumpconfig)
     71    PS_ARGUMENTS_GENERIC( ppSub, config, argc, argv );
     72
     73    // thread arguments
     74    PS_ARGUMENTS_THREADS( ppSub, config, argc, argv )
    6475
    6576    int argNum = psArgumentGet(argc, argv, "-debug"); // Debugging argument number
     
    8293    psMetadataAddStr(arguments, PS_LIST_TAIL, "-stats", 0, "Statistics file", NULL);
    8394    psMetadataAddStr(arguments,  PS_LIST_TAIL, "-stamps", 0, "Stamps filename; x,y on each line", NULL);
    84     psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Number of threads", 0);
    85     psMetadataAddStr(arguments, PS_LIST_TAIL, "-dumpconfig", 0, "file to dump configuration to", NULL);
    8695    psMetadataAddS32(arguments, PS_LIST_TAIL, "-convolve", 0, "Image to convolve [1 or 2]", 0);
    8796    psMetadataAddBool(arguments, PS_LIST_TAIL, "-photometry", 0, "Perform photometry?", NULL);
     
    166175    }
    167176
    168     int threads = psMetadataLookupS32(NULL, arguments, "-threads"); // Number of threads
    169     if (threads > 0) {
    170         if (!psThreadPoolInit(threads)) {
    171             psError(psErrorCodeLast(), false, "Unable to setup %d threads", threads);
    172             return false;
    173         }
    174     }
    175 
    176177    psTrace("ppSub", 1, "Done reading command-line arguments\n");
    177178
  • branches/eam_branches/ipp-20110213/ppSub/src/ppSubConvolve.c

    r29551 r30772  
    3939}
    4040
     41void ppSubSetThreads (void) {
     42    // ppSub does not have any of its own thread handlers
     43    return;
     44}
    4145
    4246int main(int argc, char *argv[])
     
    4953        goto die;
    5054    }
     55
     56    // generic arguments (version, dumpconfig)
     57    PS_ARGUMENTS_GENERIC( ppSub, config, argc, argv );
     58
     59    // thread arguments
     60    PS_ARGUMENTS_THREADS( ppSub, config, argc, argv )
    5161
    5262    bool reference = false;             // Input is actually the reference image?
     
    5969        psMetadataAddStr(arguments, PS_LIST_TAIL, "-kernel", 0, "Convolution kernel", NULL);
    6070        psMetadataAddBool(arguments, PS_LIST_TAIL, "-reference", 0, "Input is actually reference?", false);
    61         psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Threads to use", 0);
    6271        psMetadataAddBool(arguments, PS_LIST_TAIL, "-save-all", 0, "Save all outputs?", false);
    6372
     
    7584
    7685        reference = psMetadataLookupBool(NULL, arguments, "-reference");
    77         threads = psMetadataLookupS32(NULL, arguments, "-threads");
     86        threads = psMetadataLookupS32(NULL, arguments, "NTHREADS");
    7887        fileList("PPSUB.INPUT", inImage, "Input image", config);
    7988        fileList("PPSUB.INPUT.MASK", inMask, "Input mask", config);
     
    239248        if (threads > 0) {
    240249            pmSubtractionThreadsInit();
    241             psThreadPoolInit(threads);
    242250        }
    243251
  • branches/eam_branches/ipp-20110213/ppSub/src/ppSubMatchPSFs.c

    r30619 r30772  
    374374    }
    375375
    376     int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads
     376    int threads = psMetadataLookupS32(NULL, config->arguments, "NTHREADS"); // Number of threads
    377377    if (threads > 0) {
    378378        pmSubtractionThreadsInit();
  • branches/eam_branches/ipp-20110213/psLib/src/sys/psMemory.c

    r30595 r30772  
    2727#include <string.h>
    2828#include <assert.h>
     29#include <unistd.h>
    2930
    3031#if defined(PS_MEM_BACKTRACE) && defined(HAVE_BACKTRACE)
     
    10901091    return (memBlock1->freeFunc == memBlock2->freeFunc);
    10911092}
     1093
     1094bool static dumpMemory = false;
     1095
     1096void psMemDumpSetState (bool state) {
     1097    dumpMemory = state;
     1098}
     1099
     1100void psMemDump(const char *name)
     1101{
     1102    if (!dumpMemory) return;
     1103
     1104    char filename[1024];          // don't make your sub-names too long!
     1105    static int num = 0;           // Counter, to make files unique and give an idea of sequence
     1106
     1107    snprintf (filename, 1024, "memdump_%s_%03d.txt", name, num);
     1108    FILE *memFile = fopen(filename, "w");
     1109
     1110    psMemBlock **leaks = NULL;
     1111    int numLeaks = psMemCheckLeaks(0, &leaks, NULL, true);
     1112    fprintf(memFile, "# MemBlock Size Source\n");
     1113    unsigned long total = 0;            // Total memory used
     1114    for (int i = 0; i < numLeaks; i++) {
     1115        psMemBlock *mb = leaks[i];
     1116        fprintf(memFile, "%12lu\t%12zd\t%s:%d\n", mb->id, mb->userMemorySize, mb->file, mb->lineno);
     1117        total += mb->userMemorySize;
     1118    }
     1119    fclose(memFile);
     1120    psFree(leaks);
     1121
     1122    fprintf(stderr, "Memdump %s %d: Memory use: %ld, sbrk: %p\n", name, num, total, (void *) sbrk(0));
     1123    num++;
     1124}
  • branches/eam_branches/ipp-20110213/psLib/src/sys/psMemory.h

    r26892 r30772  
    647647  );
    648648
     649void psMemDumpSetState (bool state);
     650void psMemDump(const char *name);
     651
    649652// Ensure this is a psLib pointer
    650653#define PS_ASSERT_PTR_HEAVY(PTR, RVAL) \
  • branches/eam_branches/ipp-20110213/psLib/src/types/psArguments.h

    r24143 r30772  
    8181 *  specific routine called pkgnameVersionLong() is presumed to exist.
    8282 */
    83 #define PSARGUMENTS_INSTANTIATE_GENERICS( pkgname, config, argc, argv )   \
     83#define PS_ARGUMENTS_GENERIC( pkgname, config, argc, argv )   \
    8484  { int N= psArgumentGet (argc, argv, "-version");                        \
    8585    if (N) {                                                              \
     
    115115 *  presumed to exist.
    116116 */
    117 #define PSARGUMENTS_INSTANTIATE_THREADSARG( pkgname, config, argc, argv )   \
     117#define PS_ARGUMENTS_THREADS( pkgname, config, argc, argv )   \
    118118  { int N= psArgumentGet(argc, argv, "-threads");                           \
    119119    if (N) {                                                                \
  • branches/eam_branches/ipp-20110213/psModules/src/objects/pmPSF.c

    r29004 r30772  
    430430        return NAN;
    431431    }
     432
     433    // get the model full-width at half-max
     434    float fwhmMajor = 2*model->modelRadius (model->params, 0.5);
     435
     436# if (0)
    432437    psF32 *params = model->params->data.F32; // Model parameters
    433438    psEllipseAxes axes = pmPSF_ModelToAxes(params, MAX_AXIS_RATIO); // Ellipse axes
     
    439444
    440445    return fwhm;
    441 }
     446# else
     447
     448    psFree(model);
     449
     450    return fwhmMajor;
     451# endif
     452}
  • branches/eam_branches/ipp-20110213/psModules/src/objects/pmPSFtryFitPSF.c

    r30621 r30772  
    109109
    110110        // This function calculates the psf and aperture magnitudes
    111         status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal, markVal); // raw PSF mag, AP mag
     111        status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal, markVal, options->apRadius); // raw PSF mag, AP mag
    112112        if (!status || isnan(source->apMag)) {
    113113            psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask
  • branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourceMasks.h

    r29546 r30772  
    4646    PM_SOURCE_MODE2_DIFF_WITH_DOUBLE = 0x00000002, ///< diff source matched to positive detections in both images
    4747    PM_SOURCE_MODE2_MATCHED          = 0x00000004, ///< diff source matched to positive detections in both images
     48
     49    PM_SOURCE_MODE2_ON_SPIKE         = 0x00000008, ///< > 25% of (PSF-weighted) pixels land on diffraction spike
     50    PM_SOURCE_MODE2_ON_STARCORE      = 0x00000010, ///< > 25% of (PSF-weighted) pixels land on starcore
     51    PM_SOURCE_MODE2_ON_BURNTOOL      = 0x00000020, ///< > 25% of (PSF-weighted) pixels land on burntool
     52    PM_SOURCE_MODE2_ON_CONVPOOR      = 0x00000040, ///< > 25% of (PSF-weighted) pixels land on convpoor
    4853} pmSourceMode2;
    4954
  • branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourcePhotometry.c

    r30763 r30772  
    2323#include "pmFPAMaskWeight.h"
    2424
     25#include "pmConfigMask.h"
    2526#include "pmTrend2D.h"
    2627#include "pmResiduals.h"
     
    4950static float AP_MIN_SN = 0.0;
    5051
    51 bool pmSourceMagnitudesInit (psMetadata *config)
    52 {
    53     PS_ASSERT_PTR_NON_NULL(config, false);
     52// make this a bit more clever and dynamic
     53static psImageMaskType maskSuspect  = 0;
     54static psImageMaskType maskSpike    = 0;
     55static psImageMaskType maskStarCore = 0;
     56static psImageMaskType maskBurntool = 0;
     57static psImageMaskType maskConvPoor = 0;
     58
     59bool pmSourceMagnitudesInit (pmConfig *config, psMetadata *recipe)
     60{
     61    PS_ASSERT_PTR_NON_NULL(recipe, false);
    5462    bool status;
    5563
    56     float limit = psMetadataLookupF32 (&status, config, "AP_MIN_SN");
     64    // we are going to test specially against these poor values
     65    if (config) {
     66        maskSpike    = pmConfigMaskGet("SPIKE", config);
     67        maskStarCore = pmConfigMaskGet("STARCORE", config);
     68        maskBurntool = pmConfigMaskGet("BURNTOOL", config);
     69        maskConvPoor = pmConfigMaskGet("CONV.POOR", config);
     70        maskSuspect  = maskSpike | maskStarCore | maskBurntool | maskConvPoor;
     71    }
     72
     73    float limit = psMetadataLookupF32 (&status, recipe, "AP_MIN_SN");
    5774    if (status) {
    5875        AP_MIN_SN = limit;
     
    7794// XXX masked region should be (optionally) elliptical
    7895// if mode is PM_SOURCE_PHOT_PSFONLY, we skip all other magnitudes
    79 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal, psImageMaskType markVal)
     96bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal, psImageMaskType markVal, float radius)
    8097{
    8198    PS_ASSERT_PTR_NON_NULL(source, false);
     
    166183    // measure the contribution of included pixels
    167184    if (mode & PM_SOURCE_PHOT_WEIGHT) {
    168         pmSourcePixelWeight (&source->pixWeightNotBad, &source->pixWeightNotPoor, model, source->maskObj, maskVal, markVal);
     185        pmSourcePixelWeight (source, model, source->maskObj, maskVal, radius);
    169186    }
    170187
     
    342359
    343360// return source aperture magnitude
    344 bool pmSourcePixelWeight (float *pixWeightNotBad, float *pixWeightNotPoor, pmModel *model, psImage *mask, psImageMaskType maskVal, psImageMaskType markVal)
    345 {
    346     PS_ASSERT_PTR_NON_NULL(pixWeightNotBad, false);
    347     PS_ASSERT_PTR_NON_NULL(pixWeightNotPoor, false);
     361bool pmSourcePixelWeight (pmSource *source, pmModel *model, psImage *mask, psImageMaskType maskVal, float radius)
     362{
     363    PS_ASSERT_PTR_NON_NULL(source, false);
     364    source->pixWeightNotBad = NAN;
     365    source->pixWeightNotPoor = NAN;
     366
    348367    PS_ASSERT_PTR_NON_NULL(mask, false);
    349368    PS_ASSERT_PTR_NON_NULL(model, false);
     
    355374    float value;
    356375
     376    float spikeSum = 0;
     377    float starcoreSum = 0;
     378    float burntoolSum = 0;
     379    float convpoorSum = 0;
     380
    357381    int Xo, Yo, dP;
    358382    int dX, DX, NX;
    359383    int dY, DY, NY;
    360384
    361     *pixWeightNotBad = 0.0;
    362     *pixWeightNotPoor = 0.0;
     385    float radius2 = PS_SQR(radius);
    363386
    364387    // we only care about the value of the object model, not the local sky
     
    387410    NY = mask->numRows;
    388411
     412    psImageMaskType maskBad = maskVal;
     413    maskBad &= ~maskSuspect;
     414
    389415    // measure modelSum and validSum.  this function is applied to a sources' subimage.  the
    390416    // value of DX is chosen (see above) to cover the full possible size of the subimage if it
    391417    // were not by an edge; ie, if the source is cut in half by an image edge, we correctly
    392418    // count the virtual pixels off the edge in normalizing the value of the pixWeight
     419
     420    // we skip any pixels [real or virtual] outside of the specified radius (nominally the aperture radius)
    393421    for (int ix = -DX; ix < DX + 1; ix++) {
     422        if (ix > radius) continue;
    394423        int mx = ix + dX;
    395424        for (int iy = -DY; iy < DY + 1; iy++) {
     425            if (iy > radius) continue;
     426            if (ix*ix + iy*iy > radius2) continue;
    396427            int my = iy + dY;
    397428
     
    409440            if (my >= NY) continue;
    410441
    411             if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskVal)) {
     442            // count pixels which are masked only with bad pixels
     443            if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskBad)) {
    412444                notBadSum += value;
    413445            }
    414             if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & ~markVal)) {
     446
     447            // count pixels which are masked with an mask bit (bad or poor)
     448            if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskVal)) {
    415449                notPoorSum += value;
    416450            }
     451
     452            // count pixels which are masked with an mask bit (bad or poor)
     453            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskSpike) {
     454                spikeSum += value;
     455            }
     456            // count pixels which are masked with an mask bit (bad or poor)
     457            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskStarCore) {
     458                starcoreSum += value;
     459            }
     460            // count pixels which are masked with an mask bit (bad or poor)
     461            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskBurntool) {
     462                burntoolSum += value;
     463            }
     464            // count pixels which are masked with an mask bit (bad or poor)
     465            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskConvPoor) {
     466                convpoorSum += value;
     467            }
    417468        }
    418469    }
    419470    psFree (coord);
    420471
    421     *pixWeightNotBad  = notBadSum  / modelSum;
    422     *pixWeightNotPoor = notPoorSum / modelSum;
    423 
    424     if (false && isfinite(*pixWeightNotBad) && isfinite(*pixWeightNotPoor)) {
    425         psAssert (*pixWeightNotBad <= *pixWeightNotPoor, "error: all bad pixels should also be poor");
     472    source->pixWeightNotBad  = notBadSum  / modelSum;
     473    source->pixWeightNotPoor = notPoorSum / modelSum;
     474
     475    if ((spikeSum/modelSum) > 0.25) {
     476        source->mode2 |= PM_SOURCE_MODE2_ON_SPIKE;
     477    }
     478    if ((starcoreSum/modelSum) > 0.25) {
     479        source->mode2 |= PM_SOURCE_MODE2_ON_STARCORE;
     480    }
     481    if ((burntoolSum/modelSum) > 0.25) {
     482        source->mode2 |= PM_SOURCE_MODE2_ON_BURNTOOL;
     483    }
     484    if ((convpoorSum/modelSum) > 0.25) {
     485        source->mode2 |= PM_SOURCE_MODE2_ON_CONVPOOR;
     486    }
     487
     488    if (isfinite(source->pixWeightNotBad) && isfinite(source->pixWeightNotPoor)) {
     489        psAssert (source->pixWeightNotBad <= source->pixWeightNotPoor, "error: all bad pixels should also be poor");
    426490    }
    427491
     
    431495# define FLUX_LIMIT 3.0
    432496
    433 // measure stats that may be using in difference images for distinguishing real sources from bad residuals
     497// measure stats that may be used in difference images for distinguishing real sources from bad residuals
    434498bool pmSourceMeasureDiffStats (pmSource *source, psImageMaskType maskVal, psImageMaskType markVal)
    435499{
  • branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourcePhotometry.h

    r30763 r30772  
    6464);
    6565
    66 bool pmSourceMagnitudesInit (psMetadata *config);
    67 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal, psImageMaskType markVal);
     66bool pmSourceMagnitudesInit (pmConfig *config, psMetadata *recipe);
     67bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal, psImageMaskType markVal, float radius);
    6868
    69 bool pmSourcePixelWeight (float *pixWeightNotBad, float *pixWeightNotPoor, pmModel *model, psImage *mask, psImageMaskType maskVal, psImageMaskType markVal);
     69bool pmSourcePixelWeight (pmSource *source, pmModel *model, psImage *mask, psImageMaskType maskVal, float radius);
    7070
    7171bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psImageMaskType maskVal, const float covarFactor, int nParams);
  • branches/eam_branches/ipp-20110213/psphot/src/psphotApResid.c

    r30764 r30772  
    117117
    118118    // set limits on the aperture magnitudes
    119     pmSourceMagnitudesInit (recipe);
     119    pmSourceMagnitudesInit (config, recipe);
    120120
    121121    // threaded measurement of the source magnitudes
     
    466466        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, source->apRadius, "OR", markVal);
    467467
    468         bool status = pmSourceMagnitudes (source, psf, photMode, maskVal, markVal);
     468        bool status = pmSourceMagnitudes (source, psf, photMode, maskVal, markVal, source->apRadius);
    469469
    470470        // clear the mask bit
  • branches/eam_branches/ipp-20110213/psphot/src/psphotArguments.c

    r29004 r30772  
    109109    }
    110110
    111     PSARGUMENTS_INSTANTIATE_GENERICS( psphot, config, argc, argv );
     111    // generic arguments (version, dumpconfig)
     112    PS_ARGUMENTS_GENERIC( psphot, config, argc, argv );
     113
     114    // thread arguments
     115    PS_ARGUMENTS_THREADS( psphot, config, argc, argv )
    112116
    113117    // save the following additional recipe values based on command-line options
    114118    // these options override the PSPHOT recipe values loaded from recipe files
    115119    psMetadata *options = pmConfigRecipeOptions (config, PSPHOT_RECIPE);
    116 
    117     // Number of threads is handled
    118     PSARGUMENTS_INSTANTIATE_THREADSARG( psphot, config, argc, argv )
    119120
    120121    // run the test model (requires X,Y coordinate)
  • branches/eam_branches/ipp-20110213/psphot/src/psphotChoosePSF.c

    r30764 r30772  
    448448            }
    449449            psFree (modelPSF);
     450
     451            // float fwhmtest = pmPSFtoFWHM(psf, xc, yc);
     452            // fprintf (stderr, "fwhm: %f, %f : %f\n", FWHM_MAJOR, FWHM_MINOR, fwhmtest);
    450453        }
    451454    }
  • branches/eam_branches/ipp-20110213/psphot/src/psphotExtendedSourceFits.c

    r30764 r30772  
    4343    int NplainPass = 0;
    4444    int Nfaint = 0;
     45    int Nfail = 0;
    4546
    4647    psTimerStart ("psphot.extended");
     
    176177            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nplain
    177178            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for NplainPass
    178             PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfain
     179            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfaint
     180            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail
    179181
    180182// set this to 0 to run without threading
     
    204206            scalar = job->args->data[12];
    205207            Nfaint += scalar->data.S32;
     208            scalar = job->args->data[13];
     209            Nfail += scalar->data.S32;
    206210            psFree(job);
    207211# endif
     
    234238                scalar = job->args->data[12];
    235239                Nfaint += scalar->data.S32;
     240                scalar = job->args->data[13];
     241                Nfail += scalar->data.S32;
    236242            }
    237243            psFree(job);
     
    244250    psLogMsg ("psphot", PS_LOG_INFO, "  %d convolved models (%d passed)\n", Nconvolve, NconvolvePass);
    245251    psLogMsg ("psphot", PS_LOG_INFO, "  %d plain models (%d passed)\n", Nplain, NplainPass);
    246     psLogMsg ("psphot", PS_LOG_INFO, "  %d too faint to fit\n", Nfaint);
     252    psLogMsg ("psphot", PS_LOG_INFO, "  %d too faint to fit, %d failed\n", Nfaint, Nfail);
    247253    return true;
    248254}
     
    253259    bool status;
    254260    int Next = 0;
     261    int Nfaint = 0;
     262    int Nfail = 0;
    255263    int Nconvolve = 0;
    256264    int NconvolvePass = 0;
    257265    int Nplain = 0;
    258     int Nfaint = 0;
    259266    int NplainPass = 0;
    260267    bool savePics = false;
     
    271278    psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[6],PS_TYPE_IMAGE_MASK_DATA);
    272279
    273     pthread_t tid = pthread_self();     // Thread identifier
     280    // pthread_t tid = pthread_self();     // Thread identifier
    274281
    275282    // Define source fitting parameters for extended source fits
     
    305312        // if (source->modelEXT == NULL) continue;
    306313
    307         fprintf (stderr, "fit %d,%d in thread %d\n", source->peak->x, source->peak->y, (int) tid);
     314        // fprintf (stderr, "fit %d,%d in thread %d\n", source->peak->x, source->peak->y, (int) tid);
    308315
    309316        // replace object in image
     
    398405              if (!modelFit) {
    399406                  psTrace ("psphot", 5, "failed to fit psf-conv model for object at %f, %f", source->moments->Mx, source->moments->My);
     407                  Nfail ++;
    400408                  continue;
    401409              }
     
    412420              if (!modelFit) {
    413421                  psTrace ("psphot", 5, "failed to fit plain model for object at %f, %f", source->moments->Mx, source->moments->My);
     422                  Nfail ++;
    414423                  continue;
    415424              }
     
    529538    scalar->data.S32 = Nfaint;
    530539
     540    scalar = job->args->data[13];
     541    scalar->data.S32 = Nfail;
     542
    531543    return true;
    532544}
  • branches/eam_branches/ipp-20110213/psphot/src/psphotForcedArguments.c

    r25981 r30772  
    103103    }
    104104
    105     PSARGUMENTS_INSTANTIATE_GENERICS( psphot, config, argc, argv );
     105    PS_ARGUMENTS_GENERIC( psphot, config, argc, argv );
    106106
    107107    // save the following additional recipe values based on command-line options
     
    110110
    111111    // Number of threads is handled
    112     PSARGUMENTS_INSTANTIATE_THREADSARG( psphot, config, argc, argv )
     112    PS_ARGUMENTS_THREADS( psphot, config, argc, argv )
    113113
    114114    // visual : interactive display mode
  • branches/eam_branches/ipp-20110213/psphot/src/psphotMagnitudes.c

    r29936 r30772  
    7676    maskVal |= markVal;
    7777
    78     pmSourceMagnitudesInit (recipe);
     78    pmSourceMagnitudesInit (config, recipe);
    7979
    8080    // the binning details are saved on the analysis metadata
     
    176176        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, source->apRadius, "OR", markVal);
    177177
    178         status = pmSourceMagnitudes (source, psf, photMode, maskVal, markVal);
     178        status = pmSourceMagnitudes (source, psf, photMode, maskVal, markVal, source->apRadius);
    179179        if (status && isfinite(source->apMag)) Nap ++;
    180180
     
    295295    psArray *sources                = job->args->data[0];
    296296    psImageMaskType maskVal         = PS_SCALAR_VALUE(job->args->data[1],PS_TYPE_IMAGE_MASK_DATA);
    297     psImageMaskType markVal         = PS_SCALAR_VALUE(job->args->data[2],PS_TYPE_IMAGE_MASK_DATA);
    298297
    299298    for (int i = 0; i < sources->n; i++) {
     
    309308        }
    310309
    311         status = pmSourcePixelWeight (&source->pixWeightNotBad, &source->pixWeightNotPoor, model, source->maskObj, maskVal, markVal);
     310        status = pmSourcePixelWeight (source, model, source->maskObj, maskVal, source->apRadius);
    312311        if (!status) {
    313312          psTrace ("psphot", 3, "fail to measure pixel weight");
  • branches/eam_branches/ipp-20110213/psphot/src/psphotMakeGrowthCurve.c

    r21183 r30772  
    88
    99    // set limits on the aperture magnitudes
    10     pmSourceMagnitudesInit (recipe);
     10    pmSourceMagnitudesInit (NULL, recipe);
    1111
    1212    // bit-masks to test for good/bad pixels
  • branches/eam_branches/ipp-20110213/psphot/src/psphotMakePSFArguments.c

    r25982 r30772  
    103103    }
    104104
    105     PSARGUMENTS_INSTANTIATE_GENERICS( psphot, config, argc, argv );
     105    PS_ARGUMENTS_GENERIC( psphot, config, argc, argv );
    106106
    107107    // save the following additional recipe values based on command-line options
     
    110110
    111111    // Number of threads is handled
    112     PSARGUMENTS_INSTANTIATE_THREADSARG( psphot, config, argc, argv )
     112    PS_ARGUMENTS_THREADS( psphot, config, argc, argv )
    113113
    114114    // visual : interactive display mode
  • branches/eam_branches/ipp-20110213/psphot/src/psphotSetThreads.c

    r30624 r30772  
    3535    psFree(task);
    3636
    37     task = psThreadTaskAlloc("PSPHOT_EXTENDED_FIT", 13);
     37    task = psThreadTaskAlloc("PSPHOT_EXTENDED_FIT", 14);
    3838    task->function = &psphotExtendedSourceFits_Threaded;
    3939    psThreadTaskAdd(task);
  • branches/eam_branches/ipp-20110213/psphot/src/psphotSourceSize.c

    r30624 r30772  
    207207        num++;
    208208
    209         pmSourceMagnitudes (source, psf, photMode, maskVal, markVal);
     209        pmSourceMagnitudes (source, psf, photMode, maskVal, markVal, source->apRadius);
    210210
    211211        float kMag = -2.5*log10(source->moments->KronFlux);
     
    327327
    328328        // XXX can we test if psfMag is set and calculate only if needed?
    329         pmSourceMagnitudes (source, psf, photMode, maskVal, markVal);
     329        pmSourceMagnitudes (source, psf, photMode, maskVal, markVal, source->apRadius);
    330330
    331331        // convert to Mmaj, Mmin:
     
    501501        // psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(options->markVal));
    502502        // psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, source->apRadius, "OR", options->markVal);
    503         pmSourceMagnitudes (source, psf, photMode, maskVal, markVal);
     503        pmSourceMagnitudes (source, psf, photMode, maskVal, markVal, source->apRadius);
    504504
    505505        // clear the mask bit
  • branches/eam_branches/ipp-20110213/psphot/src/psphotStackArguments.c

    r30624 r30772  
    2222    }
    2323
    24     // -version and -dumpconfig arguments
    25     PSARGUMENTS_INSTANTIATE_GENERICS( psphot, config, argc, argv );
     24    // generic arguments (version, dumpconfig)
     25    PS_ARGUMENTS_GENERIC( psphot, config, argc, argv );
     26
     27    // thread arguments
     28    PS_ARGUMENTS_THREADS( psphot, config, argc, argv )
    2629
    2730    // save the following additional recipe values based on command-line options
     
    2932    psMetadata *options = pmConfigRecipeOptions (config, PSPHOT_RECIPE);
    3033
    31     // Number of threads is handled
    32     PSARGUMENTS_INSTANTIATE_THREADSARG( psphot, config, argc, argv )
    33 
    3434    // visual : interactive display mode
    3535    if ((N = psArgumentGet (argc, argv, "-visual"))) {
    3636        psArgumentRemove (N, &argc, argv);
    3737        pmVisualSetVisual(true);
     38    }
     39
     40    // memdump : enable memory spot checks
     41    if ((N = psArgumentGet (argc, argv, "-memdump"))) {
     42        psArgumentRemove (N, &argc, argv);
     43        psMemDumpSetState(true);
    3844    }
    3945
  • branches/eam_branches/ipp-20110213/psphot/src/psphotStackImageLoop.c

    r30624 r30772  
    5050                psLogMsg ("psphot", 6, "Readout %d: %x %x\n", view->readout, cell->file_exists, cell->process);
    5151                if (! readout->data_exists) { continue; }
     52
     53                psMemDump("load");
    5254
    5355                // PSF matching
     
    5759                    return false;
    5860                }
     61                psMemDump("stackmatch");
    5962
    6063                // XXX for now, we assume there is only a single chip in the PHU:
     
    6467                    return false;
    6568                }
    66 
     69                psMemDump("psphot");
    6770            }
    6871            // drop all versions of the internal files
  • branches/eam_branches/ipp-20110213/psphot/src/psphotStackMatchPSFsUtils.c

    r30707 r30772  
    287287
    288288    float penalty = psMetadataLookupF32(NULL, subRecipe, "PENALTY"); // Penalty for wideness
    289     int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads
     289    int threads = psMetadataLookupS32(NULL, config->arguments, "NTHREADS"); // Number of threads
    290290
    291291    int order = psMetadataLookupS32(NULL, subRecipe, "SPATIAL.ORDER"); // Spatial polynomial order
  • branches/eam_branches/ipp-20110213/psphot/src/psphotStackPSF.c

    r30624 r30772  
    5656        }
    5757
    58         float Sxx = sqrt(2.0)*targetFWHM / 2.35;
     58        // measured scale factors (fwhm = Sxx * 2.35 * scaleFactor / sqrt(2.0))
     59        // GAUSS  : 1.000
     60        // PGAUSS : 1.006
     61        // QGAUSS : 1.151
     62        // RGAUSS : 0.883
     63        // PS1_V1 : 1.134
     64       
     65        float scaleFactor = NAN;
     66        if (!strcmp(psfModel, "PS_MODEL_GAUSS")) {
     67            scaleFactor = 1.000;
     68        }
     69        if (!strcmp(psfModel, "PS_MODEL_PGAUSS")) {
     70            scaleFactor = 1.0006;
     71        }
     72        if (!strcmp(psfModel, "PS_MODEL_QGAUSS")) {
     73            scaleFactor = 1.151;
     74        }
     75        if (!strcmp(psfModel, "PS_MODEL_RGAUSS")) {
     76            scaleFactor = 0.883;
     77        }
     78        if (!strcmp(psfModel, "PS_MODEL_PS1_V1")) {
     79            scaleFactor = 1.134;
     80        }
     81        psAssert (isfinite(scaleFactor), "invalid model for PSF");
     82
     83        float Sxx = sqrt(2.0)*targetFWHM / 2.35 / scaleFactor;
    5984
    6085        // XXX probably should make the model type (and par 7) optional from recipe
    61         psf = pmPSFBuildSimple(psfModel, Sxx, Sxx, 0.0, 1.0);
     86        // psf = pmPSFBuildSimple(psfModel, Sxx, Sxx, 0.0, 1.0);
     87        psf = pmPSFBuildSimple(psfModel, Sxx, Sxx, 0.0, 0.2);
    6288        if (!psf) {
    6389            psError(PSPHOT_ERR_PSF, false, "Unable to build dummy PSF.");
  • branches/eam_branches/ipp-20110213/pswarp/src/pswarpArguments.c

    r27227 r30772  
    4242    }
    4343
     44    // generic arguments (version, dumpconfig)
     45    PS_ARGUMENTS_GENERIC( pswarp, config, argc, argv );
     46
     47    // thread arguments
     48    PS_ARGUMENTS_THREADS( pswarp, config, argc, argv )
     49
    4450    // save the following additional recipe values based on command-line options
    4551    // these options override the PSWARP recipe values loaded from recipe files
     
    7682    }
    7783
    78     // Number of threads
    79     if ((N = psArgumentGet(argc, argv, "-threads"))) {
    80         psArgumentRemove(N, &argc, argv);
    81         int nThreads = atoi(argv[N]);
    82         psMetadataAddS32(config->arguments, PS_LIST_TAIL, "NTHREADS", 0, "number of warp threads", nThreads);
    83         psArgumentRemove(N, &argc, argv);
    84 
    85         // create the thread pool with number of desired threads, supplying our thread launcher function
    86         // XXX need to determine the number of threads from the config data
    87         psThreadPoolInit (nThreads);
    88     }
    8984    pswarpSetThreads();
    90 
    91     if ((N = psArgumentGet(argc, argv, "-dumpconfig"))) {
    92         psArgumentRemove(N, &argc, argv);
    93         psMetadataAddStr(config->arguments, PS_LIST_TAIL, "DUMP_CONFIG", PS_META_REPLACE,
    94                          "Filename for configuration dump", argv[N]);
    95         psArgumentRemove(N, &argc, argv);
    96     }
    97 
    9885
    9986    pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
Note: See TracChangeset for help on using the changeset viewer.