IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41529 for trunk


Ignore:
Timestamp:
Apr 3, 2021, 11:41:29 AM (5 years ago)
Author:
eugene
Message:

add alternative configuration for images after the first so we can stack images from different cameras (recipes from first image camera are used)

Location:
trunk/ppStack/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackCamera.c

    r35556 r41529  
    3131}
    3232
    33 
     33pmConfig *pmConfigMakeTemp (pmConfig *config) {
     34    pmConfig *altconfig = pmConfigAlloc();
     35
     36    // these are NULL on pmConfigAlloc
     37    altconfig->user   = psMemIncrRefCounter(config->user);   // inherit from primary camera
     38    altconfig->site   = psMemIncrRefCounter(config->site);   // inherit from primary camera
     39    altconfig->system = psMemIncrRefCounter(config->system); // inherit from primary camera
     40
     41    psFree (altconfig->files);
     42    altconfig->files  = psMemIncrRefCounter(config->files); // inherit from primary camera
     43
     44    psFree (altconfig->arguments);
     45    altconfig->arguments = psMemIncrRefCounter(config->arguments); // inherit from primary camera
     46
     47    psFree (altconfig->recipes);
     48    altconfig->recipes = psMetadataCopy(NULL, config->recipes); // container for camera-specific recipe values (to be dropped)
     49
     50    return (altconfig);
     51}
    3452
    3553bool ppStackCamera(pmConfig *config)
     
    4866    bool convolve = psMetadataLookupBool(NULL, recipe, "CONVOLVE"); // Convolve images before stack?
    4967
    50     psArray *runImages = pmFPAfileDefineMultipleFromRun(&status, NULL, config,
    51                                                         "PPSTACK.INPUT"); // Input images from previous run
     68    psArray *runImages = pmFPAfileDefineMultipleFromRun(&status, NULL, config, "PPSTACK.INPUT"); // Input images from previous run
    5269    if (runImages) {
    5370        // Defining files from the RUN metadata
    5471        num = runImages->n;
    5572
    56         psArray *runMasks = pmFPAfileDefineMultipleFromRun(&status, runImages, config,
    57                                                            "PPSTACK.INPUT.MASK"); // Input masks
     73        psArray *runMasks = pmFPAfileDefineMultipleFromRun(&status, runImages, config, "PPSTACK.INPUT.MASK"); // Input masks
    5874        if (!status) {
    5975            psError(psErrorCodeLast(), false, "Unable to define input masks from RUN metadata.");
     
    6379        psFree(runMasks);
    6480
    65         psArray *runVars = pmFPAfileDefineMultipleFromRun(&status, runImages, config,
    66                                                           "PPSTACK.INPUT.VARIANCE"); // Input variances
     81        psArray *runVars = pmFPAfileDefineMultipleFromRun(&status, runImages, config, "PPSTACK.INPUT.VARIANCE"); // Input variances
    6782        if (!status) {
    6883            psError(psErrorCodeLast(), false, "Unable to define input variances from RUN metadata.");
     
    7590        psFree(runVars);
    7691
    77         psArray *runSrc = pmFPAfileDefineMultipleFromRun(&status, runImages, config,
    78                                                          "PPSTACK.INPUT.SOURCES"); // Input sources
     92        psArray *runSrc = pmFPAfileDefineMultipleFromRun(&status, runImages, config, "PPSTACK.INPUT.SOURCES"); // Input sources
    7993        if (!status) {
    8094            psError(psErrorCodeLast(), false, "Unable to define input sources from RUN metadata.");
     
    91105        if (convolve) {
    92106            {
    93                 psArray *runPSF = pmFPAfileDefineMultipleFromRun(&status, runImages, config,
    94                                                          "PPSTACK.INPUT.PSF"); // Input PSFs
     107                psArray *runPSF = pmFPAfileDefineMultipleFromRun(&status, runImages, config, "PPSTACK.INPUT.PSF"); // Input PSFs
    95108                if (!status) {
    96109                    psError(psErrorCodeLast(), false, "Unable to define input PSFs from RUN metadata.");
     
    105118            {
    106119
    107                 psArray *runKernel = pmFPAfileDefineMultipleFromRun(&status, runImages, config,
    108                                                                     "PPSTACK.CONV.KERNEL"); // Conv'n kernels
     120                psArray *runKernel = pmFPAfileDefineMultipleFromRun(&status, runImages, config, "PPSTACK.CONV.KERNEL"); // Conv'n kernels
    109121                if (!status) {
    110122                    psError(psErrorCodeLast(), false,
     
    158170            psString bkgmodel = psMetadataLookupStr(&mdok, input, "BKGMODEL"); // Name of warped background model
    159171           
    160             pmFPAfile *imageFile = defineFile(config, NULL, "PPSTACK.INPUT",
     172            // Use a temporary config for all but the first image, keeping the main user,
     173            // site, system, files, arguments entries loaded for the first image.  This
     174            // allows the images to be from different cameras than the first input image.
     175            // NOTE: there is no check that these images match in terms of size, pixel
     176            // scale, etc. That is up to the user.
     177           
     178            pmConfig *tempConfig = (i == 0) ? psMemIncrRefCounter(config) : pmConfigMakeTemp(config);
     179
     180            pmFPAfile *imageFile = defineFile(tempConfig, NULL, "PPSTACK.INPUT",
    161181                                              image, PM_FPA_FILE_IMAGE); // File for image
    162182            if (!imageFile) {
     
    166186
    167187            if (mask && strlen(mask) > 0 &&
    168                 !defineFile(config, imageFile, "PPSTACK.INPUT.MASK", mask, PM_FPA_FILE_MASK)) {
     188                !defineFile(tempConfig, imageFile, "PPSTACK.INPUT.MASK", mask, PM_FPA_FILE_MASK)) {
    169189                psError(psErrorCodeLast(), false, "Unable to define file from mask %d (%s)", i, mask);
    170190                return false;
     
    173193            if (variance && strlen(variance) > 0) {
    174194                haveVariances = true;
    175                 if (!defineFile(config, imageFile, "PPSTACK.INPUT.VARIANCE", variance,
     195                if (!defineFile(tempConfig, imageFile, "PPSTACK.INPUT.VARIANCE", variance,
    176196                                PM_FPA_FILE_VARIANCE)) {
    177197                    psError(psErrorCodeLast(), false,
     
    186206                } else {
    187207                    havePSFs = true;
    188                     if (!defineFile(config, imageFile, "PPSTACK.INPUT.PSF", psf, PM_FPA_FILE_PSF)) {
     208                    if (!defineFile(tempConfig, imageFile, "PPSTACK.INPUT.PSF", psf, PM_FPA_FILE_PSF)) {
    189209                        psError(psErrorCodeLast(), false, "Unable to define file from psf %d (%s)", i, psf);
    190210                        return false;
     
    200220                return false;
    201221            }
    202             if (!defineFile(config, imageFile, "PPSTACK.INPUT.SOURCES", sources, PM_FPA_FILE_CMF)) {
     222            if (!defineFile(tempConfig, imageFile, "PPSTACK.INPUT.SOURCES", sources, PM_FPA_FILE_CMF)) {
    203223                psError(psErrorCodeLast(), false, "Unable to define file from sources %d (%s)",
    204224                        i, sources);
     
    207227
    208228            if (convolve) {
    209                 pmFPAfile *kernel = pmFPAfileDefineOutput(config, imageFile->fpa, "PPSTACK.CONV.KERNEL");
     229                pmFPAfile *kernel = pmFPAfileDefineOutput(tempConfig, imageFile->fpa, "PPSTACK.CONV.KERNEL");
    210230                if (!kernel) {
    211231                    psError(psErrorCodeLast(), false,
     
    221241              psMetadataAddBool(recipe, PS_LIST_TAIL, "BACKGROUND.MODEL", PS_META_REPLACE, "Do photometry on stacked image?", false);
    222242            } else {
    223               pmFPAfile *inputBKG = defineFile(config,NULL,"PPSTACK.INPUT.BKGMODEL",bkgmodel, PM_FPA_FILE_IMAGE);
     243              pmFPAfile *inputBKG = defineFile(tempConfig,NULL,"PPSTACK.INPUT.BKGMODEL",bkgmodel, PM_FPA_FILE_IMAGE);
    224244              if (!inputBKG) {
    225245                psMetadataAddBool(recipe, PS_LIST_TAIL, "BACKGROUND.MODEL", PS_META_REPLACE, "Do photometry on stacked image?", false);
     
    232252              }
    233253            } // End bkgmodel
     254            psFree(tempConfig);
    234255            i++;
    235256        }
  • trunk/ppStack/src/ppStackLoop.c

    r36855 r41529  
    33// static functions are defined below
    44static int stackSummary(const ppStackOptions *options, const char *place);
     5bool pmConfigDumpRecipe (pmConfig *config, char *filename);
    56
    67bool ppStackLoop(pmConfig *config, ppStackOptions *options)
     
    282283    return numGood;
    283284}
     285
     286// Test function if needed:
     287bool pmConfigDumpRecipe (pmConfig *config, char *filename) {
     288
     289    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim
     290    psAssert (recipe, "oops");
     291
     292    psMetadataConfigWrite (recipe, filename, NULL);
     293
     294    return true;
     295}
     296
  • trunk/ppStack/src/ppStackSources.c

    r35383 r41529  
    227227            }
    228228        } else if (strcmp(filter, expFilter) != 0) {
    229             psError(PPSTACK_ERR_CONFIG, false, "Filters don't match: %s vs %s", filter, expFilter);
    230             psFree(zp);
    231             return false;
     229            psWarning("Filters don't match: %s vs %s", filter, expFilter);
    232230        }
    233231
Note: See TracChangeset for help on using the changeset viewer.