IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18346


Ignore:
Timestamp:
Jun 27, 2008, 12:05:30 PM (18 years ago)
Author:
Paul Price
Message:

Instead of being dependent upon a single list of sources, want to be able to use all the available information. So One common failure mode in the MOPS processing was that the source list didn't cover the entire skycell, so convolutions didn't succeed. Now we get a source list for each input image and merge these. Still retains (or at least, supposed to) the old way of inputting a single source list on the command line.

Location:
trunk/ppStack/src
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/Makefile.am

    r16605 r18346  
    1313        ppStackPhotometry.c     \
    1414        ppStackVersion.c        \
    15         ppStackMatch.c
     15        ppStackMatch.c          \
     16        ppStackSources.c
    1617
    1718noinst_HEADERS =                \
  • trunk/ppStack/src/ppStack.h

    r17255 r18346  
    6161                  psArray **regions, // Array of regions used in each PSF matching, returned
    6262                  psArray **kernels, // Array of kernels used in each PSF matching, returned
    63                   const pmReadout *sourcesRO, ///< Readout with sources
     63                  const psArray *sources, ///< Array of sources
    6464                  const pmPSF *psf,     ///< Target PSF
    6565                  psRandom *rng,        ///< Random number generator
     
    6767    );
    6868
     69
     70/// Add sources to source lists, removing duplicates and solving for magnitude differences
     71///
     72/// Returns the source lists.
     73psArray *ppStackSourceListAdd(psArray *lists, ///< List to which to add, or NULL
     74                              const pmReadout *inRO, ///< Readout containing the sources
     75                              const pmConfig *config ///< Configuration
     76    );
     77
     78/// Combine source lists to yield a unique set of sources
     79///
     80/// Returns the sources
     81psArray *ppStackSourceListCombine(psArray *lists, ///< Source lists
     82                                  const pmConfig *config ///< Configuration
     83    );
     84
     85
    6986#endif
  • trunk/ppStack/src/ppStackArguments.c

    r17255 r18346  
    2424            "\tIMAGE(STR):     Image filename\n"
    2525            "\tMASK(STR):      Mask filename\n"
    26             "\tWEIGHT(STR)     Weight map filename\n"
    27             "\tPSF(STR)        PSF filename\n"
     26            "\tWEIGHT(STR):    Weight map filename\n"
     27            "\tPSF(STR):       PSF filename\n"
     28            "\tSOURCES(STR):   Sources filename\n"
    2829            "\tWEIGHTING(F32): Relative weighting to be applied\n",
    2930            program);
     
    155156    psMetadataAddBool(arguments, PS_LIST_TAIL, "-variance", 0, "Use variance for rejection?", false);
    156157    psMetadataAddBool(arguments, PS_LIST_TAIL, "-safe", 0, "Play safe with small numbers of pixels to combine?", false);
     158    psMetadataAddF32(arguments, PS_LIST_TAIL, "-source-radius", 0, "Source exclusion radius", NAN);
     159    psMetadataAddS32(arguments, PS_LIST_TAIL, "-source-iter", 0, "Source clipping iterations", 0);
     160    psMetadataAddF32(arguments, PS_LIST_TAIL, "-source-rej", 0, "Source clipping rejection level", NAN);
     161    psMetadataAddS32(arguments, PS_LIST_TAIL, "-source-min", 0, "Source minimum overlap", 0);
    157162    psMetadataAddBool(arguments, PS_LIST_TAIL, "-renorm", 0, "Renormalise variance maps?", false);
    158163    psMetadataAddStr(arguments, PS_LIST_TAIL, "-renorm-mean", 0, "Statistic for mean in renormalisation", NULL);
     
    203208    VALUE_ARG_RECIPE_INT("-rows",             "ROWS",           S32, 0);
    204209
     210    VALUE_ARG_RECIPE_FLOAT("-source-radius", "SOURCE.RADIUS", F32);
     211    VALUE_ARG_RECIPE_INT("-source-iter",     "SOURCE.ITER",   S32, 0);
     212    VALUE_ARG_RECIPE_FLOAT("-source-rej",    "SOURCE.REJ",    F32);
     213    VALUE_ARG_RECIPE_INT("-source-min",      "SOURCE.MIN",    S32, 0);
     214
    205215    VALUE_ARG_RECIPE_INT("-psf-instances", "PSF.INSTANCES", S32, 0);
    206216    VALUE_ARG_RECIPE_FLOAT("-psf-radius",  "PSF.RADIUS",    F32);
  • trunk/ppStack/src/ppStackCamera.c

    r17916 r18346  
    7272{
    7373    bool haveWeights = false;           // Do we have weight maps?
    74     bool havePSFs = false;               // Do we have PSFs?
     74    bool havePSFs = false;              // Do we have PSFs?
     75    bool haveSources = (bool)psMetadataLookup(config->arguments, "PPSTACK.SOURCES"); // Have global sources?
    7576
    7677    psMetadata *inputs = psMetadataLookupMetadata(NULL, config->arguments, "INPUTS"); // The inputs info
     
    99100        psString weight = psMetadataLookupStr(&mdok, input, "WEIGHT"); // Name of weight map
    100101        psString psf = psMetadataLookupStr(&mdok, input, "PSF"); // Name of PSF
     102        psString sources = psMetadataLookupStr(&mdok, input, "SOURCES"); // Name of sources
    101103
    102104        float weighting = psMetadataLookupF32(&mdok, input, "WEIGHTING"); // Relative weighting
     
    198200        }
    199201
     202        // Add the sources file
     203        if (!haveSources) {
     204            if (!sources || strlen(sources) == 0) {
     205                if (havePSFs) {
     206                    psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find SOURCES %d", i);
     207                    return false;
     208                }
     209            } else {
     210                if (!havePSFs) {
     211                    psWarning("SOURCES provided without PSF --- ignoring.");
     212                } else {
     213                    psArray *sourcesFiles = psArrayAlloc(1); // Array of filenames for this FPA
     214                    sourcesFiles->data[0] = psMemIncrRefCounter(sources);
     215                    psMetadataAddArray(config->arguments, PS_LIST_TAIL, "SOURCES.FILENAMES", PS_META_REPLACE,
     216                                       "Filenames of SOURCES files", sourcesFiles);
     217                    psFree(sourcesFiles);
     218
     219                    bool status;
     220                    pmFPAfile *sourcesFile = pmFPAfileBindFromArgs(&status, imageFile, config,
     221                                                                   "PPSTACK.INPUT.SOURCES",
     222                                                                   "SOURCES.FILENAMES");
     223                    if (!status) {
     224                        psError(PS_ERR_UNKNOWN, false, "Unable to define file from sources %d (%s)",
     225                                i, sources);
     226                        return false;
     227                    }
     228                    if (sourcesFile->type != PM_FPA_FILE_CMF) {
     229                        psError(PS_ERR_IO, true, "PPSTACK.INPUT.SOURCES is not of type CMF");
     230                        return false;
     231                    }
     232                }
     233            }
     234        }
     235
    200236#if 0
    201237        // Output convolved files
     
    238274        psMetadataRemoveKey(config->arguments, "PSF.FILENAMES");
    239275    }
     276    if (psMetadataLookup(config->arguments, "SOURCES.FILENAMES")) {
     277        psMetadataRemoveKey(config->arguments, "SOURCES.FILENAMES");
     278    }
     279
     280    if (haveSources) {
     281        // Global list of sources for use as stamps
     282        bool status = false;            // Found the file?
     283        if (havePSFs) {
     284            pmFPAfile *sources = pmFPAfileDefineFromArgs(&status, config, "PPSTACK.INPUT.SOURCES",
     285                                                         "PPSTACK.SOURCES");
     286            if (!status) {
     287                psError(PS_ERR_IO, false, "Failed to load file definition PPSTACK.INPUT.SOURCES");
     288                return false;
     289            }
     290            if (sources && sources->type != PM_FPA_FILE_CMF) {
     291                psError(PS_ERR_IO, true, "PPSTACK.SOURCES is not of type CMF");
     292                return false;
     293            }
     294        }
     295    }
    240296
    241297    psMetadataAddS32(config->arguments, PS_LIST_TAIL, "INPUTS.NUM", 0, "Number of input files", i);
    242298    psMetadataAddBool(config->arguments, PS_LIST_TAIL, "HAVE.PSF", 0, "Have PSFs available?", havePSFs);
     299    psMetadataAddBool(config->arguments, PS_LIST_TAIL, "HAVE.SOURCES", 0, "Have global sources?",
     300                      haveSources);
    243301
    244302    // Output image
     
    326384    }
    327385
    328     // Sources for use as stamps
    329     bool status = false;                // Found the file?
    330     if (havePSFs) {
    331         pmFPAfile *sources = pmFPAfileDefineFromArgs(&status, config, "PPSTACK.SOURCES", "PPSTACK.SOURCES");
    332         if (!status) {
    333             psError(PS_ERR_IO, false, "Failed to load file definition PPSTACK.SOURCES");
    334             return false;
    335         }
    336         if (sources && sources->type != PM_FPA_FILE_CMF) {
    337             psError(PS_ERR_IO, true, "PPSTACK.SOURCES is not of type CMF");
    338             return false;
    339         }
    340     }
    341 
    342386    return true;
    343387}
  • trunk/ppStack/src/ppStackLoop.c

    r18168 r18346  
    1717
    1818// Files required in preparation for convolution
    19 static char *prepareFiles[] = { "PPSTACK.INPUT.PSF", "PPSTACK.SOURCES", NULL };
     19static char *prepareFiles[] = { "PPSTACK.INPUT.PSF", "PPSTACK.INPUT.SOURCES", NULL };
    2020
    2121// Files required for the convolution
     
    213213    // Preparation iteration: Load the sources, and get a target PSF model
    214214    psTrace("ppStack", 1, "Determining target PSF....\n");
    215     pmReadout *sources = NULL;          // Readout with sources to use for PSF matching
     215    psArray *sources = NULL;            // Sources to use for PSF matching
    216216    pmPSF *targetPSF = NULL;            // Target PSF
     217    bool haveSources = psMetadataLookupBool(NULL, config->arguments, "HAVE.SOURCES"); // Global sources?
    217218    if (psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) {
    218219        pmFPAfileActivate(config->files, false, NULL);
     
    223224        }
    224225
    225         // We want to hang on to the 'sources' even when its host FPA is blown away
    226         sources = psMemIncrRefCounter(pmFPAfileThisReadout(config->files, view, "PPSTACK.SOURCES"));
    227         if (!sources) {
    228             psError(PS_ERR_UNKNOWN, true, "Unable to find sources.");
    229             psFree(view);
    230             return false;
    231         }
    232 
    233226        // Generate list of PSFs
    234227        psMetadataIterator *fileIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD,
     
    236229        psMetadataItem *fileItem; // Item from iteration
    237230        psArray *psfs = psArrayAlloc(num); // PSFs for PSF envelope
     231        psArray *sourceLists = NULL;    // Source lists for merging sources from multiple readouts
    238232        int numCols = 0, numRows = 0;   // Size of image
    239233        int index = 0;                  // Index for file
     
    247241                psFree(view);
    248242                psFree(sources);
     243                psFree(sourceLists);
    249244                psFree(fileIter);
    250245                psFree(psfs);
     
    263258                psFree(view);
    264259                psFree(sources);
     260                psFree(sourceLists);
    265261                psFree(fileIter);
    266262                psFree(psfs);
     
    270266                numCols = naxis1;
    271267                numRows = naxis2;
     268            }
     269
     270            if (!haveSources) {
     271                pmReadout *ro = pmFPAviewThisReadout(view, inputFile->fpa); // Readout with sources
     272                sourceLists = ppStackSourceListAdd(sourceLists, ro, config);
     273                if (!sourceLists) {
     274                    psError(PS_ERR_UNKNOWN, false, "Unable to add sources to list.");
     275                    psFree(view);
     276                    psFree(sources);
     277                    psFree(fileIter);
     278                    psFree(psfs);
     279                    return false;
     280                }
    272281            }
    273282        }
     
    281290            psFree(sources);
    282291            return false;
     292        }
     293
     294        if (haveSources) {
     295            // We want to hang on to the 'sources' even when its host FPA is blown away
     296            sources = psMemIncrRefCounter(pmFPAfileThisReadout(config->files, view, "PPSTACK.INPUT.SOURCES"));
     297            if (!sources) {
     298                psError(PS_ERR_UNKNOWN, true, "Unable to find sources.");
     299                psFree(view);
     300                return false;
     301            }
     302        } else {
     303            sources = ppStackSourceListCombine(sourceLists, config);
     304            psFree(sourceLists);
     305            if (!sources) {
     306                psError(PS_ERR_UNKNOWN, false, "Unable to add sources to list.");
     307                psFree(view);
     308                psFree(psfs);
     309                return false;
     310            }
    283311        }
    284312
  • trunk/ppStack/src/ppStackMatch.c

    r18293 r18346  
    1616
    1717bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels,
    18                   const pmReadout *sourcesRO, const pmPSF *psf, psRandom *rng, const pmConfig *config)
     18                  const psArray *sources, const pmPSF *psf, psRandom *rng, const pmConfig *config)
    1919{
    2020    assert(readout);
     
    4646    if (psMetadataLookupBool(&mdok, config->arguments, "HAVE.PSF")) {
    4747        assert(psf);
    48         assert(sourcesRO);
     48        assert(sources);
    4949
    5050        int order = psMetadataLookupS32(NULL, recipe, "SPATIAL.ORDER"); // Spatial polynomial order
     
    8080        }
    8181
    82         psArray *sources = NULL;            // Sources in image
    83         if (sourcesRO) {
    84             sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES");
    85         }
    86 
    8782        // Generate a fake image to match to
    8883        float maxMag = -INFINITY;           // Maximum magnitude of sources
Note: See TracChangeset for help on using the changeset viewer.