Changeset 5837 for trunk/psphot/src/psphotOutput.c
- Timestamp:
- Dec 23, 2005, 1:58:45 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotOutput.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotOutput.c
r5828 r5837 24 24 return; 25 25 } 26 if (!strcasecmp (outputMode, "OBJ")) { 27 pmSourcesWriteOBJ (imdata, config, outputFile, sources, psf, sky); 28 return; 29 } 30 if (!strcasecmp (outputMode, "SX")) { 31 pmSourcesWriteSX (imdata, config, outputFile, sources, psf, sky); 32 return; 33 } 34 if (!strcasecmp (outputMode, "CMP")) { 35 pmSourcesWriteCMP (imdata, config, outputFile, sources, psf, sky); 36 return; 37 } 38 if (!strcasecmp (outputMode, "CMF")) { 39 pmSourcesWriteCMF (imdata, config, outputFile, sources, psf, sky); 40 return; 41 } 26 42 if (!strcasecmp (outputMode, "TEXT")) { 27 43 pmSourcesWriteText (imdata, config, outputFile, sources, psf, sky); … … 29 45 } 30 46 31 if (!strcasecmp (outputMode, "OBJ")) {32 pmSourcesWriteOBJ (imdata, config, outputFile, sources, psf, sky);33 return;34 }35 36 if (!strcasecmp (outputMode, "SX")) {37 pmSourcesWriteSX (imdata, config, outputFile, sources, psf, sky);38 return;39 }40 41 if (!strcasecmp (outputMode, "CMP")) {42 pmSourcesWriteCMP (imdata, config, outputFile, sources, psf, sky);43 return;44 }45 46 if (!strcasecmp (outputMode, "CMF")) {47 pmSourcesWriteCMF (imdata, config, outputFile, sources, psf, sky);48 return;49 }50 51 47 psAbort ("psphot", "unknown output mode %s", outputMode); 52 }53 54 bool pmSourcesWriteText (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky) {55 56 char *name = (char *) psAlloc (strlen(filename) + 10);57 58 sprintf (name, "%s.psf.dat", filename);59 pmModelWritePSFs (sources, config, name, psf);60 61 sprintf (name, "%s.flt.dat", filename);62 pmModelWriteFLTs (sources, name);63 64 sprintf (name, "%s.nul.dat", filename);65 pmModelWriteNULLs (sources, name);66 67 sprintf (name, "%s.mnt.dat", filename);68 pmMomentsWriteText (sources, name);69 70 psFree (name);71 return true;72 48 } 73 49 … … 115 91 psLineAdd (line, "%9.3f", PAR[5]); 116 92 psLineAdd (line, "%7.2f", PAR[6]); 117 psLineAdd (line, "%8.3f", 32.0);93 psLineAdd (line, "%8.3f", 99.999); 118 94 psLineAdd (line, "%8.3f", source->apMag); 119 95 psLineAdd (line, "%8.2f\n", apResid); … … 166 142 psLineAdd (line, "%9.2f", 0.0); // should be FWHMy 167 143 psLineAdd (line, "%6.1f", 0.0); // should be Theta 168 psLineAdd (line, "%9.4f", 32.0); // should be MAG_ISO144 psLineAdd (line, "%9.4f", 99.999); // should be MAG_ISO 169 145 psLineAdd (line, "%9.4f", source->apMag); 170 146 psLineAdd (line, "%4d\n", 0); // should be flags … … 182 158 psMetadataItem *mdi; 183 159 psF32 *PAR, *dPAR; 184 float dmag, apResid,lsky;160 float dmag, lsky; 185 161 bool status; 186 162 … … 188 164 float RADIUS = psMetadataLookupF32 (&status, config, "PSF_FIT_RADIUS"); 189 165 float ZERO_POINT = psMetadataLookupF32 (&status, config, "ZERO_POINT"); 166 if (!status) ZERO_POINT = 25.0; 190 167 char *PHOTCODE = psMetadataLookupPtr (&status, config, "PHOTCODE"); 191 168 … … 237 214 dmag = dPAR[1] / PAR[1]; 238 215 type = pmSourceDophotType (source); 239 apResid = source->apMag - source->fitMag;240 216 lsky = (PAR[0] < 1.0) ? 0.0 : log10(PAR[0]); 241 217 … … 243 219 psLineAdd (line, "%6.1f ", PAR[2]); 244 220 psLineAdd (line, "%6.1f ", PAR[3]); 245 psLineAdd (line, "%6.3f ", PS_MIN ( 32.0, source->fitMag + ZERO_POINT));246 psLineAdd (line, "%03d ", (int)(1000*dmag));221 psLineAdd (line, "%6.3f ", PS_MIN (99.999, source->fitMag + ZERO_POINT)); 222 psLineAdd (line, "%03d ", PS_MIN (999, (int)(1000*dmag))); 247 223 psLineAdd (line, "%2d ", type); 248 224 psLineAdd (line, "%3.1f ", lsky); 249 psLineAdd (line, "%6.3f ", 32.0); // should be 'Mgal250 psLineAdd (line, "%6.3f ", PS_MIN ( 32.0, source->apMag + ZERO_POINT));225 psLineAdd (line, "%6.3f ", 99.999); // should be 'Mgal 226 psLineAdd (line, "%6.3f ", PS_MIN (99.999, source->apMag + ZERO_POINT)); 251 227 psLineAdd (line, "%6.2f ", PAR[4]); // should be 'FHWM x' 252 228 psLineAdd (line, "%6.2f ", PAR[5]); // should be 'FHWM y' … … 297 273 298 274 table = psArrayAlloc (sources->n); 299 sources->n = 0;275 table->n = 0; 300 276 301 277 for (i = 0; i < sources->n; i++) { … … 313 289 314 290 row = psMetadataAlloc (); 315 psMetadataAdd (row, PS_LIST_ HEAD, "X_PIX", PS_DATA_F32, "", PAR[2]);316 psMetadataAdd (row, PS_LIST_ HEAD, "Y_PIX", PS_DATA_F32, "", PAR[3]);317 psMetadataAdd (row, PS_LIST_ HEAD, "MAG_RAW", PS_DATA_F32, "", source->fitMag + ZERO_POINT);318 psMetadataAdd (row, PS_LIST_ HEAD, "MAG_ERR", PS_DATA_F32, "", (int)(1000*dmag));319 psMetadataAdd (row, PS_LIST_ HEAD, "MAG_GAL", PS_DATA_F32, "", type);320 psMetadataAdd (row, PS_LIST_ HEAD, "MAG_AP", PS_DATA_F32, "", lsky);321 psMetadataAdd (row, PS_LIST_ HEAD, "LOG_SKY", PS_DATA_F32, "", 32.0); // should be 'Mgal'322 psMetadataAdd (row, PS_LIST_ HEAD, "FWHM_X", PS_DATA_F32, "", source->apMag + ZERO_POINT);323 psMetadataAdd (row, PS_LIST_ HEAD, "FWHM_Y", PS_DATA_F32, "", PAR[4]); // should be 'FHWM x'324 psMetadataAdd (row, PS_LIST_ HEAD, "THETA", PS_DATA_F32, "", PAR[5]); // should be 'FHWM y'325 psMetadataAdd (row, PS_LIST_ HEAD, "DOPHOT", PS_TYPE_S8,"", 0); // should be theta291 psMetadataAdd (row, PS_LIST_TAIL, "X_PIX", PS_DATA_F32, "", PAR[2]); 292 psMetadataAdd (row, PS_LIST_TAIL, "Y_PIX", PS_DATA_F32, "", PAR[3]); 293 psMetadataAdd (row, PS_LIST_TAIL, "MAG_RAW", PS_DATA_F32, "", source->fitMag + ZERO_POINT); 294 psMetadataAdd (row, PS_LIST_TAIL, "MAG_ERR", PS_DATA_F32, "", (int)(1000*dmag)); 295 psMetadataAdd (row, PS_LIST_TAIL, "MAG_GAL", PS_DATA_F32, "", type); 296 psMetadataAdd (row, PS_LIST_TAIL, "MAG_AP", PS_DATA_F32, "", lsky); 297 psMetadataAdd (row, PS_LIST_TAIL, "LOG_SKY", PS_DATA_F32, "", 32.0); // should be 'Mgal' 298 psMetadataAdd (row, PS_LIST_TAIL, "FWHM_X", PS_DATA_F32, "", source->apMag + ZERO_POINT); 299 psMetadataAdd (row, PS_LIST_TAIL, "FWHM_Y", PS_DATA_F32, "", PAR[4]); // should be 'FHWM x' 300 psMetadataAdd (row, PS_LIST_TAIL, "THETA", PS_DATA_F32, "", PAR[5]); // should be 'FHWM y' 301 psMetadataAdd (row, PS_LIST_TAIL, "DOPHOT", PS_TYPE_S32, "", 0); // should be theta 326 302 // psMetadataAdd (header, PS_LIST_HEAD, "DUMMY", PS_DATA_STRING, "", NULL); 327 303 … … 339 315 psMetadataAdd (theader, PS_LIST_HEAD, "EXTNAME", PS_DATA_STRING, "extension name", "SMPFILE"); 340 316 317 psImage *image; 318 319 image = psImageAlloc (512, 512, PS_DATA_F32); 320 for (int j = 0; j < 512; j++) { 321 for (int i = 0; i < 512; i++) { 322 image->data.F32[j][i] = i; 323 } 324 } 325 341 326 psFits *fits = psFitsOpen (filename, "w"); 342 psFitsWriteHeader (imdata->header, fits); 343 psFitsWriteTable (fits, theader, table); 327 // psFitsWriteHeader (imdata->header, fits); 328 // psFitsWriteTable (fits, theader, table); 329 330 psFitsWriteImage (fits, NULL, image, 0); 331 psFitsWriteTable (fits, NULL, table); 344 332 psFitsClose (fits); 345 333 … … 349 337 /***** Text Output Methods *****/ 350 338 351 // write the peaks to an output file 352 bool pmPeaksWriteText (psArray *peaks, char *filename) { 353 354 int i; 355 FILE *f; 356 357 f = fopen (filename, "w"); 358 if (f == NULL) { 359 psLogMsg ("pmPeaksWriteText", 3, "can't open output file for peaks%s\n", filename); 360 return false; 361 } 362 363 for (i = 0; i < peaks->n; i++) { 364 pmPeak *peak = peaks->data[i]; 365 if (peak == NULL) continue; 366 fprintf (f, "%5d %5d %7.1f\n", 367 peak->x, peak->y, peak->counts); 368 } 369 fclose (f); 339 bool pmSourcesWriteText (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky) { 340 341 char *name = (char *) psAlloc (strlen(filename) + 10); 342 343 sprintf (name, "%s.psf.dat", filename); 344 pmModelWritePSFs (sources, config, name, psf); 345 346 sprintf (name, "%s.flt.dat", filename); 347 pmModelWriteFLTs (sources, name); 348 349 sprintf (name, "%s.nul.dat", filename); 350 pmModelWriteNULLs (sources, name); 351 352 sprintf (name, "%s.mnt.dat", filename); 353 pmMomentsWriteText (sources, name); 354 355 psFree (name); 370 356 return true; 371 357 } … … 381 367 bool status; 382 368 369 float RADIUS = psMetadataLookupF32 (&status, config, "PSF_FIT_RADIUS"); 370 383 371 f = fopen (filename, "w"); 384 372 if (f == NULL) { … … 387 375 } 388 376 389 float RADIUS = psMetadataLookupF32 (&status, config, "PSF_FIT_RADIUS");390 391 377 // write sources with models first 392 378 for (i = 0; i < sources->n; i++) { … … 394 380 395 381 if (source->type != PM_SOURCE_STAR) continue; 396 // if (source->mode & PM_SOURCE_FAIL) continue;397 // if (source->mode & PM_SOURCE_POOR) continue;398 399 382 model = pmSourceMagnitudes (source, psf, RADIUS); 400 383 if (model == NULL) continue; … … 407 390 dMag = dPAR[1] / PAR[1]; 408 391 409 fprintf (f, "%7.1f %7.1f % 5.1f %8.4f %7.4f %7.4f ",392 fprintf (f, "%7.1f %7.1f %7.1f %8.4f %7.4f %7.4f ", 410 393 PAR[2], PAR[3], PAR[0], source->fitMag, dMag, dPos); 411 394 … … 449 432 450 433 if (source->type != PM_SOURCE_GALAXY) continue; 451 452 if (source->modelFLT == NULL) continue; 453 model = pmSourceMagnitudes (source, NULL, source->modelFLT->radius); 434 model = pmSourceMagnitudes (source, NULL, 0.0); 435 if (model == NULL) continue; 454 436 455 437 PAR = model->params->data.F32; … … 458 440 // dPos is shape error 459 441 // XXX these are hardwired for SGAUSS 460 dPos = 0; 461 dPos += PS_SQR(dPAR[4] / PAR[4]); 462 dPos += PS_SQR(dPAR[5] / PAR[5]); 463 // dPos += PS_SQR(dPAR[7] / PAR[7]); 464 dPos = sqrt (dPos); 442 dPos = hypot ((dPAR[4] / PAR[4]), (dPAR[5] / PAR[5])); 465 443 dMag = dPAR[1] / PAR[1]; 466 444 467 fprintf (f, "%7.1f %7.1f %7.1f % 7.3f %7.4f %7.4f ",445 fprintf (f, "%7.1f %7.1f %7.1f %8.4f %7.4f %7.4f ", 468 446 PAR[2], PAR[3], PAR[0], source->fitMag, dMag, dPos); 469 447 … … 560 538 } 561 539 540 // write the peaks to an output file 541 bool pmPeaksWriteText (psArray *peaks, char *filename) { 542 543 int i; 544 FILE *f; 545 546 f = fopen (filename, "w"); 547 if (f == NULL) { 548 psLogMsg ("pmPeaksWriteText", 3, "can't open output file for peaks%s\n", filename); 549 return false; 550 } 551 552 for (i = 0; i < peaks->n; i++) { 553 pmPeak *peak = peaks->data[i]; 554 if (peak == NULL) continue; 555 fprintf (f, "%5d %5d %7.1f\n", 556 peak->x, peak->y, peak->counts); 557 } 558 fclose (f); 559 return true; 560 } 561 562 562 // translations between psphot object types and dophot object types 563 563 int pmSourceDophotType (pmSource *source) {
Note:
See TracChangeset
for help on using the changeset viewer.
