Changeset 5754
- Timestamp:
- Dec 8, 2005, 4:39:17 PM (21 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 2 edited
-
psphotOutput.c (modified) (5 diffs)
-
psphotSetup.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotOutput.c
r5672 r5754 199 199 200 200 // create file, write-out header 201 unlink (filename); 202 psFits *fits = psFitsAlloc (filename); 201 psFits *fits = psFitsOpen (filename, "w"); 203 202 204 203 // set NAXIS to 0 : CFITSIO requires isolated header to have NAXIS = 0 … … 209 208 // psMetadataAdd (imdata->header, PS_LIST_HEAD, "NAXIS", PS_DATA_S32 | PS_META_REPLACE, "", 0); 210 209 psFitsWriteHeader (imdata->header, fits); 211 psF ree (fits);210 psFitsClose (fits); 212 211 213 212 // re-open, add data to end of file … … 336 335 psMetadataAdd (theader, PS_LIST_HEAD, "EXTNAME", PS_DATA_STRING, "extension name", "SMPFILE"); 337 336 338 unlink (filename); 339 psFits *fits = psFitsAlloc (filename); 337 psFits *fits = psFitsOpen (filename, "w"); 340 338 psFitsWriteHeader (imdata->header, fits); 341 339 psFitsWriteTable (fits, theader, table); 342 psF ree (fits);340 psFitsClose (fits); 343 341 344 342 return true; … … 542 540 } 543 541 542 // write the moments to an output file 543 bool pmMomentsWriteText (psArray *sources, char *filename) 544 { 545 546 int i; 547 FILE *f; 548 pmSource *source; 549 550 f = fopen (filename, "w"); 551 if (f == NULL) { 552 psLogMsg ("pmMomentsWriteText", 3, "can't open output file for moments%s\n", filename); 553 return false; 554 } 555 556 for (i = 0; i < sources->n; i++) { 557 source = (pmSource *) sources->data[i]; 558 if (source->moments == NULL) 559 continue; 560 fprintf (f, "%5d %5d %7.1f %7.1f %7.1f %6.3f %6.3f %8.1f %7.1f %7.1f %7.1f %4d %2d\n", 561 source->peak->x, source->peak->y, source->peak->counts, 562 source->moments->x, source->moments->y, 563 source->moments->Sx, source->moments->Sy, 564 source->moments->Sum, source->moments->Peak, 565 source->moments->Sky, source->moments->SN, 566 source->moments->nPixels, source->type); 567 } 568 fclose (f); 569 return true; 570 } 571 544 572 // translations between psphot object types and dophot object types 545 573 int pmSourceDophotType (pmSource *source) { … … 581 609 int psphotSaveImage (psMetadata *header, psImage *image, char *filename) { 582 610 583 unlink (filename); 584 psFits *fits = psFitsAlloc (filename); 611 psFits *fits = psFitsOpen (filename, "w"); 585 612 psFitsWriteImage (fits, NULL, image, 0); 586 psF ree (fits);613 psFitsClose (fits); 587 614 return (TRUE); 588 615 } 616 617 psImage *pmModelPSFatXY (psImage *image, pmModel *modelFLT, pmPSF *psf, int x, int y, int dx, int dy) { 618 619 psRegion region = {x - dx, x + dx, y - dy, y + dy}; 620 psImage *sample = psImageSubset (image, region); 621 psImageInit (sample, 0); 622 modelFLT->params->data.F32[2] = x; 623 modelFLT->params->data.F32[3] = y; 624 pmModel *modelPSF = pmModelFromPSF (modelFLT, psf); 625 pmSourceAddModel (sample, NULL, modelPSF, false, false); 626 psFree (modelPSF); 627 return (sample); 628 } 629 630 631 bool psphotSamplePSFs (pmPSF *psf, psImage *image) { 632 633 // make sample PSFs for 4 corners and the center 634 psImage *sample; 635 636 pmModel *modelFLT = pmModelAlloc (psf->type); 637 modelFLT->params->data.F32[0] = 0; 638 modelFLT->params->data.F32[1] = 1; 639 640 psFits *fits = psFitsOpen ("sample.psf.fits", "w"); 641 642 sample = pmModelPSFatXY (image, modelFLT, psf, 25, 25, 25, 25); 643 psFitsWriteImage (fits, NULL, sample, 0); 644 sample = pmModelPSFatXY (image, modelFLT, psf, image->numCols - 25, image->numRows - 25, 25, 25); 645 psFitsWriteImage (fits, NULL, sample, 0); 646 sample = pmModelPSFatXY (image, modelFLT, psf, image->numCols - 25, 25, 25, 25); 647 psFitsWriteImage (fits, NULL, sample, 0); 648 sample = pmModelPSFatXY (image, modelFLT, psf, 25, image->numRows - 25, 25, 25); 649 psFitsWriteImage (fits, NULL, sample, 0); 650 sample = pmModelPSFatXY (image, modelFLT, psf, image->numCols / 2, image->numRows / 2, 25, 25); 651 psFitsWriteImage (fits, NULL, sample, 0); 652 653 psFitsClose (fits); 654 return (TRUE); 655 } -
trunk/psphot/src/psphotSetup.c
r5672 r5754 27 27 char *input = psMetadataLookupPtr (&status, config, "IMAGE"); 28 28 if (!status) psAbort ("psphot", "input image not specified"); 29 psFits *file = psFits Alloc (input);29 psFits *file = psFitsOpen (input, "r"); 30 30 header = psFitsReadHeader (header, file); 31 31 psImage *tmpimage = psFitsReadImage (NULL, file, region, 0); 32 32 image = psImageCopy (NULL, tmpimage, PS_TYPE_F32); 33 psF ree (file);33 psFitsClose (file); 34 34 35 35 // psFree (input); … … 46 46 char *weightName = psMetadataLookupPtr (&status, config, "WEIGHT"); 47 47 if (status == true) { 48 file = psFits Alloc (weightName);48 file = psFitsOpen (weightName, "r"); 49 49 weight = psFitsReadImage (NULL, file, region, 0); 50 psF ree (file);50 psFitsClose (file); 51 51 // psFree (weightName); XXX - see psFree (input) 52 52 } else { … … 64 64 if (status == true) { 65 65 // XXX EAM require / convert mask to psU8? 66 file = psFits Alloc (maskName);66 file = psFitsOpen (maskName, "r"); 67 67 mask = psFitsReadImage (NULL, file, region, 0); 68 psF ree (file);68 psFitsClose (file); 69 69 // psFree (maskName); XXX - see psFree (input) 70 70 } else {
Note:
See TracChangeset
for help on using the changeset viewer.
