IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 19, 2006, 7:26:08 PM (20 years ago)
Author:
eugene
Message:

working on global linear fit with sky level

File:
1 edited

Legend:

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

    r10076 r10096  
    2626    }
    2727
     28    // supply the measured sky variance for optional constant errors (non-poissonian)
     29    float SKY_STDEV = psMetadataLookupF32 (&status, recipe, "SKY_STDEV");
     30    if (!status) {
     31        SKY_STDEV = 1.0;
     32        psWarning("SKY_STDEV is not set --- defaulting to %f\n", SKY_STDEV);
     33    }
    2834    // use poissonian errors or local-sky errors
    2935    bool POISSON_ERRORS = psMetadataLookupBool (&status, recipe, "POISSON_ERRORS");
     
    3238        psWarning("POISSON_ERRORS is not set in the recipe --- defaulting to true.\n");
    3339    }
     40    pmSourceFitModelInit (15, 0.01, PS_SQR(SKY_STDEV), POISSON_ERRORS);
    3441
    3542    // how to model the PSF variations across the field
     
    4855    }
    4956
    50     pmSourceFitModelInit (15, 0.1, POISSON_ERRORS);
    51 
    5257    stars = psArrayAllocEmpty (sources->n);
    5358
     
    9499        modelName = item->data.V;
    95100        models->data[i] = pmPSFtryModel (stars, modelName, RADIUS, POISSON_ERRORS, psfTrendMask);
    96     }
    97 
    98     // XXX test dump of psf stars and model
    99     if (1) {
    100         psphotSaveImage (NULL, readout->image,  "testsub.fits");
    101         pmSourcesWritePSFs (stars, "psfstars.dat");
    102         try = models->data[0];
    103         psf = try->psf;
    104         psMetadata *psfData = pmPSFtoMetadata (NULL, psf);
    105         psMetadataConfigWrite (psfData, "psfmodel.dat");
    106         psFree (psfData);
    107101    }
    108102
     
    138132    try = models->data[bestN];
    139133
     134    // XXX test dump of psf star data and psf-subtracted image
     135    if (0) {
     136        for (int i = 0; i < try->sources->n; i++) {
     137            // masked for: bad model fit, outlier in parameters
     138            if (try->mask->data.U8[i] & PSFTRY_MASK_ALL)
     139                continue;
     140
     141            pmSource *source = try->sources->data[i];
     142            float x = source->modelPSF->params->data.F32[PM_PAR_XPOS];
     143            float y = source->modelPSF->params->data.F32[PM_PAR_YPOS];
     144
     145            // set the mask and subtract the PSF model
     146            psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PM_MASK_MARK);
     147            pmModelSub (source->pixels, source->mask, source->modelPSF, false, false);
     148            psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_U8(PM_MASK_MARK));
     149        }
     150
     151        psphotSaveImage (NULL, readout->image,  "psfstars.fits");
     152        pmSourcesWritePSFs (try->sources, "psfstars.dat");
     153        psMetadata *psfData = pmPSFtoMetadata (NULL, try->psf);
     154        psMetadataConfigWrite (psfData, "psfmodel.dat");
     155        psFree (psfData);
     156        psLogMsg ("psphot.choosePSF", 3, "wrote out psf-subtracted image, psf data, exiting\n");
     157        exit (0);
     158    }
     159
    140160    // unset the PSFSTAR flag for stars not used for PSF model
    141161    for (int i = 0; i < try->sources->n; i++) {
Note: See TracChangeset for help on using the changeset viewer.