IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20348


Ignore:
Timestamp:
Oct 23, 2008, 2:16:09 PM (18 years ago)
Author:
Paul Price
Message:

Revert to using old method of finding warp PSF: old method doesn't work properly yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarpLoop.c

    r20115 r20348  
    33
    44#define WCS_NONLIN_TOL 0.001            // Non-linear tolerance for header WCS
     5#define PSPHOT_FIND_PSF 0               // Use psphot's findPSF function?
     6//#define TESTING 1                       // Testing output?
    57
    68// Lists of file rules for the detectors and skycells, and an independent list of everything else
     
    810static char *detectorFiles[] = { "PSWARP.INPUT", "PSWARP.MASK", "PSWARP.WEIGHT", NULL };
    911static char *skycellFiles[] = { "PSWARP.OUTPUT", "PSWARP.OUTPUT.MASK", "PSWARP.OUTPUT.WEIGHT", NULL };
    10 static char *photFiles[] = { "PSPHOT.INPUT", "PSPHOT.OUTPUT", "PSPHOT.INPUT.CMF", "PSPHOT.RESID",
     12static char *photFiles[] = { "PSPHOT.INPUT", "PSPHOT.OUTPUT",
     13#if PSPHOT_FIND_PSF
     14                             "PSPHOT.INPUT.CMF",
     15#endif
     16                             "PSPHOT.RESID",
    1117                             "PSPHOT.BACKMDL", "PSPHOT.BACKMDL.STDEV", "PSPHOT.BACKGND", "PSPHOT.BACKSUB",
    1218                             "PSPHOT.PSF.SAVE", "SOURCE.PLOT.MOMENTS", "SOURCE.PLOT.PSFMODEL",
     
    350356                          "Don't allow psphot to fit a fake PSF!", false);
    351357
    352 #if 0
     358#if !PSPHOT_FIND_PSF
    353359        // Get rid of the transformed sources so that we can measure the PSF
    354360        psMetadataRemoveKey(output->analysis, "PSPHOT.SOURCES");
     
    360366        pmFPAview *view = pmFPAviewAlloc(0); // View into skycell
    361367        view->chip = view->cell = view->readout = 0;
     368
     369#if PSPHOT_FIND_PSF
     370        // Need to adjust the weight --- the main operation in psphotReadoutFindPSF is not determining the
     371        // signficance of sources, but looking at the significance of individual pixels.
     372        // We can adjust the weight directly since this is a deep copy
     373        pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa);
     374        float vf = psMetadataLookupF32(NULL, photRO->parent->concepts, "CELL.VARFACTOR"); // Variance factor
     375        psBinaryOp(photRO->weight, photRO->weight, "*", psScalarAlloc(vf, PS_TYPE_F32));
     376
    362377        if (!psphotReadoutFindPSF(config, view)) {
    363378            psError(PS_ERR_UNKNOWN, false, "Unable to determine PSF for warped image.");
    364379            return false;
    365380        }
     381#else
     382        if (!psphotReadout(config, view)) {
     383            psError(PS_ERR_UNKNOWN, false, "Unable to determine PSF for warped image.");
     384            return false;
     385        }
     386#endif
     387
     388#ifdef TESTING
     389        {
     390            #define PSF_SIZE 20         // Half-size of PSF
     391            #define PSF_FLUX 10000      // Central flux for PSF
     392            pmChip *photChip = pmFPAviewThisChip(view, photFile->fpa);
     393            pmPSF *psf = psMetadataLookupPtr(NULL, photChip->analysis, "PSPHOT.PSF");
     394            psImage *image = psImageAlloc(2 * PSF_SIZE + 1, 2 * PSF_SIZE + 1, PS_TYPE_F32);
     395            psImageInit(image, 0);
     396            pmModel *model = pmModelFromPSFforXY(psf, PSF_SIZE, PSF_SIZE, PSF_FLUX);
     397            pmModelAdd(image, NULL, model, PM_MODEL_OP_FULL, 0);
     398            psFree(model);
     399            psFits *fits = psFitsOpen("psf.fits", "w");
     400            psFitsWriteImage(fits, NULL, image, 0, NULL);
     401            psFitsClose(fits);
     402            psFree(image);
     403        }
     404#endif
     405
    366406        psFree(view);
    367407    }
Note: See TracChangeset for help on using the changeset viewer.