IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15017


Ignore:
Timestamp:
Sep 25, 2007, 12:05:51 PM (19 years ago)
Author:
eugene
Message:

no X for kapa; start of code to extend PSF star selection

Location:
trunk/psphot
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/doc/psfmodel.txt

    r15000 r15017  
     1
     22007.09.25
     3
     4  The PSF model has parameters which vary across the image.  This 2D
     5  is can be represented as either a polynomial (ordinary or chebychev)
     6  or as an image map.  The user requests the maximum X & Y scale
     7  (PSF.TREND.NX & PSF.TREND.NY) for the variations, and
     8  psphotChoosePSF / pmPSFtry attempt to find the best choice for the
     9  scale.  For the polynomial representations, NX and NY are the order
     10  of the variation.  For the image map, NX and NY are the size of the
     11  image map.
    112
    2132007.09.21
  • trunk/psphot/src/psphotChoosePSF.c

    r15000 r15017  
    6262
    6363    pmSourceFitModelInit (15, 0.01, PS_SQR(SKY_SIG), options->poissonErrorsPhotLMM);
     64
     65    // check that the identified psf stars sufficiently cover the region; if not, extend the
     66    // limits somewhat
     67    // psphotCheckStarDistribution (sources, options);
    6468
    6569    psArray *stars = psArrayAllocEmpty (sources->n);
     
    8690
    8791    // get the list pointers for the PSF_MODEL entries
    88     psList *list = NULL;
    89     psMetadataItem *mdi = psMetadataLookup (recipe, "PSF_MODEL");
    90     if (mdi == NULL) psAbort("missing PSF_MODEL selection");
    91 
    92     if (mdi->type == PS_DATA_STRING) {
    93         list = psListAlloc(NULL);
    94         psListAdd (list, PS_LIST_HEAD, mdi);
     92    psArray *modelNames = NULL;
     93    psMetadataItem *item = psMetadataLookup (recipe, "PSF_MODEL");
     94    if (item == NULL) psAbort("missing PSF_MODEL selection");
     95
     96    if (item->type == PS_DATA_STRING) {
     97        modelNames = psArrayAlloc(1);
     98        modelNames->data[0] = psStringCopy (item->data.V);
    9599    } else {
    96         if (mdi->type != PS_DATA_METADATA_MULTI) psAbort("missing PSF_MODEL selection");
    97         list = psMemIncrRefCounter(mdi->data.list);
     100        if (item->type != PS_DATA_METADATA_MULTI) psAbort("missing PSF_MODEL selection");
     101        modelNames = psListToArray (item->data.list);
    98102    }
    99103
    100104    // set up an array to store the results
    101     psArray *models = psArrayAlloc (list->n);
     105    psArray *models = psArrayAlloc (modelNames->n);
    102106
    103107    // try each model option listed in config
    104     psListIterator *iter = psListIteratorAlloc (list, PS_LIST_HEAD, FALSE);
    105     for (int i = 0; i < models->n; i++) {
    106         psMetadataItem *item = psListGetAndIncrement (iter);
    107         char *modelName = item->data.V;
     108    for (int i = 0; i < modelNames->n; i++) {
     109        char *modelName = modelNames->data[i];
    108110        models->data[i] = pmPSFtryModel (stars, modelName, options, maskVal, mark);
    109111    }
    110 
    111     psFree (iter);
    112     psFree (list);
    113     psFree (stars);
    114112
    115113    // select the best of the models
     
    120118        pmPSFtry *try = models->data[i];
    121119        if (try == NULL) {
    122             psError(PSPHOT_ERR_PSF, false, "PSF model %d is NULL", i);
     120            psTrace ("psphot", 3, "PSF model %d is NULL", i);
    123121            continue;
    124122        }
     
    132130    // use the best model:
    133131    if (bestN < 0) {
    134         psError (PSPHOT_ERR_DATA, false, "Failed to fit any models when choosing PSF");
    135132        psFree (models);
    136         return NULL;
    137     }
     133        psFree (stars);
     134
     135        // XXX optionally give up here
     136        // generate a psf model using the first selection
     137        psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF");
     138        psErrorStackPrint (stderr, "Using guess PSF model");
     139        psErrorClear ();
     140       
     141        // unset the PSFSTAR flags (none are used):
     142        for (int i = 0; i < sources->n; i++) {
     143            pmSource *source = sources->data[i];
     144            source->mode &= ~PM_SOURCE_MODE_PSFSTAR;
     145        }
     146
     147        // XXX set sxx, etc from FWHM in recipe
     148        pmPSF *psf = pmPSFBuildSimple (modelNames->data[0], 1.0, 1.0, 0.0, 1.0);
     149        psf->fieldNx = readout->image->numCols;
     150        psf->fieldNy = readout->image->numRows;
     151        psFree (modelNames);
     152
     153        bool status = true;
     154        status &= psphotMakeFluxScale (readout->image, recipe, psf);
     155        status &= psphotPSFstats (readout, recipe, psf);
     156        if (!status) {
     157            psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF");
     158            psFree (psf);
     159            return NULL;
     160        }
     161
     162        // XXX set DSX_MEAN, etc?
     163        return psf;
     164    }
     165
     166    psFree (modelNames);
     167    psFree (stars);
    138168
    139169    pmPSFtry *try = models->data[bestN];
    140 
    141     // print/dump psf parameters
    142     if (psTraceGetLevel("psphot") >= 5) {
    143         for (int i = PM_PAR_SXX; i < try->psf->params->n; i++) {
    144             // XXX re-write the output or some other status info
    145         }
    146     }
    147170
    148171    // measure and save the median value of dparams[PM_PAR_SXX],dparams[PM_PAR_SYY]
  • trunk/psphot/src/psphotRadialPlot.c

    r13477 r15017  
    2424    // XXX 'showWindow = false' is broken
    2525    if (*kapa == 0) {
    26         *kapa = pmKapaOpen (true);
     26        *kapa = pmKapaOpen (false);
    2727        KapaResize (*kapa, 500, 500);
    2828        unlink (filename);
Note: See TracChangeset for help on using the changeset viewer.