IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18555


Ignore:
Timestamp:
Jul 15, 2008, 10:25:50 AM (18 years ago)
Author:
eugene
Message:

re-org and cleanup of the mask bits to make it consistent with the pmConfigMaskSetBits concepts; ensure mark and mask are correctly used

Location:
trunk/psphot
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/doc/notes.txt

    r17396 r18555  
     1
     22008.06.25
     3
     4 timing : footprints
     5
     6 on GPC1, with FFT:
     7    pass 1 :     convolved with grow disc: 17.558344 sec
     8    pass 2 :     convolved with grow disc: 8.915036 sec
    19
    2102008.01.31
  • trunk/psphot/src/Makefile.am

    r18450 r18555  
    1515        psphotImageLoop.c       \
    1616        psphotMosaicChip.c      \
     17        psphotSetMaskBits.c     \
    1718        psphotParseCamera.c
    1819
     
    8586        psphotAddNoise.c
    8687
     88# dropped? psphotGrowthCurve.c
     89
    8790include_HEADERS = \
    8891        psphot.h \
  • trunk/psphot/src/psphot.h

    r18000 r18555  
    2525bool            psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmDetections *detections, pmPSF *psf, psArray *sources);
    2626bool            psphotDefineFiles (pmConfig *config, pmFPAfile *input);
     27bool            psphotSetMaskBits (pmConfig *config);
    2728
    2829// XXX test functions
     
    7071// functions to set the correct source pixels
    7172bool            psphotInitRadiusPSF (const psMetadata *recipe, const pmModelType type);
    72 bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model);
    73 bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR);
     73bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal);
     74bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal, float dR);
    7475bool            psphotInitRadiusEXT (psMetadata *recipe, pmModelType type);
    75 bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model);
     76bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal);
    7677
    7778// output functions
     
    9192bool            psphotInitLimitsPSF (psMetadata *recipe, pmReadout *readout);
    9293bool            psphotInitLimitsEXT (psMetadata *recipe);
    93 bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal);
    94 bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal);
    95 bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal);
    96 pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal);
    97 psArray        *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal);
     94bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
     95bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
     96bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
     97pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal);
     98psArray        *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal, psMaskType markVal);
    9899
    99100// functions to support simultaneous multi-source fitting
     
    124125bool            psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal);
    125126
    126 pmModel        *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, int psfSize);
     127pmModel        *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal, int psfSize);
    127128
    128129psKernel       *psphotKernelFromPSF (pmSource *source, int nPix);
  • trunk/psphot/src/psphotApResid.c

    r17288 r18555  
    2525    }
    2626
    27     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    28     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     27    // bit-masks to test for good/bad pixels
     28    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    2929    assert (maskVal);
    3030
    31     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    32     psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels
    33     assert (mark);
     31    // bit-mask to mark pixels not used in analysis
     32    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     33    assert (markVal);
     34
     35    // maskVal is used to test for rejected pixels, and must include markVal
     36    maskVal |= markVal;
    3437
    3538    // S/N limit to perform full non-linear fits
     
    6568    psf->growth = pmGrowthCurveAlloc (PSF_FIT_PAD, 100.0, REF_RADIUS);
    6669
    67     if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH, maskVal, mark)) {
     70    if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH, maskVal, markVal)) {
    6871        psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections");
    6972        psFree(psf->growth); psf->growth = NULL;
     
    9295        // get growth-corrected, apTrend-uncorrected magnitudes in scaled apertures
    9396        // will fail if below S/N threshold or model is missing
    94         if (!pmSourceMagnitudes (source, psf, photMode, maskVal, mark)) {
     97        if (!pmSourceMagnitudes (source, psf, photMode, maskVal)) {
    9598            Nskip ++;
    9699            psTrace ("psphot", 3, "skip : bad source mag");
  • trunk/psphot/src/psphotBlendFit.c

    r17396 r18555  
    1212    psTimerStart ("psphot");
    1313
    14     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    15     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     14    // bit-masks to test for good/bad pixels
     15    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    1616    assert (maskVal);
     17
     18    // bit-mask to mark pixels not used in analysis
     19    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     20    assert (markVal);
     21
     22    // maskVal is used to test for rejected pixels, and must include markVal
     23    maskVal |= markVal;
    1724
    1825    // source analysis is done in S/N order (brightest first)
     
    8188        // I should try EXT if the source size measurement says it is large
    8289        if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) {
    83             if (psphotFitBlob (readout, source, sources, psf, maskVal)) {
     90            if (psphotFitBlob (readout, source, sources, psf, maskVal, markVal)) {
    8491                source->type = PM_SOURCE_TYPE_EXTENDED;
    8592                psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->moments->x, source->moments->y);
     
    8895            }
    8996        } else {
    90             if (psphotFitBlend (readout, source, psf, maskVal)) {
     97            if (psphotFitBlend (readout, source, psf, maskVal, markVal)) {
    9198                source->type = PM_SOURCE_TYPE_STAR;
    9299                psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->moments->x, source->moments->y);
  • trunk/psphot/src/psphotChoosePSF.c

    r18323 r18555  
    88    psTimerStart ("psphot");
    99
    10     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    11     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     10    // bit-masks to test for good/bad pixels
     11    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    1212    assert (maskVal);
    1313
    14     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    15     psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels
    16     assert (mark);
     14    // bit-mask to mark pixels not used in analysis
     15    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     16    assert (markVal);
     17
     18    // maskVal is used to test for rejected pixels, and must include markVal
     19    maskVal |= markVal;
    1720
    1821    // examine PSF sources in S/N order (brightest first)
     
    147150    for (int i = 0; i < modelNames->n; i++) {
    148151        char *modelName = modelNames->data[i];
    149         pmPSFtry *try = pmPSFtryModel (stars, modelName, options, maskVal, mark); // Attempt at fit
     152        pmPSFtry *try = pmPSFtryModel (stars, modelName, options, maskVal, markVal); // Attempt at fit
    150153        if (!try) {
    151154            // No big deal --- we'll try another model
     
    321324            // use pmModelSub because modelFlux has not been generated
    322325            assert (source->maskObj);
    323             psImageKeepCircle (source->maskObj, x, y, options->radius, "OR", PM_MASK_MARK);
     326            psImageKeepCircle (source->maskObj, x, y, options->radius, "OR", markVal);
    324327            pmModelSub (source->pixels, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL, maskVal);
    325             psImageKeepCircle (source->maskObj, x, y, options->radius, "AND", PS_NOT_U8(PM_MASK_MARK));
     328            psImageKeepCircle (source->maskObj, x, y, options->radius, "AND", PS_NOT_U8(markVal));
    326329        }
    327330
  • trunk/psphot/src/psphotExtendedSourceFits.c

    r17396 r18555  
    1515    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    1616    assert (maskVal);
     17
     18    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels
     19    assert (markVal);
     20
     21    // maskVal is used to test for rejected pixels, and must include markVal
     22    maskVal |= markVal;
    1723
    1824    // perform full extended source non-linear fits?
     
    155161          pmModel *modelFit = NULL;
    156162          if (convolved) {
    157               modelFit = psphotPSFConvModel (readout, source, modelType, maskVal, psfSize);
     163              modelFit = psphotPSFConvModel (readout, source, modelType, maskVal, markVal, psfSize);
    158164              if (!modelFit) {
    159165                  psTrace ("psphot", 5, "failed to fit psf-conv model for object at %f, %f", source->moments->x, source->moments->y);
     
    168174              psFree (source->modelFlux);
    169175              source->modelFlux = NULL;
    170               modelFit = psphotFitEXT (readout, source, modelType, maskVal);
     176              modelFit = psphotFitEXT (readout, source, modelType, maskVal, markVal);
    171177              if (!modelFit) {
    172178                  psTrace ("psphot", 5, "failed to fit plain model for object at %f, %f", source->moments->x, source->moments->y);
  • trunk/psphot/src/psphotFitSourcesLinear.c

    r17516 r18555  
    1010// the analysis is performed wrt the simulated pixel values
    1111
    12 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER);
     12static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psMaskType markVal);
    1313
    1414bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final) {
     
    2222    psTimerStart ("psphot");
    2323
    24     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    25     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     24    // bit-masks to test for good/bad pixels
     25    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    2626    assert (maskVal);
     27
     28    // bit-mask to mark pixels not used in analysis
     29    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     30    assert (markVal);
     31
     32    // maskVal is used to test for rejected pixels, and must include markVal
     33    maskVal |= markVal;
    2734
    2835    // source analysis is done in spatial order
     
    157164
    158165    // set the sky, sky_x, sky_y components of border matrix
    159     SetBorderMatrixElements (border, readout, fitSources, CONSTANT_PHOTOMETRIC_WEIGHTS, SKY_FIT_ORDER);
     166    SetBorderMatrixElements (border, readout, fitSources, CONSTANT_PHOTOMETRIC_WEIGHTS, SKY_FIT_ORDER, markVal);
    160167    psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "set border: %f (%d elements)\n", psTimerMark ("psphot"), sparse->Nelem);
    161168
     
    221228// on the pixels which correspond to all of the sources of interest.  These elements fill in
    222229// the border matrix components in the sparse matrix equation.
    223 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER) {
     230static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psMaskType markVal) {
    224231
    225232    // generate the image-wide weight terms
     
    227234    psRegion fullArray = psRegionSet (0, 0, 0, 0);
    228235    fullArray = psRegionForImage (readout->mask, fullArray);
    229     psImageMaskRegion (readout->mask, fullArray, "OR", PM_MASK_MARK);
     236    psImageMaskRegion (readout->mask, fullArray, "OR", markVal);
    230237    psLogMsg ("psphot.ensemble", PS_LOG_INFO, "step 1: %f sec\n", psTimerMark ("psphot"));
    231238
     
    237244        float x = model->params->data.F32[PM_PAR_XPOS];
    238245        float y = model->params->data.F32[PM_PAR_YPOS];
    239         psImageMaskCircle (source->maskView, x, y, model->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));
     246        psImageMaskCircle (source->maskView, x, y, model->radiusFit, "AND", PS_NOT_U8(markVal));
    240247    }
    241248    psLogMsg ("psphot.ensemble", PS_LOG_INFO, "step 2: %f sec\n", psTimerMark ("psphot"));
     
    279286
    280287    // turn off MARK for all image pixels
    281     psImageMaskRegion (readout->mask, fullArray, "AND", PS_NOT_U8(PM_MASK_MARK));
     288    psImageMaskRegion (readout->mask, fullArray, "AND", PS_NOT_U8(markVal));
    282289    psLogMsg ("psphot.ensemble", PS_LOG_INFO, "step 4: %f sec\n", psTimerMark ("psphot"));
    283290
  • trunk/psphot/src/psphotGuessModels.c

    r16820 r18555  
    2323    psTimerStart ("psphot");
    2424
    25     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    26     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     25    // bit-masks to test for good/bad pixels
     26    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    2727    assert (maskVal);
     28
     29    // bit-mask to mark pixels not used in analysis
     30    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     31    assert (markVal);
     32
     33    // maskVal is used to test for rejected pixels, and must include markVal
     34    maskVal |= markVal;
    2835
    2936    // setup the PSF fit radius details
     
    8592        // XXX need to define the guess flux?
    8693        // set the fit radius based on the object flux limit and the model
    87         psphotCheckRadiusPSF (readout, source, modelPSF);
     94        psphotCheckRadiusPSF (readout, source, modelPSF, markVal);
    8895
    8996        // set the source PSF model
  • trunk/psphot/src/psphotMagnitudes.c

    r16820 r18555  
    88    psTimerStart ("psphot");
    99
    10     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    11     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     10    // bit-masks to test for good/bad pixels
     11    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    1212    assert (maskVal);
    1313
    14     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    15     psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels
    16     assert (mark);
     14    // bit-mask to mark pixels not used in analysis
     15    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     16    assert (markVal);
     17
     18    // maskVal is used to test for rejected pixels, and must include markVal
     19    maskVal |= markVal;
    1720
    1821    pmSourceMagnitudesInit (recipe);
     
    3538    for (int i = 0; i < sources->n; i++) {
    3639        pmSource *source = (pmSource *) sources->data[i];
    37         status = pmSourceMagnitudes (source, psf, photMode, maskVal, mark);
     40        status = pmSourceMagnitudes (source, psf, photMode, maskVal);
    3841        if (status) Nap ++;
    3942
  • trunk/psphot/src/psphotMaskReadout.c

    r16820 r18555  
    77
    88    // ** Interpret the mask values:
    9 
    10     // single-bit named masks
    11     psMaskType maskMark = pmConfigMask("MARK",     config); // Mask value for marking
    12     psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.MARK", PS_META_REPLACE, "user-defined mask", maskMark);
    13 
    14     psMaskType maskSat  = pmConfigMask("SAT",      config); // Mask value for saturated pixels
     9    // XXX drop the write to recipe and move config into psphotRoughClass?
     10    psMaskType maskSat  = pmConfigMaskGet("SAT", config); // Mask value for saturated pixels
    1511    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat);
    1612
    17     psMaskType maskBad  = pmConfigMask("BAD",      config); // Mask value for bad pixels
     13    psMaskType maskBad  = pmConfigMaskGet("BAD", config); // Mask value for bad pixels
    1814    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.BAD", PS_META_REPLACE, "user-defined mask", maskBad);
    19 
    20     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    21     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "PSPHOT"); // Mask value for bad pixels
    22     if (!maskVal) {
    23       const char *maskValStr = psMetadataLookupStr(NULL, recipe, "MASKVAL"); // String with mask names
    24       if (!maskValStr) {
    25         psError(PSPHOT_ERR_CONFIG, false, "Missing recipe item: MASKVAL(STR)");
    26         return false;
    27       }
    28       maskVal = pmConfigMask(maskValStr, config); // Mask values to mask against
    29       psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal);
    30       assert (maskVal);
    31     }
    3215
    3316    // generate mask & weight images if they don't already exit
  • trunk/psphot/src/psphotModelTest.c

    r17396 r18555  
    1212    pmSourceFitMode fitMode;
    1313
    14     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    15     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    16     psMaskType mark    = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels
     14    // bit-masks to test for good/bad pixels
     15    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    1716    assert (maskVal);
    18     assert (mark);
     17
     18    // bit-mask to mark pixels not used in analysis
     19    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     20    assert (markVal);
     21
     22    // maskVal is used to test for rejected pixels, and must include markVal
     23    maskVal |= markVal;
    1924
    2025    // run model fitting tests on a single source?
     
    130135
    131136    // find the local sky
    132     status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, mark);
     137    status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    133138    if (!status) psAbort("pmSourceLocalSky error");
    134139
     
    195200
    196201    // define the pixels used for the fit
    197     psImageKeepCircle (source->maskObj, xObj, yObj, RADIUS, "OR", mark);
     202    psImageKeepCircle (source->maskObj, xObj, yObj, RADIUS, "OR", markVal);
    198203    psphotSaveImage (NULL, source->maskObj, "mask1.fits");
    199204
     
    213218        assert (status);
    214219
    215         model = psphotPSFConvModel (readout, source, modelType, maskVal, psfSize);
     220        model = psphotPSFConvModel (readout, source, modelType, maskVal, markVal, psfSize);
    216221        params = model->params->data.F32;
    217222    } else {
  • trunk/psphot/src/psphotMosaicChip.c

    r13900 r18555  
    2525    }
    2626
     27    psMaskType blankMask = pmConfigMaskGet("BLANK", config);
     28
    2729    // mosaic the chip, forcing a deep copy (resulting images are not subimages)
    2830    psTrace("pmChipMosaic", 5, "mosaic chip %s to %s (xbin,ybin: %d,%d to %d,%d)\n",
    2931            in->name, out->name, in->xBin, in->yBin, out->xBin, out->yBin);
    30     status = pmChipMosaic(outChip, inChip, true, pmConfigMask("BLANK", config));
     32    status = pmChipMosaic(outChip, inChip, true, blankMask);
    3133    return status;
    3234}
  • trunk/psphot/src/psphotPSFConvModel.c

    r17396 r18555  
    99// modelConv to contain the fitted parameters, and the modelFlux to contain the
    1010// convolved model image.
    11 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, int psfSize) {
     11pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal, int psfSize) {
    1212   
     13    // maskVal is used to test for rejected pixels, and must include markVal
     14    maskVal |= markVal;
     15
    1316    // make sure we save a cached copy of the psf flux
    1417    pmSourceCachePSF (source, maskVal);
     
    6568    psVector *dparams = modelConv->dparams;
    6669
    67     psphotCheckRadiusEXT (readout, source, modelConv);
     70    psphotCheckRadiusEXT (readout, source, modelConv, markVal);
    6871
    6972    // create the minimization constraints
  • trunk/psphot/src/psphotParseCamera.c

    r13528 r18555  
    1717    // if MASK or WEIGHT was supplied on command line, bind files to 'load'
    1818    // the mask and weight will be mosaicked with the image
    19     pmFPAfileBindFromArgs (&status, load, config, "PSPHOT.MASK",  "MASK");
     19    pmFPAfile *mask = pmFPAfileBindFromArgs (&status, load, config, "PSPHOT.MASK", "MASK");
    2020    if (!status) {
    2121        psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    2222        return NULL;
    2323    }
    24 
     24    if (mask) {
     25        // XXX need to load the mask bit names from one of the headers
     26        // this grabs the first available hdu : no guarantee that it will be valid, though
     27        pmHDU *hdu = pmHDUGetFirst (mask->fpa);
     28        if (!hdu) {
     29            psError(PS_ERR_IO, true, "no valid HDU for PSPHOT.MASK");
     30            return NULL;
     31        }
     32        // XXX should this be done in pmFPAfileIO.c read functions?
     33        if (!pmConfigMaskReadHeader (config, hdu->header)) {
     34            psError(PS_ERR_IO, false, "error in mask bits");
     35            return NULL;
     36        }
     37    }
     38    if (!psphotSetMaskBits (config)) {
     39        psError (PS_ERR_UNKNOWN, false, "failed to set mask bit values");
     40        return NULL;
     41    }
     42   
    2543    pmFPAfileBindFromArgs (&status, load, config, "PSPHOT.WEIGHT", "WEIGHT");
    2644    if (!status) {
  • trunk/psphot/src/psphotRadiusChecks.c

    r14655 r18555  
    77                                        // and a per-object radius is calculated)
    88
    9 bool psphotInitRadiusPSF(const psMetadata *recipe,
    10                          const pmModelType type)
    11 {
     9bool psphotInitRadiusPSF(const psMetadata *recipe, const pmModelType type) {
     10
    1211    bool status = true;
    1312
     
    2019
    2120// call this function whenever you (re)-define the PSF model
    22 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model)
     21bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal)
    2322{
    2423    psF32 *PAR = model->params->data.F32;
     
    4746
    4847    // set the mask to flag the excluded pixels
    49     psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK);
     48    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", markVal);
    5049    return status;
    5150}
    5251
    53 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR) {
     52bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal, float dR) {
    5453
    5554    psF32 *PAR = model->params->data.F32;
     
    6968
    7069    // set the mask to flag the excluded pixels
    71     psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK);
     70    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", markVal);
    7271    return status;
    7372}
     
    8786
    8887// call this function whenever you (re)-define the EXT model
    89 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model) {
     88bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal) {
    9089
    9190    psF32 *PAR = model->params->data.F32;
     
    102101
    103102    // set the mask to flag the excluded pixels
    104     psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK);
     103    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", markVal);
    105104    return status;
    106105}
  • trunk/psphot/src/psphotSourceFits.c

    r17396 r18555  
    2121}
    2222
    23 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal) {
     23bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
    2424
    2525    float x, y, dR;
     26
     27    // maskVal is used to test for rejected pixels, and must include markVal
     28    maskVal |= markVal;
    2629
    2730    // if this source is not a possible blend, just fit as PSF
    2831    if ((source->blends == NULL) || (source->mode & PM_SOURCE_MODE_SATSTAR)) {
    29         bool status = psphotFitPSF (readout, source, psf, maskVal);
     32        bool status = psphotFitPSF (readout, source, psf, maskVal, markVal);
    3033        return status;
    3134    }
     
    8083
    8184    // extend source radius as needed
    82     psphotCheckRadiusPSFBlend (readout, source, PSF, dR);
     85    psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, dR);
    8386
    8487    // fit PSF model (set/unset the pixel mask)
     
    139142}
    140143
    141 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal) {
     144bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
    142145
    143146    double chiTrend;
     147
     148    // maskVal is used to test for rejected pixels, and must include markVal
     149    maskVal |= markVal;
    144150
    145151    NfitPSF ++;
     
    150156
    151157    // extend source radius as needed
    152     psphotCheckRadiusPSF (readout, source, PSF);
     158    psphotCheckRadiusPSF (readout, source, PSF, markVal);
    153159
    154160    // fit PSF model (set/unset the pixel mask)
     
    197203}
    198204
    199 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal) {
     205bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
    200206
    201207    bool okEXT, okDBL;
     
    215221    psTrace ("psphot", 5, "trying blob...\n");
    216222
    217     // psTraceSetLevel("psModules.objects.pmSourceFitSet", 5);
     223    // maskVal is used to test for rejected pixels, and must include markVal
     224    maskVal |= markVal;
    218225
    219226    // this temporary source is used as a place-holder by the psphotEval functions below
    220227    pmSource *tmpSrc = pmSourceAlloc ();
    221228
    222     pmModel *EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal);
     229    pmModel *EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal, markVal);
    223230    okEXT = psphotEvalEXT (tmpSrc, EXT);
    224231    chiEXT = EXT->chisq / EXT->nDOF;
    225232
    226     psArray *DBL = psphotFitDBL (readout, source, maskVal);
     233    psArray *DBL = psphotFitDBL (readout, source, maskVal, markVal);
    227234    okDBL  = psphotEvalDBL (tmpSrc, DBL->data[0]);
    228235    okDBL &= psphotEvalDBL (tmpSrc, DBL->data[1]);
     
    306313
    307314// fit a double PSF source to an extended blob
    308 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal) {
     315psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal, psMaskType markVal) {
    309316
    310317    float dx, dy;
     
    317324    NfitDBL ++;
    318325
     326    // maskVal is used to test for rejected pixels, and must include markVal
     327    maskVal |= markVal;
     328
    319329    // make a guess at the position of the two sources
    320330    moments.x2 = source->moments->Sx;
     
    329339    // save the PSF model from the Ensemble fit
    330340    PSF = source->modelPSF;
    331     psphotCheckRadiusPSFBlend (readout, source, PSF, 8.0);
     341    psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, 8.0);
    332342    if (isnan(PSF->params->data.F32[1])) psAbort("nan in dbl fit");
    333343
     
    351361}
    352362
    353 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal) {
     363pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal) {
    354364
    355365    NfitEXT ++;
     366
     367    // maskVal is used to test for rejected pixels, and must include markVal
     368    maskVal |= markVal;
    356369
    357370    // use the source moments, etc to guess basic model parameters
     
    361374    // if (isnan(EXT->params->data.F32[1])) psAbort("nan in ext fit");
    362375
    363     psphotCheckRadiusEXT (readout, source, EXT);
     376    psphotCheckRadiusEXT (readout, source, EXT, markVal);
    364377
    365378    if ((source->moments->Sx < 1e-3) || (source->moments->Sx < 1e-3)) {
  • trunk/psphot/src/psphotSourceStats.c

    r18241 r18555  
    99    psTimerStart ("psphot");
    1010
    11     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    12     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     11    // bit-masks to test for good/bad pixels
     12    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    1313    assert (maskVal);
    1414
    15     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    16     psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels
    17     assert (mark);
     15    // bit-mask to mark pixels not used in analysis
     16    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     17    assert (markVal);
     18
     19    // maskVal is used to test for rejected pixels, and must include markVal
     20    maskVal |= markVal;
    1821
    1922    // determine properties (sky, moments) of initial sources
     
    6770        // measure a local sky value
    6871        // the local sky is now ignored; kept here for reference only
    69         status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, mark);
     72        status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    7073        if (!status) {
    7174          psFree (source);
     
    7780        // measure the local sky variance (needed if noise is not sqrt(signal))
    7881        // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken
    79         status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, mark);
     82        status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    8083        if (!status) {
    8184          psFree (source);
  • trunk/psphot/src/psphotTestPSF.c

    r13035 r18555  
    109109        // set temporary object mask and fit object
    110110        // fit model as EXT, not PSF
    111         psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PM_MASK_MARK);
     111        psImageKeepCircle (source->mask, x, y, RADIUS, "OR", markVal);
    112112        status = pmSourceFitModel (source, model, PM_SOURCE_FIT_EXT);
    113         psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_U8(PM_MASK_MARK));
     113        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_U8(markVal));
    114114
    115115        // write fitted parameters to file
Note: See TracChangeset for help on using the changeset viewer.