Changeset 5085
- Timestamp:
- Sep 20, 2005, 8:52:23 PM (21 years ago)
- Location:
- trunk/psphot
- Files:
-
- 1 added
- 6 edited
-
Makefile (modified) (1 diff)
-
src/pmObjects_EAM.h (modified) (2 diffs)
-
src/psphot.c (modified) (1 diff)
-
src/psphot.h (modified) (2 diffs)
-
src/psphotArguments.c (modified) (1 diff)
-
src/psphotMagnitudes.c (added)
-
src/psphotOutput.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/Makefile
r5084 r5085 32 32 $(SRC)/psphotSubtractPSF.$(ARCH).o \ 33 33 $(SRC)/psphotSortBySN.$(ARCH).o \ 34 $(SRC)/psphotDefinePixels.$(ARCH).o \ 34 $(SRC)/psphotDefinePixels.$(ARCH).o \ 35 $(SRC)/psphotMagnitudes.$(ARCH).o \ 35 36 $(SRC)/psLibUtils.$(ARCH).o \ 36 37 $(SRC)/psLine.$(ARCH).o \ -
trunk/psphot/src/pmObjects_EAM.h
r5049 r5085 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-09- 14 02:06:55$7 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-09-21 06:52:23 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 162 162 pmModel *modelFLT; ///< FLT Model fit (parameters and type). 163 163 pmSourceType type; ///< Best identification of object. 164 float apMag; 165 float fitMag; 164 166 } 165 167 pmSource; -
trunk/psphot/src/psphot.c
r5058 r5085 46 46 psphotFitGalaxies (imdata, config, sources, sky); 47 47 48 psphotMagnitudes (sources); 49 48 50 // write out data in appropriate format 49 51 psphotOutput (imdata, config, sources, psf, sky); -
trunk/psphot/src/psphot.h
r5084 r5085 21 21 eamReadout *psphotSetup (psMetadata *config); 22 22 psStats *psphotImageStats (eamReadout *imdata, psMetadata *config); 23 psArray *pmPeaksSigmaLimit (eamReadout *imdata, psMetadata *config, psStats *sky);24 23 psArray *psphotSourceStats (eamReadout *imdata, psMetadata *config, psArray *allpeaks); 25 24 pmPSF *psphotChoosePSF (psMetadata *config, psArray *sources, psStats *sky); … … 33 32 int psphotSaveImage (psMetadata *header, psImage *image, char *filename); 34 33 bool psphotDefinePixels (pmSource *mySource, const eamReadout *imdata, psF32 x, psF32 y, psF32 Radius); 34 35 psArray *pmPeaksSigmaLimit (eamReadout *imdata, psMetadata *config, psStats *sky); 36 pmModel *pmSourceMagnitudes (pmSource *source, pmPSF *psf, float apRadius); 37 pmModel *pmSourceSelectMode (pmSource *source); 35 38 36 39 // eamReadout functions -
trunk/psphot/src/psphotArguments.c
r5084 r5085 52 52 psMetadataAdd (config, PS_LIST_HEAD, "PSF_MODEL", PS_META_MULTI, "folder for psf model entries", NULL); 53 53 config = psMetadataConfigParse (config, &Nfail, argv[3], FALSE); 54 fprintf (stderr, "loaded config...\n");55 54 56 55 // identify input image & optional weight & mask images -
trunk/psphot/src/psphotOutput.c
r5084 r5085 70 70 bool pmSourcesWriteOBJ (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 71 71 72 int i, type, status;72 int type; 73 73 pmModel *model; 74 74 psF32 *PAR, *dPAR; 75 float sky, dmag, apMag, fitMag; 76 float x, y, rflux; 77 bool result; 75 float dmag, apResid; 76 bool status; 78 77 79 78 psLine *line = psLineAlloc (104); // 104 is dophot-defined line length … … 85 84 } 86 85 87 float RADIUS = psMetadataLookupF32 (& result, config, "PSF_FIT_RADIUS");88 89 // write sources with models first90 for (i = 0; i < sources->n; i++) {86 float RADIUS = psMetadataLookupF32 (&status, config, "PSF_FIT_RADIUS"); 87 88 // write sources with models 89 for (int i = 0; i < sources->n; i++) { 91 90 pmSource *source = (pmSource *) sources->data[i]; 92 91 93 // use the correct model 94 switch (source->type) { 95 96 // use PSF model with stars 97 case PM_SOURCE_PSFSTAR: 98 case PM_SOURCE_SATSTAR: 99 case PM_SOURCE_GOODSTAR: 100 model = source->modelPSF; 101 break; 102 103 // use FLT model with galaxies 104 case PM_SOURCE_GALAXY: 105 model = source->modelFLT; 106 break; 107 108 // skip defects and poorly fitted stars or galaxies 109 case PM_SOURCE_DEFECT: 110 case PM_SOURCE_SATURATED: 111 case PM_SOURCE_FAINTSTAR: 112 case PM_SOURCE_POOR_FIT_PSF: 113 case PM_SOURCE_POOR_FIT_GAL: 114 case PM_SOURCE_FAIL_FIT_GAL: 115 default: 116 model = NULL; 117 } 92 model = pmSourceMagnitudes (source, psf, RADIUS); 118 93 if (model == NULL) continue; 119 94 … … 121 96 dPAR = model->dparams->data.F32; 122 97 123 x = source->peak->x;124 y = source->peak->y;125 126 // we have already (psphotApplyPSF) defined pixels at least OUTER_RADIUS from source127 // we need to mask pixels to measure the aperture magnitude128 // set aperture mask circle of PSF_FIT_RADIUS129 psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);130 131 // save local sky for later132 sky = model->params->data.F32[0];133 134 // replace source flux135 // XXX EAM : need to add 'sky' boolean option here136 model->params->data.F32[0] = 0;137 pmSourceAddModel (source->pixels, source->mask, model, false);138 model->params->data.F32[0] = sky;139 140 // measure object photometry141 status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask);142 143 // correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS144 rflux = pow (10.0, 0.4*fitMag);145 apMag -= rflux * psf->skyBias * (M_PI * PS_SQR(RADIUS));146 fitMag += psf->ApResid;147 148 // subtract object, leave local sky149 // XXX EAM : need to add 'sky' boolean option here150 model->params->data.F32[0] = 0;151 pmSourceSubModel (source->pixels, source->mask, model, false);152 model->params->data.F32[0] = sky;153 154 // unmask aperture155 psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);156 157 if (status == FALSE) continue;158 159 98 dmag = dPAR[1] / PAR[1]; 160 99 type = pmSourceDophotType (source); 100 apResid = source->apMag - source->fitMag; 101 161 102 psLineInit (line); 162 psLineAdd (line, "%3d", source->type);103 psLineAdd (line, "%3d", type); 163 104 psLineAdd (line, "%8.2f", PAR[2]); 164 105 psLineAdd (line, "%8.2f", PAR[3]); 165 psLineAdd (line, "%8.3f", fitMag);106 psLineAdd (line, "%8.3f", source->fitMag); 166 107 psLineAdd (line, "%6.3f", dmag); 167 108 psLineAdd (line, "%9.2f", PAR[0]); … … 170 111 psLineAdd (line, "%7.2f", PAR[6]); 171 112 psLineAdd (line, "%8.3f", 32.0); 172 psLineAdd (line, "%8.3f", apMag);173 psLineAdd (line, "%8.2f\n", ap Mag - fitMag);113 psLineAdd (line, "%8.3f", source->apMag); 114 psLineAdd (line, "%8.2f\n", apResid); 174 115 fwrite (line->line, 1, line->Nline, f); 175 116 } … … 181 122 bool pmSourcesWriteSX (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 182 123 183 int i, status, flags;184 124 pmModel *model; 185 125 psF32 *PAR, *dPAR; 186 float sky, dmag, apMag, fitMag; 187 float x, y, rflux; 188 bool result; 126 float dmag; 127 bool status; 189 128 190 129 psLine *line = psLineAlloc (110); // 110 is sextractor line length … … 192 131 FILE *f = fopen (filename, "w"); 193 132 if (f == NULL) { 194 psLogMsg ("WriteSourceOBJ", 3, "can't open output file for output %s\n", filename); 195 return false; 196 } 197 198 // aperture radius for ap magnitude 199 // XXX EAM I probably need to measure the fit and ap magnitudes at one location elsewhere 200 // this would have to happen *after* all objects are detected and subtracted 133 psLogMsg ("WriteSourceSX", 3, "can't open output file for output %s\n", filename); 134 return false; 135 } 136 201 137 float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS"); 202 138 203 // write sources with models first204 for (i = 0; i < sources->n; i++) {139 // write sources with models 140 for (int i = 0; i < sources->n; i++) { 205 141 pmSource *source = (pmSource *) sources->data[i]; 206 flags = 0; 207 208 // use the correct model 209 switch (source->type) { 210 211 // use PSF model with stars 212 case PM_SOURCE_SATSTAR: 213 flags = 4; 214 model = source->modelPSF; 215 break; 216 217 case PM_SOURCE_PSFSTAR: 218 case PM_SOURCE_GOODSTAR: 219 model = source->modelPSF; 220 break; 221 222 // use FLT model with galaxies 223 case PM_SOURCE_GALAXY: 224 model = source->modelFLT; 225 break; 226 227 // skip defects and poorly fitted stars or galaxies 228 case PM_SOURCE_DEFECT: 229 case PM_SOURCE_SATURATED: 230 case PM_SOURCE_FAINTSTAR: 231 case PM_SOURCE_POOR_FIT_PSF: 232 case PM_SOURCE_POOR_FIT_GAL: 233 case PM_SOURCE_FAIL_FIT_GAL: 234 default: 235 model = NULL; 236 } 142 143 model = pmSourceMagnitudes (source, psf, RADIUS); 237 144 if (model == NULL) continue; 238 145 … … 240 147 dPAR = model->dparams->data.F32; 241 148 242 x = source->peak->x; 243 y = source->peak->y; 244 245 // we have already (psphotApplyPSF) defined pixels at least OUTER_RADIUS from source 246 // we need to mask pixels to measure the aperture magnitude 247 // set aperture mask circle of PSF_FIT_RADIUS 248 psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED); 249 250 // save local sky for later 251 sky = model->params->data.F32[0]; 252 253 // replace source flux 254 // XXX EAM : need to add 'sky' boolean option here 255 model->params->data.F32[0] = 0; 256 pmSourceAddModel (source->pixels, source->mask, model, false); 257 model->params->data.F32[0] = sky; 258 259 // measure object photometry 260 status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask); 261 262 // correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS 263 rflux = pow (10.0, 0.4*fitMag); 264 apMag -= rflux * psf->skyBias * (M_PI * PS_SQR(RADIUS)); 265 fitMag += psf->ApResid; 266 267 // subtract object, leave local sky 268 // XXX EAM : need to add 'sky' boolean option here 269 model->params->data.F32[0] = 0; 270 pmSourceSubModel (source->pixels, source->mask, model, false); 271 model->params->data.F32[0] = sky; 272 273 // unmask aperture 274 psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED); 275 276 if (status == FALSE) continue; 277 278 // XXX EAM : fix this to return sextractor type and flags 279 // type = pmSourceSextractType (source); 149 // pmSourceSextractType (source, &type, &flags); XXX EAM : implement me... 280 150 281 151 dmag = dPAR[1] / PAR[1]; 152 282 153 psLineInit (line); 283 154 psLineAdd (line, "%5.2f", 0.0); // should be type 284 155 psLineAdd (line, "%11.3f", PAR[2]); 285 156 psLineAdd (line, "%11.3f", PAR[3]); 286 psLineAdd (line, "%9.4f", fitMag);157 psLineAdd (line, "%9.4f", source->fitMag); 287 158 psLineAdd (line, "%9.4f", dmag); 288 159 psLineAdd (line, "%13.4f", PAR[0]); … … 291 162 psLineAdd (line, "%6.1f", 0.0); // should be Theta 292 163 psLineAdd (line, "%9.4f", 32.0); // should be MAG_ISO 293 psLineAdd (line, "%9.4f", apMag);164 psLineAdd (line, "%9.4f", source->apMag); 294 165 psLineAdd (line, "%4d\n", 0); // should be flags 295 166 fwrite (line->line, 1, line->Nline, f); … … 310 181 bool result; 311 182 183 // find config information for output header 184 float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS"); 185 float ZERO_POINT = psMetadataLookupF32 (&result, config, "ZERO_POINT"); 186 char *PHOTCODE = psMetadataLookupF32 (&result, config, "PHOTCODE"); 187 188 // write necessary information to output header 189 psMetadataAdd (imdata->header, PS_LIST_TAIL, "NSTARS", PS_META_S32 | PS_META_REPLACE, "NUMBER OF STARS", sources->n); 190 psMetadataAdd (imdata->header, PS_LIST_TAIL, "ZERO_PT", PS_META_F32 | PS_META_REPLACE, "zero point", ZERO_POINT); 191 psMetadataAdd (imdata->header, PS_LIST_TAIL, "APMIFIT", PS_META_F32 | PS_META_REPLACE, "aperture residual", psf->ApResid); 192 psMetadataAdd (imdata->header, PS_LIST_TAIL, "dAPMIFIT", PS_META_F32 | PS_META_REPLACE, "ap residual scatter", psf->dApResid); 193 psMetadataAdd (imdata->header, PS_LIST_TAIL, "SKYBIAS", PS_META_F32 | PS_META_REPLACE, "aperture sky bias", psf->skyBias); 194 psMetadataAdd (imdata->header, PS_LIST_TAIL, "PHOTCODE", PS_META_STR | PS_META_REPLACE, "photometry code", PHOTCODE); 195 psMetadataAdd (imdata->header, PS_LIST_TAIL, "FWHM_X", PS_META_F32 | PS_META_REPLACE, "PSF FWHM X", 0.0); 196 psMetadataAdd (imdata->header, PS_LIST_TAIL, "FWHM_Y", PS_META_F32 | PS_META_REPLACE, "PSF FWHM Y", 0.0); 197 psMetadataAdd (imdata->header, PS_LIST_TAIL, "ANGLE", PS_META_F32 | PS_META_REPLACE, "PSF ANGLE", 0.0); 198 psMetadataAdd (imdata->header, PS_LIST_TAIL, "FSATUR", PS_META_F32 | PS_META_REPLACE, "SATURATION MAG", 0.0); 199 psMetadataAdd (imdata->header, PS_LIST_TAIL, "FLIMIT", PS_META_F32 | PS_META_REPLACE, "COMPLETENESS MAG", 0.0); 200 312 201 // create file, write-out header 313 202 unlink (filename); … … 333 222 psLine *line = psLineAlloc (67); // 66 is imclean-defined line length 334 223 335 float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");336 337 // XXX EAM : need to add these concepts to the header (from psf and config)338 // fits_modify (header, "ZERO_PT", "%lf", 1, ZERO_POINT);339 // fits_modify (header, "FWHM_X", "%lf", 1, FWHMx);340 // fits_modify (header, "FWHM_Y", "%lf", 1, FWHMy);341 // fits_modify (header, "ANGLE", "%lf", 1, angle);342 // fits_modify (header, "FSATUR", "%lf", 1, saturate); // can use 0.0343 // fits_modify (header, "FLIMIT", "%lf", 1, complete); // can use 0.0344 // fits_modify (header, "NSTARS", "%d", 1, N);345 346 224 // write sources with models first 347 225 for (i = 0; i < sources->n; i++) { 348 226 pmSource *source = (pmSource *) sources->data[i]; 349 227 350 // use the correct model 351 switch (source->type) { 352 353 // use PSF model with stars 354 case PM_SOURCE_PSFSTAR: 355 case PM_SOURCE_SATSTAR: 356 case PM_SOURCE_GOODSTAR: 357 model = source->modelPSF; 358 break; 359 360 // use FLT model with galaxies 361 case PM_SOURCE_GALAXY: 362 model = source->modelFLT; 363 break; 364 365 // skip defects and poorly fitted stars or galaxies 366 case PM_SOURCE_DEFECT: 367 case PM_SOURCE_SATURATED: 368 case PM_SOURCE_FAINTSTAR: 369 case PM_SOURCE_POOR_FIT_PSF: 370 case PM_SOURCE_POOR_FIT_GAL: 371 case PM_SOURCE_FAIL_FIT_GAL: 372 default: 373 model = NULL; 374 } 228 model = pmSourceMagnitudes (source, psf, RADIUS); 375 229 if (model == NULL) continue; 376 230 … … 378 232 dPAR = model->dparams->data.F32; 379 233 380 x = source->peak->x;381 y = source->peak->y;382 383 // we have already (psphotApplyPSF) defined pixels at least OUTER_RADIUS from source384 // we need to mask pixels to measure the aperture magnitude385 // set aperture mask circle of PSF_FIT_RADIUS386 psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);387 388 // save local sky for later389 sky = model->params->data.F32[0];390 391 // replace source flux392 // XXX EAM : need to add 'sky' boolean option here393 model->params->data.F32[0] = 0;394 pmSourceAddModel (source->pixels, source->mask, model, false);395 model->params->data.F32[0] = sky;396 397 // measure object photometry398 status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask);399 400 // correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS401 rflux = pow (10.0, 0.4*fitMag);402 apMag -= rflux * psf->skyBias * (M_PI * PS_SQR(RADIUS));403 fitMag += psf->ApResid;404 405 // subtract object, leave local sky406 // XXX EAM : need to add 'sky' boolean option here407 model->params->data.F32[0] = 0;408 pmSourceSubModel (source->pixels, source->mask, model, false);409 model->params->data.F32[0] = sky;410 411 // unmask aperture412 psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);413 414 if (status == FALSE) continue;415 416 234 dmag = dPAR[1] / PAR[1]; 417 235 type = pmSourceDophotType (source); 236 apResid = source->apMag - source->fitMag; 418 237 lsky = (PAR[0] < 1.0) ? 0.0 : log10(PAR[0]); 419 238 … … 421 240 psLineAdd (line, "%6.1f ", PAR[2]); 422 241 psLineAdd (line, "%6.1f ", PAR[3]); 423 psLineAdd (line, "%6.3f ", fitMag + 25.0);242 psLineAdd (line, "%6.3f ", source->fitMag + ZERO_POINT); 424 243 psLineAdd (line, "%03d ", (int)(1000*dmag)); 425 244 psLineAdd (line, "%2d ", type); 426 245 psLineAdd (line, "%3.1f ", lsky); 427 246 psLineAdd (line, "%6.3f ", 32.0); // should be 'Mgal 428 psLineAdd (line, "%6.3f ", apMag + 25.0); // 25.0 should come from config247 psLineAdd (line, "%6.3f ", apMag + ZERO_POINT); 429 248 psLineAdd (line, "%6.2f ", PAR[4]); // should be 'FHWM x' 430 249 psLineAdd (line, "%6.2f ", PAR[5]); // should be 'FHWM y' … … 452 271 bool result; 453 272 273 // find config information for output header 274 float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS"); 275 float ZERO_POINT = psMetadataLookupF32 (&result, config, "ZERO_POINT"); 276 char *PHOTCODE = psMetadataLookupF32 (&result, config, "PHOTCODE"); 277 278 // write necessary information to output header 279 psMetadataAdd (imdata->header, PS_LIST_TAIL, "NSTARS", PS_META_S32 | PS_META_REPLACE, "NUMBER OF STARS", sources->n); 280 psMetadataAdd (imdata->header, PS_LIST_TAIL, "ZERO_PT", PS_META_F32 | PS_META_REPLACE, "zero point", ZERO_POINT); 281 psMetadataAdd (imdata->header, PS_LIST_TAIL, "APMIFIT", PS_META_F32 | PS_META_REPLACE, "aperture residual", psf->ApResid); 282 psMetadataAdd (imdata->header, PS_LIST_TAIL, "dAPMIFIT", PS_META_F32 | PS_META_REPLACE, "ap residual scatter", psf->dApResid); 283 psMetadataAdd (imdata->header, PS_LIST_TAIL, "SKYBIAS", PS_META_F32 | PS_META_REPLACE, "aperture sky bias", psf->skyBias); 284 psMetadataAdd (imdata->header, PS_LIST_TAIL, "PHOTCODE", PS_META_STR | PS_META_REPLACE, "photometry code", PHOTCODE); 285 psMetadataAdd (imdata->header, PS_LIST_TAIL, "FWHM_X", PS_META_F32 | PS_META_REPLACE, "PSF FWHM X", 0.0); 286 psMetadataAdd (imdata->header, PS_LIST_TAIL, "FWHM_Y", PS_META_F32 | PS_META_REPLACE, "PSF FWHM Y", 0.0); 287 psMetadataAdd (imdata->header, PS_LIST_TAIL, "ANGLE", PS_META_F32 | PS_META_REPLACE, "PSF ANGLE", 0.0); 288 psMetadataAdd (imdata->header, PS_LIST_TAIL, "FSATUR", PS_META_F32 | PS_META_REPLACE, "SATURATION MAG", 0.0); 289 psMetadataAdd (imdata->header, PS_LIST_TAIL, "FLIMIT", PS_META_F32 | PS_META_REPLACE, "COMPLETENESS MAG", 0.0); 290 454 291 // set NAXIS to 0 455 292 fprintf (stderr, "setting naxis\n"); … … 458 295 mdi->type = PS_META_S32; 459 296 460 // psMetadataAdd (imdata->header, PS_LIST_HEAD, "NAXIS", PS_META_S32 | PS_META_REPLACE, "", 0);461 462 297 table = psArrayAlloc (sources->n); 463 298 sources->n = 0; 464 299 465 float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");466 467 300 for (i = 0; i < sources->n; i++) { 468 301 pmSource *source = (pmSource *) sources->data[i]; 469 302 470 // use the correct model 471 switch (source->type) { 472 473 // use PSF model with stars 474 case PM_SOURCE_PSFSTAR: 475 case PM_SOURCE_SATSTAR: 476 case PM_SOURCE_GOODSTAR: 477 model = source->modelPSF; 478 break; 479 480 // use FLT model with galaxies 481 case PM_SOURCE_GALAXY: 482 model = source->modelFLT; 483 break; 484 485 // skip defects and poorly fitted stars or galaxies 486 case PM_SOURCE_DEFECT: 487 case PM_SOURCE_SATURATED: 488 case PM_SOURCE_FAINTSTAR: 489 case PM_SOURCE_POOR_FIT_PSF: 490 case PM_SOURCE_POOR_FIT_GAL: 491 case PM_SOURCE_FAIL_FIT_GAL: 492 default: 493 model = NULL; 494 } 303 model = pmSourceMagnitudes (source, psf, RADIUS); 495 304 if (model == NULL) continue; 496 305 497 306 PAR = model->params->data.F32; 498 307 dPAR = model->dparams->data.F32; 499 500 x = source->peak->x;501 y = source->peak->y;502 503 // we have already (psphotApplyPSF) defined pixels at least OUTER_RADIUS from source504 // we need to mask pixels to measure the aperture magnitude505 // set aperture mask circle of PSF_FIT_RADIUS506 psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);507 508 // save local sky for later509 sky = model->params->data.F32[0];510 511 // replace source flux512 // XXX EAM : need to add 'sky' boolean option here513 model->params->data.F32[0] = 0;514 pmSourceAddModel (source->pixels, source->mask, model, false);515 model->params->data.F32[0] = sky;516 517 // measure object photometry518 status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask);519 520 // correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS521 rflux = pow (10.0, 0.4*fitMag);522 apMag -= rflux * psf->skyBias * (M_PI * PS_SQR(RADIUS));523 fitMag += psf->ApResid;524 525 // subtract object, leave local sky526 // XXX EAM : need to add 'sky' boolean option here527 model->params->data.F32[0] = 0;528 pmSourceSubModel (source->pixels, source->mask, model, false);529 model->params->data.F32[0] = sky;530 531 // unmask aperture532 psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);533 534 if (status == FALSE) continue;535 308 536 309 dmag = dPAR[1] / PAR[1]; … … 541 314 psMetadataAdd (row, PS_LIST_HEAD, "X_PIX", PS_META_F32, "", PAR[2]); 542 315 psMetadataAdd (row, PS_LIST_HEAD, "Y_PIX", PS_META_F32, "", PAR[3]); 543 psMetadataAdd (row, PS_LIST_HEAD, "MAG_RAW", PS_META_F32, "", fitMag + 25.0);316 psMetadataAdd (row, PS_LIST_HEAD, "MAG_RAW", PS_META_F32, "", source->fitMag + ZERO_POINT); 544 317 psMetadataAdd (row, PS_LIST_HEAD, "MAG_ERR", PS_META_F32, "", (int)(1000*dmag)); 545 318 psMetadataAdd (row, PS_LIST_HEAD, "MAG_GAL", PS_META_F32, "", type); 546 319 psMetadataAdd (row, PS_LIST_HEAD, "MAG_AP", PS_META_F32, "", lsky); 547 320 psMetadataAdd (row, PS_LIST_HEAD, "LOG_SKY", PS_META_F32, "", 32.0); // should be 'Mgal' 548 psMetadataAdd (row, PS_LIST_HEAD, "FWHM_X", PS_META_F32, "", apMag + 25.0); // 25.0 should come from config321 psMetadataAdd (row, PS_LIST_HEAD, "FWHM_X", PS_META_F32, "", apMag + ZERO_POINT); 549 322 psMetadataAdd (row, PS_LIST_HEAD, "FWHM_Y", PS_META_F32, "", PAR[4]); // should be 'FHWM x' 550 323 psMetadataAdd (row, PS_LIST_HEAD, "THETA", PS_META_F32, "", PAR[5]); // should be 'FHWM y'
Note:
See TracChangeset
for help on using the changeset viewer.
