IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 9, 2010, 6:01:15 PM (16 years ago)
Author:
eugene
Message:

psphotStack now correctly convolves the input images to match target PSF

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/psphot.20100506/src/psphotStackPSF.c

    r27883 r27888  
    44{
    55    bool mdok = false;
     6    pmPSF *psf = NULL;
    67
    7 #ifndef TESTING
    88    // Get the recipe values
    9     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "PPSTACK"); // ppStack recipe
    10     psAssert(recipe, "We've thrown an error on this before.");
     9    psMetadata *psphotRecipe = psMetadataLookupMetadata(NULL, config->recipes, "PSPHOT"); // psphot recipe
     10    psAssert(psphotRecipe, "We've thrown an error on this before.");
    1111
    12     int psfInstances = psMetadataLookupS32(NULL, recipe, "PSF.INSTANCES"); // Number of instances for PSF
    13     float psfRadius = psMetadataLookupF32(NULL, recipe, "PSF.RADIUS"); // Radius for PSF
    14     const char *psfModel = psMetadataLookupStr(NULL, recipe, "PSF.MODEL"); // Model for PSF
    15     int psfOrder = psMetadataLookupS32(NULL, recipe, "PSF.ORDER"); // Spatial order for PSF
     12    bool autoPSF = psMetadataLookupBool (&mdok, psphotRecipe, "PSPHOT.STACK.TARGET.PSF.AUTO");
    1613
    17     psString maskValStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask going in
    18     if (!mdok || !maskValStr) {
    19         psError(PSPHOT_ERR_CONFIG, false, "Unable to find MASK.VAL in recipe");
    20         return false;
     14    if (autoPSF) {
     15        // Get the recipe values
     16        psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "PPSTACK"); // ppStack recipe
     17        psAssert(recipe, "We've thrown an error on this before.");
     18
     19        int psfInstances = psMetadataLookupS32(NULL, recipe, "PSF.INSTANCES"); // Number of instances for PSF
     20        float psfRadius = psMetadataLookupF32(NULL, recipe, "PSF.RADIUS"); // Radius for PSF
     21        const char *psfModel = psMetadataLookupStr(NULL, recipe, "PSF.MODEL"); // Model for PSF
     22        int psfOrder = psMetadataLookupS32(NULL, recipe, "PSF.ORDER"); // Spatial order for PSF
     23
     24        psString maskValStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask going in
     25        if (!mdok || !maskValStr) {
     26            psError(PSPHOT_ERR_CONFIG, false, "Unable to find MASK.VAL in recipe");
     27            return false;
     28        }
     29        psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask
     30
     31        for (int i = 0; i < psfs->n; i++) {
     32            if (inputMask->data.U8[i]) {
     33                psFree(psfs->data[i]);
     34                psfs->data[i] = NULL;
     35            }
     36        }
     37
     38        // Solve for the target PSF
     39        psf = pmPSFEnvelope(numCols, numRows, psfs, psfInstances, psfRadius, psfModel, psfOrder, psfOrder, maskVal);
     40        if (!psf) {
     41            psError(PSPHOT_ERR_PSF, false, "Unable to determine output PSF.");
     42            return NULL;
     43        }
     44
     45    } else {
     46
     47        // externally-defined PSF
     48        // XXX need to test for compatibility of target with inputs
     49
     50        float targetFWHM = psMetadataLookupF32 (&mdok, psphotRecipe, "PSPHOT.STACK.TARGET.PSF.FWHM");
     51        psAssert (isfinite(targetFWHM), "missing psphot recipe value PSPHOT.STACK.TARGET.PSF.FWHM");
     52
     53        float Sxx = sqrt(2.0)*targetFWHM / 2.35;
     54
     55        // XXX probably should make the model type (and par 7) optional from recipe
     56        psf = pmPSFBuildSimple("PS_MODEL_PS1_V1", Sxx, Sxx, 0.0, 1.0);
     57        if (!psf) {
     58            psError(PSPHOT_ERR_PSF, false, "Unable to build dummy PSF.");
     59            return NULL;
     60        }
    2161    }
    22     psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask
    23 
    24     for (int i = 0; i < psfs->n; i++) {
    25         if (inputMask->data.U8[i]) {
    26             psFree(psfs->data[i]);
    27             psfs->data[i] = NULL;
    28         }
    29     }
    30 
    31     // Solve for the target PSF
    32     pmPSF *psf = pmPSFEnvelope(numCols, numRows, psfs, psfInstances, psfRadius, psfModel, psfOrder, psfOrder, maskVal);
    33     if (!psf) {
    34         psError(PSPHOT_ERR_PSF, false, "Unable to determine output PSF.");
    35         return NULL;
    36     }
    37 #else
    38     // Dummy PSF
    39     pmPSF *psf = pmPSFBuildSimple("PS_MODEL_PS1_V1", 4.0, 4.0, 0.0, 1.0);
    40     if (!psf) {
    41         psError(PSPHOT_ERR_PSF, false, "Unable to build dummy PSF.");
    42         return NULL;
    43     }
    44 #endif
    4562
    4663    return psf;
Note: See TracChangeset for help on using the changeset viewer.