IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27888


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

Location:
branches/eam_branches/psphot.20100506/src
Files:
8 edited

Legend:

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

    r27833 r27888  
    1919    pmConceptsDone ();
    2020    pmConfigDone ();
     21    psLibFinalize();
    2122    // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "psphot");
    2223    fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "psphot");
  • branches/eam_branches/psphot.20100506/src/psphotStackImageLoop.c

    r27884 r27888  
    5353
    5454                // XXX for now, we assume there is only a single chip in the PHU:
    55                 if (!psphotStackReadout (config, view)) {
     55                if (0 && !psphotStackReadout (config, view)) {
    5656                    psError(psErrorCodeLast(), false, "failure in psphotStackReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
    5757                    psFree (view);
  • branches/eam_branches/psphot.20100506/src/psphotStackMatchPSFs.c

    r27884 r27888  
    5858        }
    5959    }
     60
     61    psFree (options);
    6062    return true;
    6163}
     
    7880    pmReadout *readoutOut = pmFPAviewThisReadout(view, fileOut->fpa);
    7981    if (readoutOut == NULL) {
    80         readoutOut = pmFPAGenerateReadout(config, view, "PSPHOT.STACK.OUTPUT.IMAGE", fileSrc->fpa, NULL, 0);
     82        readoutOut = pmFPAGenerateReadout(config, view, "PSPHOT.STACK.OUTPUT.IMAGE", fileSrc->fpa, NULL, index);
    8183        psAssert (readoutOut, "missing readout?");
    8284    }
  • branches/eam_branches/psphot.20100506/src/psphotStackMatchPSFsPrepare.c

    r27884 r27888  
    8383}
    8484
    85     // determine the input seeing
     85// determine the input seeing
    8686bool determineSeeing (pmPSF *psf, psphotStackOptions *options, int index) {
    8787
  • branches/eam_branches/psphot.20100506/src/psphotStackMatchPSFsUtils.c

    r27884 r27888  
    4545}
    4646
     47# define SN_MIN 50.0
    4748psArray *stackSourcesFilter(psArray *sources, // Source list to filter
    4849                            int exclusion // Exclusion zone, pixels
     
    6263            continue;
    6364        }
     65        if (!source->peak) continue;
     66        if (source->peak->SN < SN_MIN) continue;
    6467        coordsFromSource(&x->data.F32[numGood], &y->data.F32[numGood], source);
    6568        numGood++;
     
    7780            continue;
    7881        }
     82        if (!source->peak) continue;
     83        if (source->peak->SN < SN_MIN) continue;
    7984        float xSource, ySource;         // Coordinates of source
    8085        coordsFromSource(&xSource, &ySource, source);
     
    325330
    326331    // These values are specified specifically for stacking
    327     const char *stampsName = psMetadataLookupStr(NULL, config->arguments, "STAMPS");// Stamps filename
     332    const char *stampsName = psMetadataLookupStr(&mdok, config->arguments, "STAMPS");// Stamps filename
    328333
    329334    psVector *widthsCopy = NULL;
  • branches/eam_branches/psphot.20100506/src/psphotStackOptions.c

    r27884 r27888  
    55    if (options == NULL) return;
    66
     7    // free the psf
    78    psFree (options->psf);
    8     psFree (options->inputSeeing);
     9
     10    // free the array elements
     11    psFree (options->psfs);
    912    psFree (options->sourceLists);
    10     psFree (options->norm);
    1113    psFree (options->kernels);
    1214    psFree (options->regions);
     15
     16    // free the vector elements
     17    psFree (options->inputMask);
     18    psFree (options->inputSeeing);
     19    psFree (options->norm);
    1320    psFree (options->matchChi2);
    1421    psFree (options->weightings);
  • 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;
  • branches/eam_branches/psphot.20100506/src/psphotStackParseCamera.c

    r27884 r27888  
    125125            }
    126126            outputMask->save = true;
     127            outputMask->fileID = i;             // this is used to generate output names
    127128
    128129            pmFPAfile *outputVariance = pmFPAfileDefineOutput(config, outputImage->fpa, "PSPHOT.STACK.OUTPUT.VARIANCE");
     
    136137            }
    137138            outputVariance->save = true;
     139            outputVariance->fileID = i;         // this is used to generate output names
    138140
    139141            // the output sources are carried on the outputImage->fpa structures
Note: See TracChangeset for help on using the changeset viewer.