Changeset 18555
- Timestamp:
- Jul 15, 2008, 10:25:50 AM (18 years ago)
- Location:
- trunk/psphot
- Files:
-
- 19 edited
-
doc/notes.txt (modified) (1 diff)
-
src/Makefile.am (modified) (2 diffs)
-
src/psphot.h (modified) (4 diffs)
-
src/psphotApResid.c (modified) (3 diffs)
-
src/psphotBlendFit.c (modified) (3 diffs)
-
src/psphotChoosePSF.c (modified) (3 diffs)
-
src/psphotExtendedSourceFits.c (modified) (3 diffs)
-
src/psphotFitSourcesLinear.c (modified) (7 diffs)
-
src/psphotGuessModels.c (modified) (2 diffs)
-
src/psphotMagnitudes.c (modified) (2 diffs)
-
src/psphotMaskReadout.c (modified) (1 diff)
-
src/psphotModelTest.c (modified) (4 diffs)
-
src/psphotMosaicChip.c (modified) (1 diff)
-
src/psphotPSFConvModel.c (modified) (2 diffs)
-
src/psphotParseCamera.c (modified) (1 diff)
-
src/psphotRadiusChecks.c (modified) (6 diffs)
-
src/psphotSourceFits.c (modified) (11 diffs)
-
src/psphotSourceStats.c (modified) (3 diffs)
-
src/psphotTestPSF.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/doc/notes.txt
r17396 r18555 1 2 2008.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 1 9 2 10 2008.01.31 -
trunk/psphot/src/Makefile.am
r18450 r18555 15 15 psphotImageLoop.c \ 16 16 psphotMosaicChip.c \ 17 psphotSetMaskBits.c \ 17 18 psphotParseCamera.c 18 19 … … 85 86 psphotAddNoise.c 86 87 88 # dropped? psphotGrowthCurve.c 89 87 90 include_HEADERS = \ 88 91 psphot.h \ -
trunk/psphot/src/psphot.h
r18000 r18555 25 25 bool psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmDetections *detections, pmPSF *psf, psArray *sources); 26 26 bool psphotDefineFiles (pmConfig *config, pmFPAfile *input); 27 bool psphotSetMaskBits (pmConfig *config); 27 28 28 29 // XXX test functions … … 70 71 // functions to set the correct source pixels 71 72 bool 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);73 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal); 74 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal, float dR); 74 75 bool psphotInitRadiusEXT (psMetadata *recipe, pmModelType type); 75 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model );76 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal); 76 77 77 78 // output functions … … 91 92 bool psphotInitLimitsPSF (psMetadata *recipe, pmReadout *readout); 92 93 bool 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 );94 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal); 95 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal, psMaskType markVal); 96 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal); 97 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal); 98 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal, psMaskType markVal); 98 99 99 100 // functions to support simultaneous multi-source fitting … … 124 125 bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal); 125 126 126 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, int psfSize);127 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal, int psfSize); 127 128 128 129 psKernel *psphotKernelFromPSF (pmSource *source, int nPix); -
trunk/psphot/src/psphotApResid.c
r17288 r18555 25 25 } 26 26 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 pixels27 // bit-masks to test for good/bad pixels 28 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); 29 29 assert (maskVal); 30 30 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; 34 37 35 38 // S/N limit to perform full non-linear fits … … 65 68 psf->growth = pmGrowthCurveAlloc (PSF_FIT_PAD, 100.0, REF_RADIUS); 66 69 67 if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH, maskVal, mark )) {70 if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH, maskVal, markVal)) { 68 71 psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections"); 69 72 psFree(psf->growth); psf->growth = NULL; … … 92 95 // get growth-corrected, apTrend-uncorrected magnitudes in scaled apertures 93 96 // 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)) { 95 98 Nskip ++; 96 99 psTrace ("psphot", 3, "skip : bad source mag"); -
trunk/psphot/src/psphotBlendFit.c
r17396 r18555 12 12 psTimerStart ("psphot"); 13 13 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 pixels14 // bit-masks to test for good/bad pixels 15 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); 16 16 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; 17 24 18 25 // source analysis is done in S/N order (brightest first) … … 81 88 // I should try EXT if the source size measurement says it is large 82 89 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)) { 84 91 source->type = PM_SOURCE_TYPE_EXTENDED; 85 92 psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->moments->x, source->moments->y); … … 88 95 } 89 96 } else { 90 if (psphotFitBlend (readout, source, psf, maskVal )) {97 if (psphotFitBlend (readout, source, psf, maskVal, markVal)) { 91 98 source->type = PM_SOURCE_TYPE_STAR; 92 99 psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->moments->x, source->moments->y); -
trunk/psphot/src/psphotChoosePSF.c
r18323 r18555 8 8 psTimerStart ("psphot"); 9 9 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 pixels10 // bit-masks to test for good/bad pixels 11 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); 12 12 assert (maskVal); 13 13 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; 17 20 18 21 // examine PSF sources in S/N order (brightest first) … … 147 150 for (int i = 0; i < modelNames->n; i++) { 148 151 char *modelName = modelNames->data[i]; 149 pmPSFtry *try = pmPSFtryModel (stars, modelName, options, maskVal, mark ); // Attempt at fit152 pmPSFtry *try = pmPSFtryModel (stars, modelName, options, maskVal, markVal); // Attempt at fit 150 153 if (!try) { 151 154 // No big deal --- we'll try another model … … 321 324 // use pmModelSub because modelFlux has not been generated 322 325 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); 324 327 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)); 326 329 } 327 330 -
trunk/psphot/src/psphotExtendedSourceFits.c
r17396 r18555 15 15 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 16 16 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; 17 23 18 24 // perform full extended source non-linear fits? … … 155 161 pmModel *modelFit = NULL; 156 162 if (convolved) { 157 modelFit = psphotPSFConvModel (readout, source, modelType, maskVal, psfSize);163 modelFit = psphotPSFConvModel (readout, source, modelType, maskVal, markVal, psfSize); 158 164 if (!modelFit) { 159 165 psTrace ("psphot", 5, "failed to fit psf-conv model for object at %f, %f", source->moments->x, source->moments->y); … … 168 174 psFree (source->modelFlux); 169 175 source->modelFlux = NULL; 170 modelFit = psphotFitEXT (readout, source, modelType, maskVal );176 modelFit = psphotFitEXT (readout, source, modelType, maskVal, markVal); 171 177 if (!modelFit) { 172 178 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 10 10 // the analysis is performed wrt the simulated pixel values 11 11 12 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER );12 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psMaskType markVal); 13 13 14 14 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final) { … … 22 22 psTimerStart ("psphot"); 23 23 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 pixels24 // bit-masks to test for good/bad pixels 25 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); 26 26 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; 27 34 28 35 // source analysis is done in spatial order … … 157 164 158 165 // 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); 160 167 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "set border: %f (%d elements)\n", psTimerMark ("psphot"), sparse->Nelem); 161 168 … … 221 228 // on the pixels which correspond to all of the sources of interest. These elements fill in 222 229 // 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 ) {230 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psMaskType markVal) { 224 231 225 232 // generate the image-wide weight terms … … 227 234 psRegion fullArray = psRegionSet (0, 0, 0, 0); 228 235 fullArray = psRegionForImage (readout->mask, fullArray); 229 psImageMaskRegion (readout->mask, fullArray, "OR", PM_MASK_MARK);236 psImageMaskRegion (readout->mask, fullArray, "OR", markVal); 230 237 psLogMsg ("psphot.ensemble", PS_LOG_INFO, "step 1: %f sec\n", psTimerMark ("psphot")); 231 238 … … 237 244 float x = model->params->data.F32[PM_PAR_XPOS]; 238 245 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)); 240 247 } 241 248 psLogMsg ("psphot.ensemble", PS_LOG_INFO, "step 2: %f sec\n", psTimerMark ("psphot")); … … 279 286 280 287 // 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)); 282 289 psLogMsg ("psphot.ensemble", PS_LOG_INFO, "step 4: %f sec\n", psTimerMark ("psphot")); 283 290 -
trunk/psphot/src/psphotGuessModels.c
r16820 r18555 23 23 psTimerStart ("psphot"); 24 24 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 pixels25 // bit-masks to test for good/bad pixels 26 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); 27 27 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; 28 35 29 36 // setup the PSF fit radius details … … 85 92 // XXX need to define the guess flux? 86 93 // set the fit radius based on the object flux limit and the model 87 psphotCheckRadiusPSF (readout, source, modelPSF );94 psphotCheckRadiusPSF (readout, source, modelPSF, markVal); 88 95 89 96 // set the source PSF model -
trunk/psphot/src/psphotMagnitudes.c
r16820 r18555 8 8 psTimerStart ("psphot"); 9 9 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 pixels10 // bit-masks to test for good/bad pixels 11 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); 12 12 assert (maskVal); 13 13 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; 17 20 18 21 pmSourceMagnitudesInit (recipe); … … 35 38 for (int i = 0; i < sources->n; i++) { 36 39 pmSource *source = (pmSource *) sources->data[i]; 37 status = pmSourceMagnitudes (source, psf, photMode, maskVal , mark);40 status = pmSourceMagnitudes (source, psf, photMode, maskVal); 38 41 if (status) Nap ++; 39 42 -
trunk/psphot/src/psphotMaskReadout.c
r16820 r18555 7 7 8 8 // ** 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 15 11 psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat); 16 12 17 psMaskType maskBad = pmConfigMask ("BAD",config); // Mask value for bad pixels13 psMaskType maskBad = pmConfigMaskGet("BAD", config); // Mask value for bad pixels 18 14 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 pixels22 if (!maskVal) {23 const char *maskValStr = psMetadataLookupStr(NULL, recipe, "MASKVAL"); // String with mask names24 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 against29 psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal);30 assert (maskVal);31 }32 15 33 16 // generate mask & weight images if they don't already exit -
trunk/psphot/src/psphotModelTest.c
r17396 r18555 12 12 pmSourceFitMode fitMode; 13 13 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"); 17 16 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; 19 24 20 25 // run model fitting tests on a single source? … … 130 135 131 136 // 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); 133 138 if (!status) psAbort("pmSourceLocalSky error"); 134 139 … … 195 200 196 201 // 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); 198 203 psphotSaveImage (NULL, source->maskObj, "mask1.fits"); 199 204 … … 213 218 assert (status); 214 219 215 model = psphotPSFConvModel (readout, source, modelType, maskVal, psfSize);220 model = psphotPSFConvModel (readout, source, modelType, maskVal, markVal, psfSize); 216 221 params = model->params->data.F32; 217 222 } else { -
trunk/psphot/src/psphotMosaicChip.c
r13900 r18555 25 25 } 26 26 27 psMaskType blankMask = pmConfigMaskGet("BLANK", config); 28 27 29 // mosaic the chip, forcing a deep copy (resulting images are not subimages) 28 30 psTrace("pmChipMosaic", 5, "mosaic chip %s to %s (xbin,ybin: %d,%d to %d,%d)\n", 29 31 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); 31 33 return status; 32 34 } -
trunk/psphot/src/psphotPSFConvModel.c
r17396 r18555 9 9 // modelConv to contain the fitted parameters, and the modelFlux to contain the 10 10 // convolved model image. 11 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, int psfSize) {11 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal, int psfSize) { 12 12 13 // maskVal is used to test for rejected pixels, and must include markVal 14 maskVal |= markVal; 15 13 16 // make sure we save a cached copy of the psf flux 14 17 pmSourceCachePSF (source, maskVal); … … 65 68 psVector *dparams = modelConv->dparams; 66 69 67 psphotCheckRadiusEXT (readout, source, modelConv );70 psphotCheckRadiusEXT (readout, source, modelConv, markVal); 68 71 69 72 // create the minimization constraints -
trunk/psphot/src/psphotParseCamera.c
r13528 r18555 17 17 // if MASK or WEIGHT was supplied on command line, bind files to 'load' 18 18 // the mask and weight will be mosaicked with the image 19 pmFPAfile BindFromArgs (&status, load, config, "PSPHOT.MASK","MASK");19 pmFPAfile *mask = pmFPAfileBindFromArgs (&status, load, config, "PSPHOT.MASK", "MASK"); 20 20 if (!status) { 21 21 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 22 22 return NULL; 23 23 } 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 25 43 pmFPAfileBindFromArgs (&status, load, config, "PSPHOT.WEIGHT", "WEIGHT"); 26 44 if (!status) { -
trunk/psphot/src/psphotRadiusChecks.c
r14655 r18555 7 7 // and a per-object radius is calculated) 8 8 9 bool psphotInitRadiusPSF(const psMetadata *recipe, 10 const pmModelType type) 11 { 9 bool psphotInitRadiusPSF(const psMetadata *recipe, const pmModelType type) { 10 12 11 bool status = true; 13 12 … … 20 19 21 20 // call this function whenever you (re)-define the PSF model 22 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model )21 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal) 23 22 { 24 23 psF32 *PAR = model->params->data.F32; … … 47 46 48 47 // 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); 50 49 return status; 51 50 } 52 51 53 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR) {52 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal, float dR) { 54 53 55 54 psF32 *PAR = model->params->data.F32; … … 69 68 70 69 // 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); 72 71 return status; 73 72 } … … 87 86 88 87 // call this function whenever you (re)-define the EXT model 89 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model ) {88 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal) { 90 89 91 90 psF32 *PAR = model->params->data.F32; … … 102 101 103 102 // 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); 105 104 return status; 106 105 } -
trunk/psphot/src/psphotSourceFits.c
r17396 r18555 21 21 } 22 22 23 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal ) {23 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) { 24 24 25 25 float x, y, dR; 26 27 // maskVal is used to test for rejected pixels, and must include markVal 28 maskVal |= markVal; 26 29 27 30 // if this source is not a possible blend, just fit as PSF 28 31 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); 30 33 return status; 31 34 } … … 80 83 81 84 // extend source radius as needed 82 psphotCheckRadiusPSFBlend (readout, source, PSF, dR);85 psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, dR); 83 86 84 87 // fit PSF model (set/unset the pixel mask) … … 139 142 } 140 143 141 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal ) {144 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) { 142 145 143 146 double chiTrend; 147 148 // maskVal is used to test for rejected pixels, and must include markVal 149 maskVal |= markVal; 144 150 145 151 NfitPSF ++; … … 150 156 151 157 // extend source radius as needed 152 psphotCheckRadiusPSF (readout, source, PSF );158 psphotCheckRadiusPSF (readout, source, PSF, markVal); 153 159 154 160 // fit PSF model (set/unset the pixel mask) … … 197 203 } 198 204 199 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal ) {205 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal, psMaskType markVal) { 200 206 201 207 bool okEXT, okDBL; … … 215 221 psTrace ("psphot", 5, "trying blob...\n"); 216 222 217 // psTraceSetLevel("psModules.objects.pmSourceFitSet", 5); 223 // maskVal is used to test for rejected pixels, and must include markVal 224 maskVal |= markVal; 218 225 219 226 // this temporary source is used as a place-holder by the psphotEval functions below 220 227 pmSource *tmpSrc = pmSourceAlloc (); 221 228 222 pmModel *EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal );229 pmModel *EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal, markVal); 223 230 okEXT = psphotEvalEXT (tmpSrc, EXT); 224 231 chiEXT = EXT->chisq / EXT->nDOF; 225 232 226 psArray *DBL = psphotFitDBL (readout, source, maskVal );233 psArray *DBL = psphotFitDBL (readout, source, maskVal, markVal); 227 234 okDBL = psphotEvalDBL (tmpSrc, DBL->data[0]); 228 235 okDBL &= psphotEvalDBL (tmpSrc, DBL->data[1]); … … 306 313 307 314 // fit a double PSF source to an extended blob 308 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal ) {315 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal, psMaskType markVal) { 309 316 310 317 float dx, dy; … … 317 324 NfitDBL ++; 318 325 326 // maskVal is used to test for rejected pixels, and must include markVal 327 maskVal |= markVal; 328 319 329 // make a guess at the position of the two sources 320 330 moments.x2 = source->moments->Sx; … … 329 339 // save the PSF model from the Ensemble fit 330 340 PSF = source->modelPSF; 331 psphotCheckRadiusPSFBlend (readout, source, PSF, 8.0);341 psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, 8.0); 332 342 if (isnan(PSF->params->data.F32[1])) psAbort("nan in dbl fit"); 333 343 … … 351 361 } 352 362 353 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal ) {363 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal) { 354 364 355 365 NfitEXT ++; 366 367 // maskVal is used to test for rejected pixels, and must include markVal 368 maskVal |= markVal; 356 369 357 370 // use the source moments, etc to guess basic model parameters … … 361 374 // if (isnan(EXT->params->data.F32[1])) psAbort("nan in ext fit"); 362 375 363 psphotCheckRadiusEXT (readout, source, EXT );376 psphotCheckRadiusEXT (readout, source, EXT, markVal); 364 377 365 378 if ((source->moments->Sx < 1e-3) || (source->moments->Sx < 1e-3)) { -
trunk/psphot/src/psphotSourceStats.c
r18241 r18555 9 9 psTimerStart ("psphot"); 10 10 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 pixels11 // bit-masks to test for good/bad pixels 12 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); 13 13 assert (maskVal); 14 14 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; 18 21 19 22 // determine properties (sky, moments) of initial sources … … 67 70 // measure a local sky value 68 71 // 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); 70 73 if (!status) { 71 74 psFree (source); … … 77 80 // measure the local sky variance (needed if noise is not sqrt(signal)) 78 81 // 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); 80 83 if (!status) { 81 84 psFree (source); -
trunk/psphot/src/psphotTestPSF.c
r13035 r18555 109 109 // set temporary object mask and fit object 110 110 // 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); 112 112 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)); 114 114 115 115 // write fitted parameters to file
Note:
See TracChangeset
for help on using the changeset viewer.
