Changeset 5128
- Timestamp:
- Sep 25, 2005, 9:24:29 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotOutput.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotOutput.c
r5085 r5128 21 21 } 22 22 if (!strcasecmp (outputMode, "TEXT")) { 23 pmSourcesWriteText (imdata, outputFile, sources, psf, sky);23 pmSourcesWriteText (imdata, config, outputFile, sources, psf, sky); 24 24 return; 25 25 } … … 47 47 } 48 48 49 bool pmSourcesWriteText (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *sky) {49 bool pmSourcesWriteText (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky) { 50 50 51 51 char *name = (char *) psAlloc (strlen(filename) + 10); 52 52 53 53 sprintf (name, "%s.psf.dat", filename); 54 pmModelWritePSFs (sources, name);54 pmModelWritePSFs (sources, config, name, psf); 55 55 56 56 sprintf (name, "%s.flt.dat", filename); … … 135 135 } 136 136 137 float RADIUS = psMetadataLookupF32 (& result, config, "PSF_FIT_RADIUS");137 float RADIUS = psMetadataLookupF32 (&status, config, "PSF_FIT_RADIUS"); 138 138 139 139 // write sources with models … … 173 173 bool pmSourcesWriteCMP (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 174 174 175 int i, type , status;175 int i, type; 176 176 pmModel *model; 177 177 psMetadataItem *mdi; 178 178 psF32 *PAR, *dPAR; 179 float sky, dmag, apMag, fitMag, lsky; 180 float x, y, rflux; 181 bool result; 179 float dmag, apResid, lsky; 180 bool status; 182 181 183 182 // 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 = psMetadataLookup F32 (&result, config, "PHOTCODE");183 float RADIUS = psMetadataLookupF32 (&status, config, "PSF_FIT_RADIUS"); 184 float ZERO_POINT = psMetadataLookupF32 (&status, config, "ZERO_POINT"); 185 char *PHOTCODE = psMetadataLookupPtr (&status, config, "PHOTCODE"); 187 186 188 187 // write necessary information to output header … … 240 239 psLineAdd (line, "%6.1f ", PAR[2]); 241 240 psLineAdd (line, "%6.1f ", PAR[3]); 242 psLineAdd (line, "%6.3f ", source->fitMag + ZERO_POINT);241 psLineAdd (line, "%6.3f ", PS_MIN (32.0, source->fitMag + ZERO_POINT)); 243 242 psLineAdd (line, "%03d ", (int)(1000*dmag)); 244 243 psLineAdd (line, "%2d ", type); 245 244 psLineAdd (line, "%3.1f ", lsky); 246 245 psLineAdd (line, "%6.3f ", 32.0); // should be 'Mgal 247 psLineAdd (line, "%6.3f ", apMag + ZERO_POINT);246 psLineAdd (line, "%6.3f ", PS_MIN (32.0, source->apMag + ZERO_POINT)); 248 247 psLineAdd (line, "%6.2f ", PAR[4]); // should be 'FHWM x' 249 248 psLineAdd (line, "%6.2f ", PAR[5]); // should be 'FHWM y' … … 264 263 psMetadata *row; 265 264 psMetadata *theader; 266 int i, type , status;265 int i, type; 267 266 pmModel *model; 268 267 psF32 *PAR, *dPAR; 269 float sky, dmag, apMag, fitMag; 270 float x, y, rflux, lsky; 271 bool result; 268 float dmag, lsky; 269 bool status; 272 270 273 271 // 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 = psMetadataLookup F32 (&result, config, "PHOTCODE");272 float RADIUS = psMetadataLookupF32 (&status, config, "PSF_FIT_RADIUS"); 273 float ZERO_POINT = psMetadataLookupF32 (&status, config, "ZERO_POINT"); 274 char *PHOTCODE = psMetadataLookupPtr (&status, config, "PHOTCODE"); 277 275 278 276 // write necessary information to output header … … 319 317 psMetadataAdd (row, PS_LIST_HEAD, "MAG_AP", PS_META_F32, "", lsky); 320 318 psMetadataAdd (row, PS_LIST_HEAD, "LOG_SKY", PS_META_F32, "", 32.0); // should be 'Mgal' 321 psMetadataAdd (row, PS_LIST_HEAD, "FWHM_X", PS_META_F32, "", apMag + ZERO_POINT);319 psMetadataAdd (row, PS_LIST_HEAD, "FWHM_X", PS_META_F32, "", source->apMag + ZERO_POINT); 322 320 psMetadataAdd (row, PS_LIST_HEAD, "FWHM_Y", PS_META_F32, "", PAR[4]); // should be 'FHWM x' 323 321 psMetadataAdd (row, PS_LIST_HEAD, "THETA", PS_META_F32, "", PAR[5]); // should be 'FHWM y' … … 331 329 // psAbort ("psphotOutput", "FITS table output not finished"); 332 330 333 psImage *image = psImageAlloc (1, 1, PS_TYPE_F32);331 // psImage *image = psImageAlloc (1, 1, PS_TYPE_F32); 334 332 // XXX missing: theader = psFitsHeaderFromTable (NULL, table, "SMPFILE"); 333 // psFitsWriteImage (fits, imdata->header, image, 0); 335 334 336 335 theader = psMetadataAlloc (); … … 339 338 unlink (filename); 340 339 psFits *fits = psFitsAlloc (filename); 341 psFitsWrite Image (fits, imdata->header, image, 0);340 psFitsWriteHeader (imdata->header, fits); 342 341 psFitsWriteTable (fits, theader, table); 343 342 psFree (fits); … … 400 399 401 400 // dump the sources to an output file 402 bool pmModelWritePSFs (psArray *sources, char *filename) {403 404 double dP, flux;401 bool pmModelWritePSFs (psArray *sources, psMetadata *config, char *filename, pmPSF *psf) { 402 403 double dP, dmag; 405 404 int i, j; 406 405 FILE *f; 407 psVector *params; 408 psVector *dparams; 406 psF32 *PAR, *dPAR; 409 407 pmModel *model; 408 bool status; 410 409 411 410 f = fopen (filename, "w"); … … 415 414 } 416 415 417 // write sources with models first 416 float RADIUS = psMetadataLookupF32 (&status, config, "PSF_FIT_RADIUS"); 417 418 // write sources with models first 418 419 for (i = 0; i < sources->n; i++) { 419 420 pmSource *source = (pmSource *) sources->data[i]; 420 model = (pmModel *) source->modelPSF;421 if (model == NULL) continue;422 421 423 422 // valid source types for this function … … 428 427 429 428 valid: 430 params = model->params; 431 dparams = model->dparams; 429 model = pmSourceMagnitudes (source, psf, RADIUS); 430 if (model == NULL) continue; 431 432 PAR = model->params->data.F32; 433 dPAR = model->dparams->data.F32; 432 434 433 435 dP = 0; 434 dP += PS_SQR(d params[0].data.F32[2]);435 dP += PS_SQR(d params[0].data.F32[3]);436 dP += PS_SQR(dPAR[2]); 437 dP += PS_SQR(dPAR[3]); 436 438 dP = sqrt (dP); 437 439 438 pmModelFlux modelFluxFunc = pmModelFlux_GetFunction (model->type); 439 flux = modelFluxFunc (params); 440 441 fprintf (f, "%7.1f %7.1f %5.1f %7.3f %7.4f %7.4f ", 442 params[0].data.F32[2], 443 params[0].data.F32[3], 444 params[0].data.F32[0], 445 -2.5*log10(flux), 446 (dparams[0].data.F32[1]/params[0].data.F32[1]), 447 dP); 440 dmag = dPAR[1] / PAR[1]; 441 442 fprintf (f, "%7.1f %7.1f %5.1f %7.4f %7.4f %7.4f ", 443 PAR[2], PAR[3], PAR[0], source->fitMag, dmag, dP); 444 448 445 for (j = 0; j < model->params->n - 4; j++) { 449 fprintf (f, "%9.6f ", params[0].data.F32[j+4]);446 fprintf (f, "%9.6f ", PAR[j+4]); 450 447 } 451 448 fprintf (f, " : "); 452 449 for (j = 0; j < model->params->n - 4; j++) { 453 fprintf (f, "%9.6f ", d params[0].data.F32[j+4]);450 fprintf (f, "%9.6f ", dPAR[j+4]); 454 451 } 455 452 fprintf (f, ": %2d %7.3f %7.3f %7.2f %4d %2d\n",
Note:
See TracChangeset
for help on using the changeset viewer.
