IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 26, 2009, 1:59:32 PM (17 years ago)
Author:
beaumont
Message:

merged with trunk

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/ppSub

  • branches/cnb_branches/cnb_branch_20090301/ppSub/src

    • Property svn:ignore
      •  

        old new  
        1010stamp-h1
        1111ppSubKernel
         12ppSubErrorCodes.h
         13ppSubErrorCodes.c
         14ppSubVersionDefinitions.h
  • branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubCamera.c

    r23594 r24244  
    134134
    135135
    136 bool ppSubCamera(pmConfig *config)
     136bool ppSubCamera(ppSubData *data)
    137137{
     138    psAssert(data, "Require processing data");
     139    pmConfig *config = data->config;
    138140    psAssert(config, "Require configuration");
    139141
     
    147149    pmFPAfile *inVar = defineInputFile(config, input, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE",
    148150                                       PM_FPA_FILE_VARIANCE);
    149     defineInputFile(config, input, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES", PM_FPA_FILE_CMF);
     151    defineInputFile(config, NULL, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES", PM_FPA_FILE_CMF);
    150152
    151153    // Reference image
     
    158160    pmFPAfile *refVar = defineInputFile(config, ref, "PPSUB.REF.VARIANCE", "REF.VARIANCE",
    159161                                        PM_FPA_FILE_VARIANCE);
    160     defineInputFile(config, ref, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF);
    161 
    162 
    163     // Output image
    164     pmFPAfile *output = defineOutputFile(config, input, true, "PPSUB.OUTPUT", PM_FPA_FILE_IMAGE);
    165     pmFPAfile *outMask = defineOutputFile(config, output, false, "PPSUB.OUTPUT.MASK", PM_FPA_FILE_MASK);
    166     if (!output || !outMask) {
    167         psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
    168         return false;
    169     }
    170     output->save = true;
    171     outMask->save = true;
    172     pmFPAfile *outVar = NULL;
    173     if (inVar && refVar) {
    174         outVar = defineOutputFile(config, output, false, "PPSUB.OUTPUT.VARIANCE", PM_FPA_FILE_VARIANCE);
    175         if (!outVar) {
    176             psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
    177             return false;
    178         }
    179         outVar->save = true;
    180     }
     162    defineInputFile(config, NULL, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF);
    181163
    182164
     
    216198
    217199
     200    // Now that the camera has been determined, we can read the recipe
     201    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
     202    if (!recipe) {
     203        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSUB_RECIPE);
     204        return false;
     205    }
     206    if (psMetadataLookupBool(NULL, config->arguments, "-photometry")) {
     207        psMetadataAddBool(recipe, PS_LIST_TAIL, "PHOTOMETRY", PS_META_REPLACE,
     208                          "Perform photometry?", true);
     209    }
     210    if (psMetadataLookupBool(NULL, config->arguments, "-inverse")) {
     211        psMetadataAddBool(recipe, PS_LIST_TAIL, "INVERSE", PS_META_REPLACE,
     212                          "Generate inverse subtractions?", true);
     213    }
     214
     215    data->inverse = psMetadataLookupBool(NULL, recipe, "INVERSE");
     216    data->photometry = psMetadataLookupBool(NULL, recipe, "PHOTOMETRY");
     217
     218
     219    // Output image
     220    pmFPAfile *output = defineOutputFile(config, inConvImage, true, "PPSUB.OUTPUT", PM_FPA_FILE_IMAGE);
     221    pmFPAfile *outMask = defineOutputFile(config, output, false, "PPSUB.OUTPUT.MASK", PM_FPA_FILE_MASK);
     222    if (!output || !outMask) {
     223        psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
     224        return false;
     225    }
     226    output->save = true;
     227    outMask->save = true;
     228    if (inVar && refVar) {
     229        pmFPAfile *outVar = defineOutputFile(config, output, false, "PPSUB.OUTPUT.VARIANCE",
     230                                             PM_FPA_FILE_VARIANCE);
     231        if (!outVar) {
     232            psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
     233            return false;
     234        }
     235        outVar->save = true;
     236    }
     237
     238    pmFPAfile *inverse = NULL;          // Inverse output image
     239    if (data->inverse) {
     240        // Inverse output image
     241        inverse = defineOutputFile(config, output, true, "PPSUB.INVERSE", PM_FPA_FILE_IMAGE);
     242        pmFPAfile *invMask = defineOutputFile(config, inverse, false, "PPSUB.INVERSE.MASK",
     243                                              PM_FPA_FILE_MASK);
     244        if (!inverse || !invMask) {
     245            psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
     246            return false;
     247        }
     248        inverse->save = true;
     249        invMask->save = true;
     250        if (inVar && refVar) {
     251            pmFPAfile *invVar = defineOutputFile(config, inverse, false, "PPSUB.INVERSE.VARIANCE",
     252                                                 PM_FPA_FILE_VARIANCE);
     253            if (!invVar) {
     254                psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
     255                return false;
     256            }
     257            invVar->save = true;
     258        }
     259    }
     260
     261
    218262    // Output JPEGs
    219263    pmFPAfile *jpeg1 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.JPEG1");
     
    245289    }
    246290
    247     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
    248     if (!recipe) {
    249         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSUB_RECIPE);
    250         return false;
    251     }
    252 
    253291    // psPhot input
    254     if (psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) {
     292    if (data->photometry) {
    255293        psphotModelClassInit();        // load implementation-specific models
    256 
    257         // Internal-ish file for getting the PSF from the minuend
    258         pmFPAfile *psf = pmFPAfileDefineOutputFromFile(config, output, "PSPHOT.PSF.LOAD");
    259         if (!psf) {
    260             psError(PS_ERR_IO, false, "Failed to build FPA from PSPHOT.PSF.LOAD");
    261             return false;
    262         }
    263         if (psf->type != PM_FPA_FILE_PSF) {
    264             psError(PS_ERR_IO, true, "PSPHOT.PSF.LOAD is not of type PSF");
    265             return false;
    266         }
    267         pmFPAfileActivate(config->files, false, "PSPHOT.PSF.LOAD");
    268294
    269295        pmFPAfile *psphot = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT");
     
    276302            return false;
    277303        }
     304        pmFPAfileActivate(config->files, false, "PSPHOT.INPUT");
     305
     306        // Internal-ish file for getting the PSF from the minuend
     307        pmFPAfile *psf = pmFPAfileDefineOutputFromFile(config, psphot, "PSPHOT.PSF.LOAD");
     308        if (!psf) {
     309            psError(PS_ERR_IO, false, "Failed to build FPA from PSPHOT.PSF.LOAD");
     310            return false;
     311        }
     312        if (psf->type != PM_FPA_FILE_PSF) {
     313            psError(PS_ERR_IO, true, "PSPHOT.PSF.LOAD is not of type PSF");
     314            return false;
     315        }
     316        pmFPAfileActivate(config->files, false, "PSPHOT.PSF.LOAD");
    278317
    279318        if (!psphotDefineFiles(config, psphot)) {
     
    281320            return false;
    282321        }
     322
     323        // Deactivate psphot output sources --- we want to define output source files of our own
     324        pmFPAfile *psphotOutput = pmFPAfileSelectSingle(config->files, "PSPHOT.OUTPUT", 0);
     325        psphotOutput->save = false;
     326
     327        pmFPAfile *outSources = defineOutputFile(config, output, false, "PPSUB.OUTPUT.SOURCES",
     328                                                 PM_FPA_FILE_CMF);
     329        if (!outSources) {
     330            psError(PS_ERR_UNKNOWN, false, "Unable to set up output source file.");
     331            return false;
     332        }
     333        outSources->save = true;
     334
     335        if (data->inverse) {
     336            pmFPAfile *invSources = defineOutputFile(config, inverse, false, "PPSUB.INVERSE.SOURCES",
     337                                                     PM_FPA_FILE_CMF);
     338            if (!invSources) {
     339                psError(PS_ERR_UNKNOWN, false, "Unable to set up inverse source file.");
     340                return false;
     341            }
     342            invSources->save = true;
     343        }
    283344    }
    284345
    285346    return true;
    286347}
     348
     349
Note: See TracChangeset for help on using the changeset viewer.