IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 4, 2023, 7:39:02 AM (3 years ago)
Author:
eugene
Message:

merge from trunk: correctly handle different camera diffs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20220316/ppSub/src/ppSubCamera.c

    r42096 r42363  
    119119
    120120
    121 // Define an output file that will be used in a calculation
    122 // This means it might already be available in the RUN metadata
     121// Define an output file that will be used in a calculation. This means it might already be
     122// available in the RUN metadata
     123
     124// EAM 2022.10.14 : If the file is not found, treat it as if it did not exist in the input
     125// RUN metadata.  Currently, this is only used in this file to select
     126// PPSUB.OUTPUT.KERNELS.
    123127static pmFPAfile *defineCalcFile(pmConfig *config, // Configuration
    124128                                 pmFPAfile *bind,    // File to which to bind, or NULL
     
    133137    pmFPAfile *file = pmFPAfileDefineFromRun(&status, NULL, config, filerule); // File to return
    134138    if (!status) {
    135         psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
    136         return NULL;
     139      bool requireSubkernel = psMetadataLookupBool(NULL, config->arguments, "-require-subkernel");
     140      if (requireSubkernel) {
     141        psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
     142        return NULL;
     143      } else {
     144        psWarning("Failed to load file definition for %s, regenerate", filerule);
     145      }
    137146    }
    138147    file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname);
     
    177186    altconfig->user   = psMemIncrRefCounter(config->user);   // inherit from primary camera
    178187    altconfig->site   = psMemIncrRefCounter(config->site);   // inherit from primary camera
    179     altconfig->system = psMemIncrRefCounter(config->system); // inherit from primary camera
     188
     189    psFree (altconfig->system);
     190    altconfig->system = psMetadataCopy(NULL, config->system); // container for camera-specific recipe values (to be dropped)
    180191
    181192    psFree (altconfig->files);
     
    188199    altconfig->recipes = psMetadataCopy(NULL, config->recipes); // container for camera-specific recipe values (to be dropped)
    189200
    190 # if (0)
    191     // XXX ppStack seems to work without removing PSCAMERA
    192     // remove PSCAMERA entries from *-SKYCELL cameras
    193     // XXX make this optional to force matching cameras if desired?
     201    // remove PSCAMERA entries from *-SKYCELL cameras.  This allows skycell images from
     202    // one camera to match those of another camera.  XXX Make this optional to force
     203    // matching cameras if desired?
    194204    bool mdok = false;
    195205    psMetadata *cameras = psMetadataLookupMetadata(&mdok, altconfig->system, "CAMERAS");
     
    229239      psMetadataRemoveKey (rule, "PSCAMERA"); // allow any camera skycell to match
    230240    }
    231 # endif
     241    psFree (camerasIter);
    232242
    233243    return (altconfig);
     244}
     245
     246bool ppSubCopyPSCamera (pmFPAfile *tgt, pmFPAfile *src) {
     247
     248    bool success;
     249    psMetadata *ruleSrc = psMetadataLookupMetadata(&success, src->format, "RULE"); // one true format for skycells
     250    psAssert (ruleSrc, "missing RULE in src->format");
     251
     252    psString pscameraSrc = psMetadataLookupStr(&success, ruleSrc, "PSCAMERA"); // one true format for skycells
     253    psAssert (pscameraSrc, "missing PSCAMERA in src file");
     254
     255    psMetadata *ruleTgt = psMetadataLookupMetadata(&success, tgt->format, "RULE"); // one true format for skycells
     256    psAssert (ruleTgt, "missing RULE in tgt->format");
     257
     258    psMetadataAddStr (ruleTgt, PS_LIST_TAIL, "PSCAMERA", PS_META_REPLACE, "", pscameraSrc);
     259    return true;
    234260}
    235261
     
    271297    // different camera than the input image.  NOTE: there is no check that these two
    272298    // images match in terms of size, pixel scale, etc. That is up to the user.
     299    // The temporary config structure has PSCAMERA entries removed from the SKYCELL rules
     300    // to allow subtraction between cameras.
    273301   
    274302    pmConfig *refconfig = pmConfigMakeTemp(config);
    275303
    276 # if (0)
    277     // EAM TEST: can we bind the ref to the input to force the right skycell format?
    278     // Reference image
    279     pmFPAfile *ref = defineInputFile(&success, config, input, "PPSUB.REF", "REF", PM_FPA_FILE_IMAGE);
    280     if (!success) {
    281         psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF");
    282         return false;
    283     }
    284 # else
    285304    // Reference image
    286305    pmFPAfile *ref = defineInputFile(&success, refconfig, NULL, "PPSUB.REF", "REF", PM_FPA_FILE_IMAGE);
    287306    if (!success) {
    288         psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF");
    289         return false;
    290     }
    291 # endif
    292 
     307        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF");
     308        return false;
     309    }
     310    // Reference mask
    293311    defineInputFile(&success, refconfig, ref, "PPSUB.REF.MASK", "REF.MASK", PM_FPA_FILE_MASK);
    294312    if (!success) {
     
    296314        return false;
    297315    }
    298 
     316    // Reference variance
    299317    pmFPAfile *refVar = defineInputFile(&success, refconfig, ref, "PPSUB.REF.VARIANCE", "REF.VARIANCE", PM_FPA_FILE_VARIANCE);
    300318    if (!success) {
     
    302320        return false;
    303321    }
     322    // copy ref->format(RULE) PSCAMERA from input->format(RULE)
     323    ppSubCopyPSCamera (ref, input);
    304324    psFree (refconfig);
    305325
     
    308328    pmConfig *srcconfig = pmConfigMakeTemp(config);
    309329
    310     defineInputFile(&success, srcconfig, NULL, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF);
    311     if (!success) {
    312         psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.SOURCES");
    313         return false;
    314     }
     330    // Sources input file (CMF)
     331    pmFPAfile *src = defineInputFile(&success, srcconfig, NULL, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF);
     332    if (!success) {
     333        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.SOURCES");
     334        return false;
     335    }
     336    // XXX do we need to copy the PSCAMERA across to src? 
     337    ppSubCopyPSCamera (src, input);
    315338    psFree (srcconfig);
    316339   
Note: See TracChangeset for help on using the changeset viewer.