IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 1, 2009, 3:52:39 PM (17 years ago)
Author:
eugene
Message:

add ability to read a text list of sources (for forced photometry); fix destination for nRegions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmPSF_IO.c

    r25854 r25979  
    4949#include "pmSource.h"
    5050#include "pmModelClass.h"
     51#include "pmModelUtils.h"
    5152#include "pmSourceIO.h"
    5253
     
    267268        }
    268269        residName = pmFPAfileNameFromRule (rule, file, view);
     270
     271        // EXTNAME for psf image
     272        // rule = psMetadataLookupStr(&status, menu, "PSF.RESID");
     273        // if (!rule) {
     274        //     psError(PS_ERR_UNKNOWN, false, "missing entry for PSF.RESID in EXTNAME.RULES in camera.config");
     275        //     psFree (headName);
     276        //     psFree (tableName);
     277        //     psFree(hdu);
     278        //     return false;
     279        // }
     280        // residName = pmFPAfileNameFromRule (rule, file, view);
    269281    }
    270282
     
    477489    }
    478490
     491    // write a representation of the psf model
     492    {
     493        psMetadata *header = psMetadataAlloc ();
     494
     495        if (0) {
     496            // set some header keywords to make it clear there are no residuals?
     497            psFitsWriteBlank (file->fits, header, residName);
     498            psFree (residName);
     499            psFree (header);
     500            return true;
     501        }
     502
     503        int DX = 65;
     504        int DY = 65;
     505
     506        psImage *psfMosaic = psImageAlloc (DX, DY, PS_TYPE_F32);
     507        psImageInit (psfMosaic, 0.0);
     508
     509        pmModel *modelRef = pmModelAlloc(psf->type);
     510
     511        // use the center of the center pixel of the image
     512        float xc = 0.5*psf->fieldNx;
     513        float yc = 0.5*psf->fieldNy;
     514
     515        // assign the x and y coords to the image center
     516        // create an object with center intensity of 1000
     517        modelRef->params->data.F32[PM_PAR_SKY] = 0;
     518        modelRef->params->data.F32[PM_PAR_I0] = 1.000;
     519        modelRef->params->data.F32[PM_PAR_XPOS] = xc;
     520        modelRef->params->data.F32[PM_PAR_YPOS] = yc;
     521
     522        // create modelPSF from this model
     523        pmModel *model = pmModelFromPSF (modelRef, psf);
     524        if (model) {
     525            // place the reference object in the image center
     526            pmModelAddWithOffset (psfMosaic, NULL, model, PM_MODEL_OP_FULL | PM_MODEL_OP_CENTER, 0, 0.0, 0.0);
     527            psFree (model);
     528       
     529            if (false) {
     530                // this call creates an extension with NAXIS3 = 3
     531                psArray *images = psArrayAllocEmpty (3);
     532                psArrayAdd (images, 1, psfMosaic);
     533                // psArrayAdd (images, 1, psfModel);
     534                // psArrayAdd (images, 1, psfModel);
     535
     536                psFitsWriteImageCube (file->fits, header, images, "PSF_MODEL");
     537                psFree (images);
     538            } else {
     539                // this call creates an extension with NAXIS3 = 1
     540                // XXX need to replace PSF_MODEL with rule-based name like residName
     541                psFitsWriteImage(file->fits, header, psfMosaic, 0, "PSF_MODEL");
     542            }
     543        }
     544
     545        psFree (psfMosaic);
     546        psFree (modelRef);
     547        psFree (header);
     548    }
     549
    479550    return true;
    480551
     
    693764        psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY);
    694765    } else {
    695         psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS",  PS_META_REPLACE, "psf clump regions", nRegions);
     766        psMetadataAddS32 (analysis, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS",  PS_META_REPLACE, "psf clump regions", nRegions);
    696767
    697768        for (int i = 0; i < nRegions; i++) {
Note: See TracChangeset for help on using the changeset viewer.