IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34085


Ignore:
Timestamp:
Jun 26, 2012, 11:31:38 AM (14 years ago)
Author:
eugene
Message:

re-enable MODEL_VAR option for linear photometry fit

Location:
trunk/psModules
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules

  • trunk/psModules/configure.ac

    r23794 r34085  
    1414AC_SUBST(PSMODULES_LT_VERSION,$PSMODULES_LT_VERSION)
    1515
    16 IPP_STDCFLAGS
     16IPP_STDLDFLAGS
    1717
    1818AC_LANG(C)
     
    312312dnl ------- enable -Werror after all of the probes have run ---------
    313313IPP_STDOPTS
    314 
    315 CFLAGS="${CFLAGS} -Wall -Werror"
     314IPP_STDCFLAGS
     315
    316316dnl enable POSIX/XSI and C99 compliance
    317317CFLAGS="${CFLAGS=} -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L"
  • trunk/psModules/src/camera/pmFPAMosaic.c

    r28007 r34085  
    661661            good = false;
    662662        }
     663    }
     664    if (!good) {
     665        // XXX do something to address this?
    663666    }
    664667
  • trunk/psModules/src/camera/pmFPARead.c

    r27346 r34085  
    957957        trimsec->y1 = naxis2 + trimsec->y1;
    958958
    959     int maxSize;                        // Number of cols,rows in image
    960     if (readdir == 1) {
    961         maxSize = PS_MIN(naxis2, trimsec->y1 - trimsec->y0);
    962     } else {
    963         maxSize = PS_MIN(naxis1, trimsec->x1 - trimsec->x0);
    964     }
     959    // XX not used int maxSize;                        // Number of cols,rows in image
     960    // XX not used if (readdir == 1) {
     961    // XX not used     maxSize = PS_MIN(naxis2, trimsec->y1 - trimsec->y0);
     962    // XX not used } else {
     963    // XX not used     maxSize = PS_MIN(naxis1, trimsec->x1 - trimsec->x0);
     964    // XX not used }
    965965
    966966    int offset;                         // start of the segment
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r31633 r34085  
    333333        psMetadataItem *fuzz = psMetadataLookup(scheme, "FUZZ"); // Quantisation fuzz?
    334334        if (fuzz) {
    335             if (fuzz->type != PS_TYPE_BOOL) {
     335            if (fuzz->type != PS_DATA_BOOL) {
    336336                psWarning("FUZZ in compression scheme %s isn't boolean.", fitsType);
    337337                goto FITS_OPTIONS_DONE;
  • trunk/psModules/src/camera/pmReadoutFake.c

    r33624 r34085  
    332332#define CONCEPT_SET_S32(CONCEPTS, NAME, OLD, NEW) { \
    333333        psMetadataItem *item = psMetadataLookup(CONCEPTS, NAME); \
    334         psAssert(item->type == PS_TYPE_S32, "Incorrect type: %x", item->type); \
     334        psAssert(item->type == PS_DATA_S32, "Incorrect type: %x", item->type); \
    335335        if (item->data.S32 == OLD) { \
    336336            item->data.S32 = NEW; \
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r32941 r34085  
    118118    assert(concept);
    119119    assert(cell);
    120     assert(concept->type == PS_TYPE_F32);
     120    assert(concept->type == PS_DATA_F32);
    121121
    122122    float rn = concept->data.F32;       // Read noise
     
    930930    psFree(timesysName);
    931931
    932     if (!item || item->type != PS_TYPE_S32) {
     932    if (!item || item->type != PS_DATA_S32) {
    933933        psWarning("Unable to find %s --- assuming UTC", timesysName);
    934934        return PS_TIME_UTC;
     
    12581258#endif
    12591259      default:
    1260         if (concept->type == PS_TYPE_F32 && concept->data.F32 - (int)concept->data.F32 == 0) {
     1260        if (concept->type == PS_DATA_F32 && concept->data.F32 - (int)concept->data.F32 == 0) {
    12611261            offset = concept->data.F32;
    1262         } else if (concept->type == PS_TYPE_F64 && concept->data.F64 - (int)concept->data.F64 == 0) {
     1262        } else if (concept->type == PS_DATA_F64 && concept->data.F64 - (int)concept->data.F64 == 0) {
    12631263            offset = concept->data.F64;
    12641264        } else {
     
    15581558    assert(cameraFormat);
    15591559
    1560     if (concept->type != PS_TYPE_S32) {
     1560    if (concept->type != PS_DATA_S32) {
    15611561        psError(PS_ERR_UNKNOWN, true, "Concept %s is not of type S32, as expected.\n", concept->name);
    15621562        return NULL;
  • trunk/psModules/src/concepts/pmConceptsUpdate.c

    r20095 r34085  
    3030            if (isfinite(gain)) {
    3131                psMetadataItem *rn = psMetadataLookup(cell->concepts, "CELL.READNOISE"); // Read noise
    32                 psAssert(rn && rn->type == PS_TYPE_F32, "Should be of the correct type");
     32                psAssert(rn && rn->type == PS_DATA_F32, "Should be of the correct type");
    3333                rn->data.F32 *= gain;
    3434                psMetadataRemoveKey(cell->concepts, "CELL.READNOISE.UPDATE");
  • trunk/psModules/src/config/pmConfigCommand.c

    r18937 r34085  
    4242    psMetadataItem *item;               // Item from iteration
    4343    while ((item = psMetadataGetAndIncrement(iter))) {
    44         assert(item->type == PS_TYPE_S32);
     44        assert(item->type == PS_DATA_S32);
    4545        psStringAppend(command, " -trace %s %d", item->name, item->data.S32);
    4646    }
  • trunk/psModules/src/detrend/pmFringeStats.c

    r31069 r34085  
    662662        if (item->type == PS_DATA_VECTOR) { \
    663663            ARRAY->data[i] = psMemIncrRefCounter(item->data.V); \
    664         } else if (item->type == PS_TYPE_##TYPE) { \
     664        } else if (item->type == PS_DATA_##TYPE) { \
    665665            psVector *vector = psVectorAlloc(1, PS_TYPE_##TYPE); \
    666666            vector->data.TYPE[0] = item->data.TYPE; \
  • trunk/psModules/src/detrend/pmNonLinear.c

    r29935 r34085  
    8282    }
    8383    PS_ASSERT_PTR_NON_NULL(outFlux,NULL);
    84     psS32 tableSize = inFlux->n;
     84    // XXX unused psS32 tableSize = inFlux->n;
    8585    if (inFlux->n != outFlux->n) {
    86         tableSize = PS_MIN(inFlux->n, outFlux->n);
     86        // XXX unused tableSize = PS_MIN(inFlux->n, outFlux->n);
    8787        psLogMsg(__func__, PS_LOG_WARN,
    8888                 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): "
     
    329329
    330330    bin = correction_fluxes->n - 1;
     331    psTrace("psModules.nonlin",6,"NLMN: %f %d %f %f\n",flux,bin,correction_fluxes->data.F32[0],correction_fluxes->data.F32[bin]);
     332    if (bin < 0) { /* warn? */ }
    331333    if (flux < correction_fluxes->data.F32[0]) {
    332334        return(0.0);
     
    357359    bin = correction_fluxes->n - 1;
    358360    psTrace("psModules.nonlin",6,"NLMN: %f %d %f %f\n",flux,bin,correction_fluxes->data.F32[0],correction_fluxes->data.F32[bin]);
     361    if (bin < 0) { /* warn? */ }
    359362    if (flux < correction_fluxes->data.F32[0]) {
    360363        return(0.0);
  • trunk/psModules/src/detrend/pmShutterCorrection.c

    r33089 r34085  
    406406
    407407    // Check input sizes, generate first-pass statistics
    408     psRegion refRegion;                 // Reference region
    409408    psVector *refs = psVectorAlloc(num, PS_TYPE_F32); // Reference measurements
    410409    psVectorInit(refs, 0);
     
    441440            numCols = image->numCols;
    442441            // define the reference region : a box of size 'size' at the center
    443             refRegion = psRegionForSquare(0.5 * numCols, 0.5 * numRows, size);
     442            // XXX unused psRegion refRegion = psRegionForSquare(0.5 * numCols, 0.5 * numRows, size);
    444443            // Set up the sample regions : boxes of size 'size' at the 4 image corners
    445444            for (int j = 0; j < MEASURE_SAMPLES; j++) {
  • trunk/psModules/src/extras/pmVisualUtils.c

    r31373 r34085  
    424424            nwritten = fwrite (line, 1, strlen(line), output);
    425425        }
     426        if (nwritten < 1) {
     427        }
    426428    }
    427429
  • trunk/psModules/src/extras/psPipe.c

    r23487 r34085  
    105105
    106106        status = execvp (argv[0], argv);
    107 
    108         // this statement exits the child, not the parent, process
    109         exit (1);
     107        if (status < 0) { psWarning ("error running exec for child process"); }
     108        exit (1); // this statement exits the child, not the parent, process
    110109    }
    111110    psFree (cmd);
  • trunk/psModules/src/objects/models/pmModel_PGAUSS.c

    r32347 r34085  
    261261{
    262262    psF64 z;
    263     int Nstep = 0;
    264263    psEllipseShape shape;
    265264
     
    285284    // use the fact that f is monotonically decreasing
    286285    z = 0;
    287     Nstep = 0;
    288286
    289287    // choose a z value guaranteed to be beyond our limit
  • trunk/psModules/src/objects/models/pmModel_PS1_V1.c

    r32347 r34085  
    283283{
    284284    psF64 z;
    285     int Nstep = 0;
    286285    psEllipseShape shape;
    287286
     
    308307    // use the fact that f is monotonically decreasing
    309308    z = 0;
    310     Nstep = 0;
    311309
    312310    // choose a z value guaranteed to be beyond our limit
  • trunk/psModules/src/objects/models/pmModel_QGAUSS.c

    r33417 r34085  
    284284{
    285285    psF64 z;
    286     int Nstep = 0;
    287286    psEllipseShape shape;
    288287
     
    312311    // use the fact that f is monotonically decreasing
    313312    z = 0;
    314     Nstep = 0;
    315313
    316314    // choose a z value guaranteed to be beyond our limit
  • trunk/psModules/src/objects/models/pmModel_RGAUSS.c

    r32347 r34085  
    273273{
    274274    psF64 z;
    275     int Nstep = 0;
    276275    psEllipseShape shape;
    277276
     
    296295    // use the fact that f is monotonically decreasing
    297296    z = 0;
    298     Nstep = 0;
    299297
    300298    // choose a z value guaranteed to be beyond our limit
  • trunk/psModules/src/objects/pmModelFuncs.h

    r33993 r34085  
    2929# define PM_MODEL_FUNCS_H
    3030
    31 # define HAVE_MODEL_VAR 1
    32 
    3331/// @addtogroup Objects Object Detection / Analysis Functions
    3432/// @{
     
    5755    PM_MODEL_OP_NORM     = 0x20,
    5856    PM_MODEL_OP_NOISE    = 0x40,
    59 # if (HAVE_MODEL_VAR)
    6057    PM_MODEL_OP_MODELVAR = 0x80,
    61 # endif
    6258} pmModelOpMode;
    6359
  • trunk/psModules/src/objects/pmModelUtils.c

    r33417 r34085  
    4343
    4444#include "pmErrorCodes.h"
     45
     46// XX static bool useModelVar = false;
     47// XX
     48// XX void pmModelSetModelVarOption (bool option) {
     49// XX   useModelVar = option;
     50// XX }
     51// XX bool pmModelGetModelVarOption (void) {
     52// XX   return useModelVar;
     53// XX }
    4554
    4655/*****************************************************************************
  • trunk/psModules/src/objects/pmModelUtils.h

    r31153 r34085  
    4646bool pmModelSetShape (float *Sxx, float *Sxy, float *Syy, pmMoments *moments);
    4747
     48// XXX void pmModelSetModelVarOption (bool option);
     49// XXX bool pmModelGetModelVarOption (void);
     50
    4851/// @}
    4952# endif /* PM_MODEL_UTILS_H */
  • trunk/psModules/src/objects/pmPSFtryMakePSF.c

    r30044 r34085  
    231231        // XXX we are using the same stats structure on each pass: do we need to re-init it?
    232232        // XXX we hardwire this to SAMPLE stats above (psphotChoosePSF.c), hardwire here instead?
    233         psStatsOptions meanOption = psStatsMeanOption(psf->psfTrendStats->options);
    234         psStatsOptions stdevOption = psStatsStdevOption(psf->psfTrendStats->options);
    235 
     233     
    236234        pmTrend2D *trend = NULL;
    237         float mean, stdev;
    238235
    239236        // XXX we are using the same stats structure on each pass: do we need to re-init it?
     
    249246            return true;
    250247        }
     248
     249# if (PS_TRACE_ON)
     250        float mean, stdev;
     251        psStatsOptions meanOption = psStatsMeanOption(psf->psfTrendStats->options);
     252        psStatsOptions stdevOption = psStatsStdevOption(psf->psfTrendStats->options);
    251253        mean = psStatsGetValue (trend->stats, meanOption);
    252254        stdev = psStatsGetValue (trend->stats, stdevOption);
    253255        psTrace ("psModules.objects", 4, "clipped E0 : %f +/- %f keeping %ld of %ld\n", mean, stdev, psf->psfTrendStats->clippedNvalues, e0->n);
     256# endif
     257
    254258        if (psf->psfTrendMode == PM_TREND_MAP) psImageMapCleanup (trend->map);
    255259        pmSourceVisualPSFModelResid (trend, x, y, e0, srcMask);
     
    264268            return true;
    265269        }
     270# if (PS_TRACE_ON)
    266271        mean = psStatsGetValue (trend->stats, meanOption);
    267272        stdev = psStatsGetValue (trend->stats, stdevOption);
    268273        psTrace ("psModules.objects", 4, "clipped E1 : %f +/- %f keeping %ld of %ld\n", mean, stdev, psf->psfTrendStats->clippedNvalues, e1->n);
     274# endif
    269275        if (psf->psfTrendMode == PM_TREND_MAP) psImageMapCleanup (trend->map);
    270276        pmSourceVisualPSFModelResid (trend, x, y, e1, srcMask);
     
    279285            return true;
    280286        }
     287# if (PS_TRACE_ON)
    281288        mean = psStatsGetValue (trend->stats, meanOption);
    282289        stdev = psStatsGetValue (trend->stats, stdevOption);
    283290        psTrace ("psModules.objects", 4, "clipped E2 : %f +/- %f keeping %ld of %ld\n", mean, stdev, psf->psfTrendStats->clippedNvalues, e2->n);
     291# endif
    284292        if (psf->psfTrendMode == PM_TREND_MAP) psImageMapCleanup (trend->map);
    285293        pmSourceVisualPSFModelResid (trend, x, y, e2, srcMask);
  • trunk/psModules/src/objects/pmSource.c

    r33993 r34085  
    5151    psFree(tmp->pixels);
    5252    psFree(tmp->variance);
    53 # if (HAVE_MODEL_VAR)
    5453    psFree(tmp->modelVar);
    55 # endif
    5654    psFree(tmp->maskObj);
    5755    psFree(tmp->maskView);
     
    8078    psFree (source->pixels);
    8179    psFree (source->variance);
    82 # if (HAVE_MODEL_VAR)
    8380    psFree (source->modelVar);
    84 # endif
    8581    psFree (source->maskObj);
    8682    psFree (source->maskView);
     
    9086    source->pixels = NULL;
    9187    source->variance = NULL;
    92 # if (HAVE_MODEL_VAR)
    9388    source->modelVar = NULL;
    94 # endif
    9589    source->maskObj = NULL;
    9690    source->maskView = NULL;
     
    122116    source->pixels = NULL;
    123117    source->variance = NULL;
    124 # if (HAVE_MODEL_VAR)
    125118    source->modelVar = NULL;
    126 # endif
    127119    source->maskObj = NULL;
    128120    source->maskView = NULL;
     
    212204    source->pixels   = in->pixels   ? psImageCopyView(NULL, in->pixels)   : NULL;
    213205    source->variance = in->variance ? psImageCopyView(NULL, in->variance) : NULL;
    214 # if (HAVE_MODEL_VAR)
    215206    source->modelVar = NULL;
    216 # endif
    217207    source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL;
    218208
     
    10441034    bool addNoise = mode & PM_MODEL_OP_NOISE;
    10451035
    1046 # if (HAVE_MODEL_VAR)
    10471036    bool addModelVar = mode & PM_MODEL_OP_MODELVAR;
    10481037    if (addModelVar) psAssert (source->modelVar, "programming error");
    1049 # endif
    10501038
    10511039    // require the use of pmModelAddWithOffset if we are adding noise (because the model size and norm are rescaled)
     
    10701058        }
    10711059
    1072 # if (HAVE_MODEL_VAR)
    1073         psF32 **target = addModelVar ? source->modelVar->data.F32 : source->pixels->data.F32;
    1074 # else
    1075         psF32 **target = source->pixels->data.F32;
    1076 # endif
     1060        psF32 **target = NULL;
     1061        target = addModelVar ? source->modelVar->data.F32 : source->pixels->data.F32;
    10771062
    10781063        for (int iy = 0; iy < source->modelFlux->numRows; iy++) {
     
    10891074            }
    10901075        }
    1091 # if (HAVE_MODEL_VAR)
     1076        // do not change the flag here if we are adding/subtracting from modelVar
    10921077        if (!addModelVar) {
    1093             if (add) {
    1094                 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
    1095             } else {
    1096                 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
    1097             }
     1078          if (add) {
     1079            source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
     1080          } else {
     1081            source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
     1082          }
    10981083        }
    1099 # else
    1100         if (add) {
    1101             source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
    1102         } else {
    1103             source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
    1104         }
    1105 # endif
    11061084        return true;
    11071085    }
     
    11111089        target = source->variance;
    11121090    }
    1113 # if (HAVE_MODEL_VAR)
    11141091    if (addModelVar) {
    1115         target = source->modelVar;
    1116     }
    1117 # endif
     1092      target = source->modelVar;
     1093    }
    11181094
    11191095    if (add) {
    11201096        status = pmModelAddWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy);
    1121 # if (HAVE_MODEL_VAR)
    11221097        if (!addNoise && !addModelVar) source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
    1123 # else
    1124         source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
    1125 # endif
    11261098    } else {
    11271099        status = pmModelSubWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy);
    1128 # if (HAVE_MODEL_VAR)
    11291100        if (!addNoise && !addModelVar) source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
    1130 # else
    1131         source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
    1132 # endif
     1101    }
     1102    if (!status) {
     1103        // XXX maybe raise an error or warning?
    11331104    }
    11341105
     
    12001171        status = pmModelSubWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy);
    12011172    }
     1173    if (!status) {
     1174        // XXX raise an error or warning?
     1175    }
    12021176
    12031177    // restore original values
     
    12871261    } else {
    12881262        status = pmModelSubWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy);
     1263    }
     1264    if (!status) {
     1265        // XXX raise an error or warning?
    12891266    }
    12901267
  • trunk/psModules/src/objects/pmSource.h

    r33993 r34085  
    7272    psImage *pixels;                    ///< Rectangular region including object pixels.
    7373    psImage *variance;                  ///< Image variance.
    74 # if (HAVE_MODEL_VAR)
    7574    psImage *modelVar;                  ///< variance based on current models
    76 # endif
    7775    psImage *maskObj;                   ///< unique mask for this object which marks included pixels associated with objects.
    7876    psImage *maskView;                  ///< view into global image mask for this object region
  • trunk/psModules/src/objects/pmSourceIO_CMP.c

    r32347 r34085  
    6565    int i, type;
    6666    // psMetadataItem *mdi;
    67     psF32 *PAR, *dPAR;
     67    psF32 *PAR;
    6868    float lsky = 0;
    6969    bool status;
     
    130130
    131131        PAR = model->params->data.F32;
    132         dPAR = model->dparams->data.F32;
    133132
    134133        type = pmSourceGetDophotType (source);
     
    174173    bool status;
    175174    int Ninstar;
    176     psF32 *PAR, *dPAR;
     175    psF32 *PAR;
    177176    psEllipseAxes axes;
    178177
     
    185184    }
    186185
    187     // find config information for output header
    188     float ZERO_POINT = psMetadataLookupF32 (&status, header, "ZERO_PT");
    189     if (!status)
    190         ZERO_POINT = 25.0;
     186    // XXX unused // find config information for output header
     187    // XXX unused float ZERO_POINT = psMetadataLookupF32 (&status, header, "ZERO_PT");
     188    // XXX unused if (!status)
     189    // XXX unused     ZERO_POINT = 25.0;
    191190
    192191    // how many lines in the header?
     
    273272
    274273            PAR = source->modelPSF->params->data.F32;
    275             dPAR = source->modelPSF->dparams->data.F32;
    276274
    277275            PAR[PM_PAR_SKY] = pow (atof (array->data[5]), 10.0);
  • trunk/psModules/src/objects/pmSourceIO_PS1_CAL_0.c

    r32347 r34085  
    322322}
    323323
     324# define WRITE_AP_DATA 0
     325
    324326bool pmSourcesWrite_PS1_CAL_0_XSRC (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, char *extname, psMetadata *recipe)
    325327{
     
    338340    }
    339341
     342# if (WRITE_AP_DATA)
    340343    bool calMags = false;
    341344    bool status1 = false;
     
    350353        calMags = true;
    351354    }
     355# endif
    352356
    353357    // create a header to hold the output data
     
    424428        psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT_SIG",        PS_DATA_F32, "Sigma in EXT y coordinate",                  yErr);
    425429
    426 # if (0)
     430# if (WRITE_AP_DATA)
    427431        // Petrosian measurements
    428432        // XXX insert header data: petrosian ref radius, flux ratio
  • trunk/psModules/src/objects/pmSourceIO_SMPDATA.c

    r32347 r34085  
    6363    psMetadata *row;
    6464    int i;
    65     psF32 *PAR, *dPAR;
     65    psF32 *PAR;
    6666    bool status;
    6767    psEllipseAxes axes;
     
    8585        if (model != NULL) {
    8686            PAR = model->params->data.F32;
    87             dPAR = model->dparams->data.F32;
    8887            xPos = PAR[PM_PAR_XPOS];
    8988            yPos = PAR[PM_PAR_YPOS];
     
    145144
    146145    bool status;
    147     psF32 *PAR, *dPAR;
     146    psF32 *PAR;
    148147    psEllipseAxes axes;
    149148    float lsky;
     
    176175
    177176        PAR = model->params->data.F32;
    178         dPAR = model->dparams->data.F32;
    179177
    180178        psMetadata *row = table->data[i];
  • trunk/psModules/src/objects/pmSourceIO_SX.c

    r32347 r34085  
    5656    PS_ASSERT_PTR_NON_NULL(filename, false);
    5757
    58     psF32 *PAR, *dPAR;
     58    psF32 *PAR;
    5959    psEllipseAxes axes;
    6060
     
    7777
    7878        PAR = model->params->data.F32;
    79         dPAR = model->dparams->data.F32;
    8079
    8180        // pmSourceSextractType (source, &type, &flags);
  • trunk/psModules/src/objects/pmSourcePhotometry.c

    r33993 r34085  
    899899}
    900900
    901 # if (HAVE_MODEL_VAR)
    902901double pmSourceModelWeight(const pmSource *Mi, int term, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
    903 # else
    904 double pmSourceModelWeight(const pmSource *Mi, int term, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
    905 # endif
    906902{
    907903    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
    908 # if (HAVE_MODEL_VAR)
    909     double flux = 0, wt = 1.0, factor = 0;
    910 # else
    911     double flux = 0, wt = 0, factor = 0;
    912 # endif
     904    double flux = 0;
     905    double wt = 1.0;
     906    double factor = 0;
    913907
    914908    const psImage *Pi = Mi->modelFlux;
    915909    assert (Pi != NULL);
    916910
    917 # if (HAVE_MODEL_VAR)
    918911    const psImage *Wi = NULL;
    919912    switch (fitVarMode) {
     
    921914        break;
    922915      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     916      case PM_SOURCE_PHOTFIT_MODEL_SKY:
     917        Wi = Mi->variance;
     918        psAssert (Wi, "programming error");
     919        break;
     920      case PM_SOURCE_PHOTFIT_MODEL_VAR:
     921        Wi = Mi->modelVar;
     922        psAssert (Wi, "programming error");
     923        break;
     924      case PM_SOURCE_PHOTFIT_NONE:
     925        psAbort("programming error");
     926    }   
     927    const psImage *Ti = Mi->maskObj;
     928    assert (Ti != NULL);
     929
     930    for (int yi = 0; yi < Pi->numRows; yi++) {
     931        for (int xi = 0; xi < Pi->numCols; xi++) {
     932            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal)
     933                continue;
     934            if (fitVarMode != PM_SOURCE_PHOTFIT_CONST) {
     935                wt = covarFactor * Wi->data.F32[yi][xi];
     936                if (wt == 0) continue;
     937            }
     938            switch (term) {
     939              case 0:
     940                factor = 1;
     941                break;
     942              case 1:
     943                factor = xi + Pi->col0;
     944                break;
     945              case 2:
     946                factor = yi + Pi->row0;
     947                break;
     948              default:
     949                psAbort("invalid term for pmSourceWeight");
     950            }
     951
     952            // wt is 1.0 for CONST
     953            flux += (factor * Pi->data.F32[yi][xi]) / wt;
     954        }
     955    }
     956    return flux;
     957}
     958
     959double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
     960{
     961    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     962    PS_ASSERT_PTR_NON_NULL(Mj, NAN);
     963    int Xs, Xe, Ys, Ye;
     964    int xi, xj, yi, yj;
     965    int xIs, xJs, yIs, yJs;
     966    int xIe, yIe;
     967    double flux;
     968    double wt = 1.0;
     969
     970    const psImage *Pi = Mi->modelFlux;
     971    assert (Pi != NULL);
     972    const psImage *Pj = Mj->modelFlux;
     973    assert (Pj != NULL);
     974
     975    const psImage *Wi = NULL;
     976    switch (fitVarMode) {
     977      case PM_SOURCE_PHOTFIT_CONST:
     978        break;
     979      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     980      case PM_SOURCE_PHOTFIT_MODEL_SKY:
     981        Wi = Mi->variance;
     982        psAssert (Wi, "programming error");
     983        break;
     984      case PM_SOURCE_PHOTFIT_MODEL_VAR:
     985        Wi = Mi->modelVar;
     986        psAssert (Wi, "programming error");
     987        break;
     988      case PM_SOURCE_PHOTFIT_NONE:
     989        psAbort("programming error");
     990    }   
     991
     992    const psImage *Ti = Mi->maskObj;
     993    assert (Ti != NULL);
     994    const psImage *Tj = Mj->maskObj;
     995    assert (Tj != NULL);
     996
     997    Xs = PS_MAX (Pi->col0, Pj->col0);
     998    Xe = PS_MIN (Pi->col0 + Pi->numCols, Pj->col0 + Pj->numCols);
     999
     1000    Ys = PS_MAX (Pi->row0, Pj->row0);
     1001    Ye = PS_MIN (Pi->row0 + Pi->numRows, Pj->row0 + Pj->numRows);
     1002
     1003    xIs = Xs - Pi->col0;
     1004    xJs = Xs - Pj->col0;
     1005    yIs = Ys - Pi->row0;
     1006    yJs = Ys - Pj->row0;
     1007
     1008    xIe = Xe - Pi->col0;
     1009    yIe = Ye - Pi->row0;
     1010
     1011    // note that weight is addressing the same image pixels
     1012    flux = 0;
     1013    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
     1014        for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
     1015            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal)
     1016                continue;
     1017            if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj] & maskVal)
     1018                continue;
     1019
     1020            float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
     1021            switch (fitVarMode) {
     1022              case PM_SOURCE_PHOTFIT_CONST:
     1023                wt = 1.0;
     1024                break;
     1025              case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1026              case PM_SOURCE_PHOTFIT_MODEL_SKY:
     1027              case PM_SOURCE_PHOTFIT_MODEL_VAR:
     1028                wt = covarFactor * Wi->data.F32[yi][xi];
     1029                break;
     1030              case PM_SOURCE_PHOTFIT_NONE:
     1031                psAbort("programming error");
     1032            }
     1033            // skip pixels with nonsense weight values
     1034            if (wt <= 0) continue;
     1035
     1036            flux += value / wt;
     1037        }
     1038    }
     1039    return flux;
     1040}
     1041
     1042double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
     1043{
     1044    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     1045    PS_ASSERT_PTR_NON_NULL(Mj, NAN);
     1046    int Xs, Xe, Ys, Ye;
     1047    int xi, xj, yi, yj;
     1048    int xIs, xJs, yIs, yJs;
     1049    int xIe, yIe;
     1050    double flux;
     1051    double wt = 1.0;
     1052
     1053    const psImage *Pi = Mi->pixels;
     1054    assert (Pi != NULL);
     1055    const psImage *Pj = Mj->modelFlux;
     1056    assert (Pj != NULL);
     1057
     1058    const psImage *Wi = NULL;
     1059    switch (fitVarMode) {
     1060      case PM_SOURCE_PHOTFIT_CONST:
     1061        break;
     1062      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1063      case PM_SOURCE_PHOTFIT_MODEL_SKY:
    9231064        Wi = Mi->variance;
    9241065        psAssert (Wi, "programming error");
     
    9311072        psAbort("programming error");
    9321073    }   
    933 # else
    934     const psImage *Wi = Mi->variance;
    935     if (!unweighted_sum) {
    936         assert (Wi != NULL);
    937     }
    938 # endif
    939     const psImage *Ti = Mi->maskObj;
    940     assert (Ti != NULL);
    941 
    942     for (int yi = 0; yi < Pi->numRows; yi++) {
    943         for (int xi = 0; xi < Pi->numCols; xi++) {
    944             if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal)
    945                 continue;
    946 # if (HAVE_MODEL_VAR)
    947             if (fitVarMode != PM_SOURCE_PHOTFIT_CONST) {
    948                 wt = covarFactor * Wi->data.F32[yi][xi];
    949                 if (wt == 0) continue;
    950             }
    951 # else
    952             if (!unweighted_sum) {
    953                 wt = covarFactor * Wi->data.F32[yi][xi];
    954                 if (wt == 0)
    955                     continue;
    956             }
    957 # endif
    958 
    959             switch (term) {
    960               case 0:
    961                 factor = 1;
    962                 break;
    963               case 1:
    964                 factor = xi + Pi->col0;
    965                 break;
    966               case 2:
    967                 factor = yi + Pi->row0;
    968                 break;
    969               default:
    970                 psAbort("invalid term for pmSourceWeight");
    971             }
    972 
    973 # if (HAVE_MODEL_VAR)
    974             // wt is 1.0 for CONST
    975             flux += (factor * Pi->data.F32[yi][xi]) / wt;
    976 # else
    977             if (unweighted_sum) {
    978                 flux += (factor * Pi->data.F32[yi][xi]);
    979             } else {
    980                 flux += (factor * Pi->data.F32[yi][xi]) / wt;
    981             }
    982 # endif
    983         }
    984     }
    985     return flux;
    986 }
    987 
    988 # if (HAVE_MODEL_VAR)
    989 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
    990 # else
    991 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
    992 # endif
    993 {
    994     PS_ASSERT_PTR_NON_NULL(Mi, NAN);
    995     PS_ASSERT_PTR_NON_NULL(Mj, NAN);
    996     int Xs, Xe, Ys, Ye;
    997     int xi, xj, yi, yj;
    998     int xIs, xJs, yIs, yJs;
    999     int xIe, yIe;
    1000 # if (HAVE_MODEL_VAR)
    1001     double flux;
    1002     double wt = 1.0;
    1003 # else
    1004     double flux, wt;
    1005 # endif
    1006 
    1007     const psImage *Pi = Mi->modelFlux;
    1008     assert (Pi != NULL);
    1009     const psImage *Pj = Mj->modelFlux;
    1010     assert (Pj != NULL);
    1011 
    1012 # if (HAVE_MODEL_VAR)
    1013     const psImage *Wi = NULL;
    1014     switch (fitVarMode) {
    1015       case PM_SOURCE_PHOTFIT_CONST:
    1016         break;
    1017       case PM_SOURCE_PHOTFIT_IMAGE_VAR:
    1018         Wi = Mi->variance;
    1019         psAssert (Wi, "programming error");
    1020         break;
    1021       case PM_SOURCE_PHOTFIT_MODEL_VAR:
    1022         Wi = Mi->modelVar;
    1023         psAssert (Wi, "programming error");
    1024         break;
    1025       case PM_SOURCE_PHOTFIT_NONE:
    1026         psAbort("programming error");
    1027     }   
    1028 # else
    1029     const psImage *Wi = Mi->variance;
    1030     if (!unweighted_sum) {
    1031         assert (Wi != NULL);
    1032     }
    1033 # endif
    10341074
    10351075    const psImage *Ti = Mi->maskObj;
     
    10521092    yIe = Ye - Pi->row0;
    10531093
    1054     // note that weight is addressing the same image pixels
     1094    // note that weight is addressing the same image pixels,
    10551095    flux = 0;
    10561096    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
     
    10611101                continue;
    10621102
    1063 # if (HAVE_MODEL_VAR)
    10641103            float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
    10651104            switch (fitVarMode) {
     
    10681107                break;
    10691108              case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1109              case PM_SOURCE_PHOTFIT_MODEL_SKY:
    10701110              case PM_SOURCE_PHOTFIT_MODEL_VAR:
    10711111                wt = covarFactor * Wi->data.F32[yi][xi];
     
    10781118
    10791119            flux += value / wt;
    1080 # else
    1081             // XXX skip the nonsense weight pixels?
    1082             if (unweighted_sum) {
    1083                 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
    1084             } else {
    1085                 wt = covarFactor * Wi->data.F32[yi][xi];
    1086                 if (wt > 0) {
    1087                     flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
    1088                 }
    1089             }
    1090 # endif
    10911120        }
    10921121    }
    10931122    return flux;
    10941123}
    1095 
    1096 # if (HAVE_MODEL_VAR)
    1097 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
    1098 # else
    1099 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
    1100 # endif
    1101 {
    1102     PS_ASSERT_PTR_NON_NULL(Mi, NAN);
    1103     PS_ASSERT_PTR_NON_NULL(Mj, NAN);
    1104     int Xs, Xe, Ys, Ye;
    1105     int xi, xj, yi, yj;
    1106     int xIs, xJs, yIs, yJs;
    1107     int xIe, yIe;
    1108 # if (HAVE_MODEL_VAR)
    1109     double flux;
    1110     double wt = 1.0;
    1111 # else
    1112     double flux, wt;
    1113 # endif
    1114 
    1115     const psImage *Pi = Mi->pixels;
    1116     assert (Pi != NULL);
    1117     const psImage *Pj = Mj->modelFlux;
    1118     assert (Pj != NULL);
    1119 
    1120 # if (HAVE_MODEL_VAR)
    1121     const psImage *Wi = NULL;
    1122     switch (fitVarMode) {
    1123       case PM_SOURCE_PHOTFIT_CONST:
    1124         break;
    1125       case PM_SOURCE_PHOTFIT_IMAGE_VAR:
    1126         Wi = Mi->variance;
    1127         psAssert (Wi, "programming error");
    1128         break;
    1129       case PM_SOURCE_PHOTFIT_MODEL_VAR:
    1130         Wi = Mi->modelVar;
    1131         psAssert (Wi, "programming error");
    1132         break;
    1133       case PM_SOURCE_PHOTFIT_NONE:
    1134         psAbort("programming error");
    1135     }   
    1136 # else
    1137     const psImage *Wi = Mi->variance;
    1138     if (!unweighted_sum) {
    1139         assert (Wi != NULL);
    1140     }
    1141 # endif
    1142 
    1143     const psImage *Ti = Mi->maskObj;
    1144     assert (Ti != NULL);
    1145     const psImage *Tj = Mj->maskObj;
    1146     assert (Tj != NULL);
    1147 
    1148     Xs = PS_MAX (Pi->col0, Pj->col0);
    1149     Xe = PS_MIN (Pi->col0 + Pi->numCols, Pj->col0 + Pj->numCols);
    1150 
    1151     Ys = PS_MAX (Pi->row0, Pj->row0);
    1152     Ye = PS_MIN (Pi->row0 + Pi->numRows, Pj->row0 + Pj->numRows);
    1153 
    1154     xIs = Xs - Pi->col0;
    1155     xJs = Xs - Pj->col0;
    1156     yIs = Ys - Pi->row0;
    1157     yJs = Ys - Pj->row0;
    1158 
    1159     xIe = Xe - Pi->col0;
    1160     yIe = Ye - Pi->row0;
    1161 
    1162     // note that weight is addressing the same image pixels,
    1163     flux = 0;
    1164     for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
    1165         for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
    1166             if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal)
    1167                 continue;
    1168             if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj] & maskVal)
    1169                 continue;
    1170 
    1171 # if (HAVE_MODEL_VAR)
    1172             float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
    1173             switch (fitVarMode) {
    1174               case PM_SOURCE_PHOTFIT_CONST:
    1175                 wt = 1.0;
    1176                 break;
    1177               case PM_SOURCE_PHOTFIT_IMAGE_VAR:
    1178               case PM_SOURCE_PHOTFIT_MODEL_VAR:
    1179                 wt = covarFactor * Wi->data.F32[yi][xi];
    1180                 break;
    1181               case PM_SOURCE_PHOTFIT_NONE:
    1182                 psAbort("programming error");
    1183             }
    1184             // skip pixels with nonsense weight values
    1185             if (wt <= 0) continue;
    1186 
    1187             flux += value / wt;
    1188 
    1189 # else
    1190             // XXX skip the nonsense weight pixels?
    1191             if (unweighted_sum) {
    1192                 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
    1193             } else {
    1194                 wt = covarFactor * Wi->data.F32[yi][xi];
    1195                 if (wt > 0) {
    1196                     flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
    1197                 }
    1198             }
    1199 # endif
    1200         }
    1201     }
    1202     return flux;
    1203 }
  • trunk/psModules/src/objects/pmSourcePhotometry.h

    r33993 r34085  
    3838} pmSourcePhotometryMode;
    3939
    40 # if (HAVE_MODEL_VAR)
    4140typedef enum {
    4241    PM_SOURCE_PHOTFIT_NONE       = 0,
     
    4443    PM_SOURCE_PHOTFIT_IMAGE_VAR  = 2,
    4544    PM_SOURCE_PHOTFIT_MODEL_VAR  = 3,
     45    PM_SOURCE_PHOTFIT_MODEL_SKY  = 4,   // XXX bad name: set variance floor based on mean variance image (variance of sky)
    4646} pmSourceFitVarMode;
    47 # endif
    4847
    4948bool pmSourcePhotometryModel(
     
    8483bool pmSourceMeasureDiffStats (pmSource *source, psImageMaskType maskVal, psImageMaskType markVal);
    8584
    86 # if (HAVE_MODEL_VAR)
    8785double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal);
    8886double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal);
    8987double pmSourceModelWeight(const pmSource *Mi, int term, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal);
    90 # else
    91 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal);
    92 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal);
    93 double pmSourceModelWeight(const pmSource *Mi, int term, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal);
    94 # endif
    9588
    9689bool pmSourceNeighborFlags (pmSource *source);
  • trunk/psModules/test/tap/src/tap.c

    r11550 r34085  
    8787    if(test_name != NULL) {
    8888        va_start(ap, test_name);
    89         vasprintf(&local_test_name, test_name, ap);
     89        int status = vasprintf(&local_test_name, test_name, ap);
     90        if (status) {/* warning? */}
    9091        va_end(ap);
    9192
     
    303304
    304305    va_start(ap, fmt);
    305     asprintf(&skip_msg, fmt, ap);
     306    int status = asprintf(&skip_msg, fmt, ap);
     307    if (status) {/* warning? */}
    306308    va_end(ap);
    307309
     
    328330
    329331    va_start(ap, fmt);
    330     vasprintf(&todo_msg, fmt, ap);
     332    int status = vasprintf(&todo_msg, fmt, ap);
     333    if (status) {/* warning? */}
    331334    va_end(ap);
    332335
Note: See TracChangeset for help on using the changeset viewer.