IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5754


Ignore:
Timestamp:
Dec 8, 2005, 4:39:17 PM (21 years ago)
Author:
eugene
Message:

updated to use psFitsAlloc

Location:
trunk/psphot/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotOutput.c

    r5672 r5754  
    199199
    200200    // create file, write-out header
    201     unlink (filename);
    202     psFits *fits = psFitsAlloc (filename);
     201    psFits *fits = psFitsOpen (filename, "w");
    203202
    204203    // set NAXIS to 0 : CFITSIO requires isolated header to have NAXIS = 0
     
    209208    // psMetadataAdd (imdata->header, PS_LIST_HEAD, "NAXIS", PS_DATA_S32 | PS_META_REPLACE, "", 0);
    210209    psFitsWriteHeader (imdata->header, fits);
    211     psFree (fits);
     210    psFitsClose (fits);
    212211
    213212    // re-open, add data to end of file
     
    336335    psMetadataAdd (theader, PS_LIST_HEAD, "EXTNAME", PS_DATA_STRING, "extension name", "SMPFILE");
    337336
    338     unlink (filename);
    339     psFits *fits = psFitsAlloc (filename);
     337    psFits *fits = psFitsOpen (filename, "w");
    340338    psFitsWriteHeader (imdata->header, fits);
    341339    psFitsWriteTable (fits, theader, table);
    342     psFree (fits);
     340    psFitsClose (fits);
    343341
    344342    return true;
     
    542540}
    543541
     542// write the moments to an output file
     543bool 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
    544572// translations between psphot object types and dophot object types
    545573int pmSourceDophotType (pmSource *source) {
     
    581609int psphotSaveImage (psMetadata *header, psImage *image, char *filename) {
    582610
    583     unlink (filename);
    584     psFits *fits = psFitsAlloc (filename);
     611    psFits *fits = psFitsOpen (filename, "w");
    585612    psFitsWriteImage (fits, NULL, image, 0);
    586     psFree (fits);
     613    psFitsClose (fits);
    587614    return (TRUE);
    588615}
     616
     617psImage *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
     631bool 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  
    2727    char *input = psMetadataLookupPtr (&status, config, "IMAGE");
    2828    if (!status) psAbort ("psphot", "input image not specified");
    29     psFits *file = psFitsAlloc (input);
     29    psFits *file = psFitsOpen (input, "r");
    3030    header = psFitsReadHeader (header, file);
    3131    psImage *tmpimage = psFitsReadImage (NULL, file, region, 0);
    3232    image = psImageCopy (NULL, tmpimage, PS_TYPE_F32);
    33     psFree (file);
     33    psFitsClose (file);
    3434   
    3535    // psFree (input);
     
    4646    char *weightName = psMetadataLookupPtr (&status, config, "WEIGHT");
    4747    if (status == true) {
    48         file = psFitsAlloc (weightName);
     48        file = psFitsOpen (weightName, "r");
    4949        weight = psFitsReadImage  (NULL, file, region, 0);
    50         psFree (file);
     50        psFitsClose (file);
    5151        // psFree (weightName); XXX - see psFree (input)
    5252    } else {
     
    6464    if (status == true) {
    6565        // XXX EAM require / convert mask to psU8?
    66         file = psFitsAlloc (maskName);
     66        file = psFitsOpen (maskName, "r");
    6767        mask  = psFitsReadImage  (NULL, file, region, 0);
    68         psFree (file);
     68        psFitsClose (file);
    6969        // psFree (maskName); XXX - see psFree (input)
    7070    } else {
Note: See TracChangeset for help on using the changeset viewer.