Changeset 10096
- Timestamp:
- Nov 19, 2006, 7:26:08 PM (20 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 7 edited
-
psphotChoosePSF.c (modified) (5 diffs)
-
psphotEnsemblePSF.c (modified) (7 diffs)
-
psphotImageMedian.c (modified) (1 diff)
-
psphotModelTest.c (modified) (1 diff)
-
psphotOutput.c (modified) (1 diff)
-
psphotTestPSF.c (modified) (2 diffs)
-
psphotWeightBias.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotChoosePSF.c
r10076 r10096 26 26 } 27 27 28 // supply the measured sky variance for optional constant errors (non-poissonian) 29 float SKY_STDEV = psMetadataLookupF32 (&status, recipe, "SKY_STDEV"); 30 if (!status) { 31 SKY_STDEV = 1.0; 32 psWarning("SKY_STDEV is not set --- defaulting to %f\n", SKY_STDEV); 33 } 28 34 // use poissonian errors or local-sky errors 29 35 bool POISSON_ERRORS = psMetadataLookupBool (&status, recipe, "POISSON_ERRORS"); … … 32 38 psWarning("POISSON_ERRORS is not set in the recipe --- defaulting to true.\n"); 33 39 } 40 pmSourceFitModelInit (15, 0.01, PS_SQR(SKY_STDEV), POISSON_ERRORS); 34 41 35 42 // how to model the PSF variations across the field … … 48 55 } 49 56 50 pmSourceFitModelInit (15, 0.1, POISSON_ERRORS);51 52 57 stars = psArrayAllocEmpty (sources->n); 53 58 … … 94 99 modelName = item->data.V; 95 100 models->data[i] = pmPSFtryModel (stars, modelName, RADIUS, POISSON_ERRORS, psfTrendMask); 96 }97 98 // XXX test dump of psf stars and model99 if (1) {100 psphotSaveImage (NULL, readout->image, "testsub.fits");101 pmSourcesWritePSFs (stars, "psfstars.dat");102 try = models->data[0];103 psf = try->psf;104 psMetadata *psfData = pmPSFtoMetadata (NULL, psf);105 psMetadataConfigWrite (psfData, "psfmodel.dat");106 psFree (psfData);107 101 } 108 102 … … 138 132 try = models->data[bestN]; 139 133 134 // XXX test dump of psf star data and psf-subtracted image 135 if (0) { 136 for (int i = 0; i < try->sources->n; i++) { 137 // masked for: bad model fit, outlier in parameters 138 if (try->mask->data.U8[i] & PSFTRY_MASK_ALL) 139 continue; 140 141 pmSource *source = try->sources->data[i]; 142 float x = source->modelPSF->params->data.F32[PM_PAR_XPOS]; 143 float y = source->modelPSF->params->data.F32[PM_PAR_YPOS]; 144 145 // set the mask and subtract the PSF model 146 psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PM_MASK_MARK); 147 pmModelSub (source->pixels, source->mask, source->modelPSF, false, false); 148 psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_U8(PM_MASK_MARK)); 149 } 150 151 psphotSaveImage (NULL, readout->image, "psfstars.fits"); 152 pmSourcesWritePSFs (try->sources, "psfstars.dat"); 153 psMetadata *psfData = pmPSFtoMetadata (NULL, try->psf); 154 psMetadataConfigWrite (psfData, "psfmodel.dat"); 155 psFree (psfData); 156 psLogMsg ("psphot.choosePSF", 3, "wrote out psf-subtracted image, psf data, exiting\n"); 157 exit (0); 158 } 159 140 160 // unset the PSFSTAR flag for stars not used for PSF model 141 161 for (int i = 0; i < try->sources->n; i++) { -
trunk/psphot/src/psphotEnsemblePSF.c
r10076 r10096 10 10 // the analysis is performed wrt the simulated pixel values 11 11 12 static bool SetBorderT (psSparseBorder *border, pmReadout *readout, psArray *refSources, psArray *fitSources, psVector *index, bool fitSlope );12 static bool SetBorderT (psSparseBorder *border, pmReadout *readout, psArray *refSources, psArray *fitSources, psVector *index, bool fitSlope, bool constant_weights); 13 13 14 14 bool psphotEnsemblePSF (pmReadout *readout, psArray *refSources, psMetadata *recipe, pmPSF *psf, bool final) { … … 162 162 // set the sky, sky_x, sky_y components of border matrix 163 163 // XXX ignore sky slope terms for now 164 SetBorderT (border, readout, refSources, fitSources, index, false );164 SetBorderT (border, readout, refSources, fitSources, index, false, CONSTANT_PHOTOMETRIC_WEIGHTS); 165 165 166 166 psSparseConstraint constraint; … … 170 170 171 171 // solve for normalization terms (need include local sky?) 172 # if ( 0)172 # if (1) 173 173 psVector *norm = NULL; 174 174 psVector *skyfit = NULL; 175 175 psSparseBorderSolve (&norm, &skyfit, constraint, border, 3); 176 fprintf (stderr, "skyfit: %f\n", skyfit->data.F32[0]); 176 177 # else 177 178 psVector *norm = psSparseSolve (NULL, constraint, sparse, 3); … … 226 227 227 228 // calculate the weight terms for the sky fit component of the matrix 228 static bool SetBorderT (psSparseBorder *border, pmReadout *readout, psArray *refSources, psArray *fitSources, psVector *index, bool fitSlope ) {229 static bool SetBorderT (psSparseBorder *border, pmReadout *readout, psArray *refSources, psArray *fitSources, psVector *index, bool fitSlope, bool constant_weights) { 229 230 230 231 // generate the image-wide weight terms … … 251 252 psU8 **mask = readout->mask->data.U8; 252 253 253 double w, x, y, x2, xy, y2, xc, yc ;254 w = x = y = x2 = xy = y2 = 0;254 double w, x, y, x2, xy, y2, xc, yc, wt, f, fo, fx, fy; 255 w = x = y = x2 = xy = y2 = fo = fx = fy = 0; 255 256 256 257 int col0 = readout->image->col0; … … 260 261 for (int i = 0; i < readout->image->numCols; i++) { 261 262 if (mask[j][i]) continue; 262 w += image[j][i]/weight[j][i]; 263 if (constant_weights) { 264 wt = 1.0; 265 } else { 266 wt = weight[j][i]; 267 } 268 f = image[j][i]; 269 w += 1/wt; 270 fo += f/wt; 271 263 272 if (!fitSlope) continue; 264 273 xc = i + col0; 265 274 yc = j + row0; 266 x += xc*image[j][i]/weight[j][i]; 267 y += yc*image[j][i]/weight[j][i]; 268 x2 += xc*xc*image[j][i]/weight[j][i]; 269 xy += xc*yc*image[j][i]/weight[j][i]; 270 y2 += yc*yc*image[j][i]/weight[j][i]; 275 x += xc/wt; 276 y += yc/wt; 277 x2 += xc*xc/wt; 278 xy += xc*yc/wt; 279 y2 += yc*yc/wt; 280 fx += f*xc/wt; 281 fy += f*yc/wt; 271 282 } 272 283 } … … 276 287 277 288 // set the Border T elements 289 psSparseBorderElementG (border, 0, fo); 278 290 psSparseBorderElementT (border, 0, 0, w); 279 291 if (fitSlope) { 292 psSparseBorderElementG (border, 0, fx); 293 psSparseBorderElementG (border, 0, fy); 280 294 psSparseBorderElementT (border, 1, 0, x); 281 295 psSparseBorderElementT (border, 2, 0, y); -
trunk/psphot/src/psphotImageMedian.c
r9270 r10096 124 124 stats = psImageStats (stats, model->image, NULL, 0); 125 125 psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_MEAN", PS_DATA_F32 | PS_META_REPLACE, "sky model mean", stats->sampleMean); 126 psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_STD V", PS_DATA_F32 | PS_META_REPLACE, "sky model stdev", stats->sampleStdev);126 psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_STDEV", PS_DATA_F32 | PS_META_REPLACE, "sky model stdev", stats->sampleStdev); 127 127 psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_MAX", PS_DATA_F32 | PS_META_REPLACE, "sky model maximum value", stats->max); 128 128 psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_MIN", PS_DATA_F32 | PS_META_REPLACE, "sky model minimum value", stats->min); -
trunk/psphot/src/psphotModelTest.c
r9539 r10096 17 17 bool POISSON_ERRORS = psMetadataLookupBool (&status, recipe, "POISSON_ERRORS"); 18 18 if (!status) POISSON_ERRORS = true; 19 pmSourceFitModelInit (15, 0.1, POISSON_ERRORS);19 pmSourceFitModelInit (15, 0.1, 1.0, POISSON_ERRORS); 20 20 21 21 // run model fitting tests on a single source -
trunk/psphot/src/psphotOutput.c
r9270 r10096 80 80 // sky background model statistics 81 81 psMetadataItemTransfer (header, recipe, "SKY_MEAN"); 82 psMetadataItemTransfer (header, recipe, "SKY_STD V");82 psMetadataItemTransfer (header, recipe, "SKY_STDEV"); 83 83 psMetadataItemTransfer (header, recipe, "SKY_MIN"); 84 84 psMetadataItemTransfer (header, recipe, "SKY_MAX"); -
trunk/psphot/src/psphotTestPSF.c
r9771 r10096 32 32 psWarning("POISSON_ERRORS is not set in the recipe --- defaulting to true.\n"); 33 33 } 34 pmSourceFitModelInit (15, 0.1, 1.0, POISSON_ERRORS); 34 35 35 36 // how to model the PSF variations across the field … … 47 48 } 48 49 } 49 50 pmSourceFitModelInit (15, 0.1, POISSON_ERRORS);51 50 52 51 stars = psArrayAllocEmpty (sources->n); -
trunk/psphot/src/psphotWeightBias.c
r9813 r10096 18 18 19 19 // set fitting method to use non-poisson errors (local sky error) 20 pmSourceFitModelInit (15, 0.1, false); 20 float SKY_STDEV = psMetadataLookupF32 (&status, recipe, "SKY_STDEV"); 21 if (!status) { 22 SKY_STDEV = 1.0; 23 psWarning("SKY_STDEV is not set --- defaulting to %f\n", SKY_STDEV); 24 } 25 // use poissonian errors or local-sky errors 26 bool POISSON_ERRORS = psMetadataLookupBool (&status, recipe, "POISSON_ERRORS"); 27 if (!status) { 28 POISSON_ERRORS = true; 29 psWarning("POISSON_ERRORS is not set in the recipe --- defaulting to true.\n"); 30 } 31 pmSourceFitModelInit (15, 0.1, PS_SQR(SKY_STDEV), POISSON_ERRORS); 21 32 22 33 // option to limit analysis to a specific region
Note:
See TracChangeset
for help on using the changeset viewer.
