Changeset 5084 for trunk/psphot/src/psphotOutput.c
- Timestamp:
- Sep 20, 2005, 6:48:16 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotOutput.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotOutput.c
r5073 r5084 26 26 27 27 if (!strcasecmp (outputMode, "OBJ")) { 28 pmSourcesWriteOBJ (imdata, outputFile, sources, psf, sky);28 pmSourcesWriteOBJ (imdata, config, outputFile, sources, psf, sky); 29 29 return; 30 30 } … … 36 36 37 37 if (!strcasecmp (outputMode, "CMP")) { 38 pmSourcesWriteCMP (imdata, outputFile, sources, psf, sky);38 pmSourcesWriteCMP (imdata, config, outputFile, sources, psf, sky); 39 39 return; 40 40 } 41 41 42 42 if (!strcasecmp (outputMode, "CMF")) { 43 pmSourcesWriteCMF (imdata, outputFile, sources, psf, sky);43 pmSourcesWriteCMF (imdata, config, outputFile, sources, psf, sky); 44 44 return; 45 45 } … … 68 68 69 69 // dophot-style output list with fixed line width 70 bool pmSourcesWriteOBJ (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {70 bool pmSourcesWriteOBJ (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 71 71 72 72 int i, type, status; … … 74 74 psF32 *PAR, *dPAR; 75 75 float sky, dmag, apMag, fitMag; 76 float x, y, rflux; 77 bool result; 76 78 77 79 psLine *line = psLineAlloc (104); // 104 is dophot-defined line length … … 82 84 return false; 83 85 } 86 87 float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS"); 84 88 85 89 // write sources with models first … … 296 300 297 301 // elixir-style pseudo FITS table (header + ascii list) 298 bool pmSourcesWriteCMP (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {302 bool pmSourcesWriteCMP (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 299 303 300 304 int i, type, status; 301 305 pmModel *model; 306 psMetadataItem *mdi; 302 307 psF32 *PAR, *dPAR; 303 float sky, dmag, apMag, fitMag, lsky, Theta; 308 float sky, dmag, apMag, fitMag, lsky; 309 float x, y, rflux; 310 bool result; 304 311 305 312 // create file, write-out header 306 313 unlink (filename); 307 314 psFits *fits = psFitsAlloc (filename); 315 316 // set NAXIS to 0 : CFITSIO requires isolated header to have NAXIS = 0 317 mdi = psMetadataLookup (imdata->header, "NAXIS"); 318 mdi->data.S32 = 0; 319 mdi->type = PS_META_S32; 320 321 // psMetadataAdd (imdata->header, PS_LIST_HEAD, "NAXIS", PS_META_S32 | PS_META_REPLACE, "", 0); 308 322 psFitsWriteHeader (imdata->header, fits); 309 323 psFree (fits); … … 317 331 fseek (f, 0, SEEK_END); 318 332 319 psLine *line = psLineAlloc (66); // 66 is imclean-defined line length 333 psLine *line = psLineAlloc (67); // 66 is imclean-defined line length 334 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.0 343 // fits_modify (header, "FLIMIT", "%lf", 1, complete); // can use 0.0 344 // fits_modify (header, "NSTARS", "%d", 1, N); 320 345 321 346 // write sources with models first … … 404 429 psLineAdd (line, "%6.2f ", PAR[4]); // should be 'FHWM x' 405 430 psLineAdd (line, "%6.2f ", PAR[5]); // should be 'FHWM y' 406 psLineAdd (line, "%5.1f\n", Theta); // should be theta431 psLineAdd (line, "%5.1f\n", 0); // should be theta 407 432 fwrite (line->line, 1, line->Nline, f); 408 433 } … … 414 439 // this format consists of a header derived from the image header 415 440 // followed by a zero-size matrix, followed by the table data 416 bool pmSourcesWriteCMF (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {441 bool pmSourcesWriteCMF (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 417 442 418 443 psArray *table; 444 psMetadataItem *mdi; 419 445 psMetadata *row; 420 446 psMetadata *theader; 447 int i, type, status; 448 pmModel *model; 449 psF32 *PAR, *dPAR; 450 float sky, dmag, apMag, fitMag; 451 float x, y, rflux, lsky; 452 bool result; 421 453 422 454 // set NAXIS to 0 423 psMetadataAdd (header, PS_LIST_HEAD, "NAXIS", PS_META_S32 | PS_META_REPLACE, "", 0); 455 fprintf (stderr, "setting naxis\n"); 456 mdi = psMetadataLookup (imdata->header, "NAXIS"); 457 mdi->data.S32 = 0; 458 mdi->type = PS_META_S32; 459 460 // psMetadataAdd (imdata->header, PS_LIST_HEAD, "NAXIS", PS_META_S32 | PS_META_REPLACE, "", 0); 424 461 425 462 table = psArrayAlloc (sources->n); 426 463 sources->n = 0; 464 465 float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS"); 427 466 428 467 for (i = 0; i < sources->n; i++) { … … 499 538 lsky = (PAR[0] < 1.0) ? 0.0 : log10(PAR[0]); 500 539 501 table = psMetdataAlloc ();502 psMetadataAdd ( table, PS_LIST_HEAD, "X_PIX", PS_META_F32, "", PAR[2]);503 psMetadataAdd ( table, PS_LIST_HEAD, "Y_PIX", PS_META_F32, "", PAR[3]);504 psMetadataAdd ( table, PS_LIST_HEAD, "MAG_RAW", PS_META_F32, "", fitMag + 25.0);505 psMetadataAdd ( table, PS_LIST_HEAD, "MAG_ERR", PS_META_F32, "", (int)(1000*dmag));506 psMetadataAdd ( table, PS_LIST_HEAD, "MAG_GAL", PS_META_F32, "", type);507 psMetadataAdd ( table, PS_LIST_HEAD, "MAG_AP", PS_META_F32, "", lsky);508 psMetadataAdd ( table, PS_LIST_HEAD, "LOG_SKY", PS_META_F32, "", 32.0); // should be 'Mgal'509 psMetadataAdd ( table, PS_LIST_HEAD, "FWHM_X", PS_META_F32, "", apMag + 25.0); // 25.0 should come from config510 psMetadataAdd ( table, PS_LIST_HEAD, "FWHM_Y", PS_META_F32, "", PAR[4]); // should be 'FHWM x'511 psMetadataAdd ( table, PS_LIST_HEAD, "THETA", PS_META_F32, "", PAR[5]); // should be 'FHWM y'512 psMetadataAdd ( table, PS_LIST_HEAD, "DOPHOT", PS_META_S8, "", Theta); // should be theta540 row = psMetadataAlloc (); 541 psMetadataAdd (row, PS_LIST_HEAD, "X_PIX", PS_META_F32, "", PAR[2]); 542 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); 544 psMetadataAdd (row, PS_LIST_HEAD, "MAG_ERR", PS_META_F32, "", (int)(1000*dmag)); 545 psMetadataAdd (row, PS_LIST_HEAD, "MAG_GAL", PS_META_F32, "", type); 546 psMetadataAdd (row, PS_LIST_HEAD, "MAG_AP", PS_META_F32, "", lsky); 547 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 config 549 psMetadataAdd (row, PS_LIST_HEAD, "FWHM_Y", PS_META_F32, "", PAR[4]); // should be 'FHWM x' 550 psMetadataAdd (row, PS_LIST_HEAD, "THETA", PS_META_F32, "", PAR[5]); // should be 'FHWM y' 551 psMetadataAdd (row, PS_LIST_HEAD, "DOPHOT", PS_TYPE_S8, "", 0); // should be theta 513 552 // psMetadataAdd (header, PS_LIST_HEAD, "DUMMY", PS_META_STR, "", NULL); 514 553 … … 517 556 } 518 557 519 image = psImageAlloc (0, 0, PS_TYPE_F32); 520 theader = psFitsHeaderFromTable (NULL, table, "SMPFILE"); 558 // psAbort ("psphotOutput", "FITS table output not finished"); 559 560 psImage *image = psImageAlloc (1, 1, PS_TYPE_F32); 561 // XXX missing: theader = psFitsHeaderFromTable (NULL, table, "SMPFILE"); 562 563 theader = psMetadataAlloc (); 564 psMetadataAdd (theader, PS_LIST_HEAD, "EXTNAME", PS_META_STR, "extension name", "SMPFILE"); 521 565 522 566 unlink (filename); 523 567 psFits *fits = psFitsAlloc (filename); 524 psFitsWriteImage (fits, header, image, 0, NULL);568 psFitsWriteImage (fits, imdata->header, image, 0); 525 569 psFitsWriteTable (fits, theader, table); 526 570 psFree (fits);
Note:
See TracChangeset
for help on using the changeset viewer.
