IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:50:52 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/simtest_nebulous_branches
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/simtest_nebulous_branches

  • branches/simtest_nebulous_branches/ppSub/src

    • Property svn:ignore
      •  

        old new  
        1313ppSubErrorCodes.c
        1414ppSubVersionDefinitions.h
         15ppSubConvolve
  • branches/simtest_nebulous_branches/ppSub/src/ppSubCamera.c

    r24261 r27840  
    2323
    2424// Define an input file
    25 static pmFPAfile *defineInputFile(pmConfig *config,// Configuration
     25static pmFPAfile *defineInputFile(bool *success,
     26                                  pmConfig *config,// Configuration
    2627                                  pmFPAfile *bind,    // File to which to bind, or NULL
    2728                                  char *filerule,     // Name of file rule
     
    3233    bool status;
    3334
    34     // look for the file on the RUN metadata
    35     pmFPAfile *file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return
     35    *success = false;
     36
     37    pmFPAfile *file = NULL;
     38
     39    // look for the file on the argument list
     40    if (bind) {
     41        file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname);
     42    } else {
     43        file = pmFPAfileDefineFromArgs(&status, config, filerule, argname);
     44    }
     45
    3646    if (!status) {
    37         psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule);
    38         return NULL;
     47        psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
     48        return false;
    3949    }
    4050    if (!file) {
    41         // look for the file on the argument list
    42         if (bind) {
    43             file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname);
    44         } else {
    45             file = pmFPAfileDefineFromArgs(&status, config, filerule, argname);
    46         }
     51        // look for the file on the RUN metadata
     52        file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return
    4753        if (!status) {
    48             psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule);
    49             return false;
     54            psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
     55            return NULL;
    5056        }
    5157    }
    5258
    5359    if (!file) {
     60        // no file defined
     61        *success = true;
    5462        return NULL;
    5563    }
    5664
    5765    if (file->type != fileType) {
    58         psError(PS_ERR_UNKNOWN, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
    59         return NULL;
    60     }
    61 
     66        psError(PPSUB_ERR_CONFIG, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
     67        return NULL;
     68    }
     69
     70    *success = true;
    6271    return file;
    6372}
     
    7584        pmFPAfileDefineOutput(config, template->fpa, filerule);
    7685    if (!file) {
    77         psError(PS_ERR_IO, false, _("Unable to generate output file from %s"), filerule);
     86        psError(psErrorCodeLast(), false, _("Unable to generate output file from %s"), filerule);
    7887        return NULL;
    7988    }
    8089    if (file->type != fileType) {
    81         psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
     90        psError(PPSUB_ERR_CONFIG, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
    8291        return NULL;
    8392    }
     
    92101                                 pmFPAfile *bind,    // File to which to bind, or NULL
    93102                                 char *filerule,     // Name of file rule
     103                                 const char *argname,   // Argument name for file
    94104                                 pmFPAfileType fileType // Type of file
    95105    )
     
    98108
    99109    // look for the file on the RUN metadata
    100     pmFPAfile *file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return
     110    pmFPAfile *file = pmFPAfileDefineFromRun(&status, NULL, config, filerule); // File to return
    101111    if (!status) {
    102         psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule);
     112        psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
     113        return NULL;
     114    }
     115    file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname);
     116    if (!status) {
     117        psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
    103118        return NULL;
    104119    }
     
    112127        file = pmFPAfileDefineOutput(config, bind ? bind->fpa : NULL, filerule);
    113128        if (!status) {
    114             psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule);
     129            psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
    115130            return false;
    116131        }
     
    126141
    127142    if (file->type != fileType) {
    128         psError(PS_ERR_UNKNOWN, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
     143        psError(PPSUB_ERR_CONFIG, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
    129144        return NULL;
    130145    }
     
    136151bool ppSubCamera(ppSubData *data)
    137152{
     153    bool success = true;
     154
    138155    psAssert(data, "Require processing data");
    139156    pmConfig *config = data->config;
     
    141158
    142159    // Input image
    143     pmFPAfile *input = defineInputFile(config, NULL, "PPSUB.INPUT", "INPUT", PM_FPA_FILE_IMAGE);
    144     if (!input) {
    145         psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.INPUT");
    146         return false;
    147     }
    148     defineInputFile(config, input, "PPSUB.INPUT.MASK", "INPUT.MASK", PM_FPA_FILE_MASK);
    149     pmFPAfile *inVar = defineInputFile(config, input, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE",
    150                                        PM_FPA_FILE_VARIANCE);
    151     defineInputFile(config, NULL, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES", PM_FPA_FILE_CMF);
     160    pmFPAfile *input = defineInputFile(&success, config, NULL, "PPSUB.INPUT", "INPUT", PM_FPA_FILE_IMAGE);
     161    if (!success) {
     162        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT");
     163        return false;
     164    }
     165
     166    defineInputFile(&success, config, input, "PPSUB.INPUT.MASK", "INPUT.MASK", PM_FPA_FILE_MASK);
     167    if (!success) {
     168        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT.MASK");
     169        return false;
     170    }
     171
     172    pmFPAfile *inVar = defineInputFile(&success, config, input, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE", PM_FPA_FILE_VARIANCE);
     173    if (!success) {
     174        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT.VARIANCE");
     175        return false;
     176    }
     177
     178    defineInputFile(&success, config, NULL, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES", PM_FPA_FILE_CMF);
     179    if (!success) {
     180        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT.SOURCES");
     181        return false;
     182    }
    152183
    153184    // Reference image
    154     pmFPAfile *ref = defineInputFile(config, NULL, "PPSUB.REF", "REF", PM_FPA_FILE_IMAGE);
    155     if (!ref) {
    156         psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.REF");
    157         return false;
    158     }
    159     defineInputFile(config, ref, "PPSUB.REF.MASK", "REF.MASK", PM_FPA_FILE_MASK);
    160     pmFPAfile *refVar = defineInputFile(config, ref, "PPSUB.REF.VARIANCE", "REF.VARIANCE",
    161                                         PM_FPA_FILE_VARIANCE);
    162     defineInputFile(config, NULL, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF);
    163 
     185    pmFPAfile *ref = defineInputFile(&success, config, NULL, "PPSUB.REF", "REF", PM_FPA_FILE_IMAGE);
     186    if (!success) {
     187        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF");
     188        return false;
     189    }
     190
     191    defineInputFile(&success, config, ref, "PPSUB.REF.MASK", "REF.MASK", PM_FPA_FILE_MASK);
     192    if (!success) {
     193        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.MASK");
     194        return false;
     195    }
     196
     197    pmFPAfile *refVar = defineInputFile(&success, config, ref, "PPSUB.REF.VARIANCE", "REF.VARIANCE", PM_FPA_FILE_VARIANCE);
     198    if (!success) {
     199        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.VARIANCE");
     200        return false;
     201    }
     202
     203    defineInputFile(&success, config, NULL, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF);
     204    if (!success) {
     205        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.SOURCES");
     206        return false;
     207    }
    164208
    165209    // Now that the camera has been determined, we can read the recipe
    166210    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
    167211    if (!recipe) {
    168         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSUB_RECIPE);
     212        psError(PPSUB_ERR_CONFIG, false, "Unable to find recipe %s", PPSUB_RECIPE);
    169213        return false;
    170214    }
     
    180224    data->inverse = psMetadataLookupBool(NULL, recipe, "INVERSE");
    181225    data->photometry = psMetadataLookupBool(NULL, recipe, "PHOTOMETRY");
    182 
    183     bool mdok;                          // Status of MD lookup
    184     bool saveConv = psMetadataLookupBool(&mdok, recipe, "SAVE.CONVOLVED"); // Save convolved images?
    185226
    186227    // Convolved input image
     
    189230                                             PM_FPA_FILE_MASK);
    190231    if (!inConvImage || !inConvMask) {
    191         psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
    192         return false;
    193     }
    194     if (saveConv) {
    195         inConvImage->save = true;
    196         inConvMask->save = true;
    197     }
     232        psError(psErrorCodeLast(), false, "Unable to define output files");
     233        return false;
     234    }
     235    inConvImage->save = data->saveInConv;
     236    inConvMask->save = data->saveInConv;
    198237    if (inVar) {
    199238        pmFPAfile *inConvVar = defineOutputFile(config, inConvImage, false, "PPSUB.INPUT.CONV.VARIANCE",
    200239                                                PM_FPA_FILE_VARIANCE);
    201240        if (!inConvVar) {
    202             psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
    203             return false;
    204         }
    205         if (saveConv) {
    206             inConvVar->save = true;
    207         }
     241            psError(psErrorCodeLast(), false, "Unable to define output files");
     242            return false;
     243        }
     244        inConvVar->save = data->saveInConv;
    208245    }
    209246
     
    213250                                              PM_FPA_FILE_MASK);
    214251    if (!refConvImage || !refConvMask) {
    215         psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
    216         return false;
    217     }
    218     if (saveConv) {
    219         refConvImage->save = true;
    220         refConvMask->save = true;
    221     }
     252        psError(psErrorCodeLast(), false, "Unable to define output files");
     253        return false;
     254    }
     255    refConvImage->save = data->saveRefConv;
     256    refConvMask->save = data->saveRefConv;
    222257    if (refVar) {
    223258        pmFPAfile *refConvVar = defineOutputFile(config, refConvImage, false, "PPSUB.REF.CONV.VARIANCE",
    224259                                                 PM_FPA_FILE_VARIANCE);
    225260        if (!refConvVar) {
    226             psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
    227             return false;
    228         }
    229         if (saveConv) {
    230             refConvVar->save = true;
    231         }
     261            psError(psErrorCodeLast(), false, "Unable to define output files");
     262            return false;
     263        }
     264        refConvVar->save = data->saveRefConv;
    232265    }
    233266
     
    236269    pmFPAfile *outMask = defineOutputFile(config, output, false, "PPSUB.OUTPUT.MASK", PM_FPA_FILE_MASK);
    237270    if (!output || !outMask) {
    238         psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
     271        psError(psErrorCodeLast(), false, "Unable to define output files");
    239272        return false;
    240273    }
     
    245278                                             PM_FPA_FILE_VARIANCE);
    246279        if (!outVar) {
    247             psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
     280            psError(psErrorCodeLast(), false, "Unable to define output files");
    248281            return false;
    249282        }
     
    258291                                              PM_FPA_FILE_MASK);
    259292        if (!inverse || !invMask) {
    260             psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
     293            psError(psErrorCodeLast(), false, "Unable to define output files");
    261294            return false;
    262295        }
     
    267300                                                 PM_FPA_FILE_VARIANCE);
    268301            if (!invVar) {
    269                 psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
     302                psError(psErrorCodeLast(), false, "Unable to define output files");
    270303                return false;
    271304            }
     
    278311    pmFPAfile *jpeg1 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.JPEG1");
    279312    if (!jpeg1) {
    280         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG1"));
     313        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG1"));
    281314        return false;
    282315    }
    283316    if (jpeg1->type != PM_FPA_FILE_JPEG) {
    284         psError(PS_ERR_IO, true, "PPSUB.OUTPUT.JPEG1 is not of type JPEG");
     317        psError(psErrorCodeLast(), true, "PPSUB.OUTPUT.JPEG1 is not of type JPEG");
    285318        return false;
    286319    }
     
    288321    pmFPAfile *jpeg2 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.JPEG2");
    289322    if (!jpeg2) {
    290         psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG2"));
     323        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG2"));
    291324        return false;
    292325    }
    293326    if (jpeg2->type != PM_FPA_FILE_JPEG) {
    294         psError(PS_ERR_IO, true, "PPSUB.OUTPUT.JPEG2 is not of type JPEG");
     327        psError(psErrorCodeLast(), true, "PPSUB.OUTPUT.JPEG2 is not of type JPEG");
    295328        return false;
    296329    }
    297330    jpeg2->save = true;
    298331
     332    // Output residual JPEG
     333    pmFPAfile *jpeg3 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.RESID.JPEG");
     334    if (!jpeg3) {
     335        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSUB.OUTPUT.RESID.JPEG"));
     336        return false;
     337    }
     338    if (jpeg3->type != PM_FPA_FILE_JPEG) {
     339        psError(psErrorCodeLast(), true, "PPSUB.OUTPUT.RESID.JPEG is not of type JPEG");
     340        return false;
     341    }
     342    jpeg3->save = true;
     343
    299344    // Output subtraction kernel
    300     pmFPAfile *kernel = defineCalcFile(config, output, "PPSUB.OUTPUT.KERNELS", PM_FPA_FILE_SUBKERNEL);
     345    pmFPAfile *kernel = defineCalcFile(config, output, "PPSUB.OUTPUT.KERNELS", "KERNEL",
     346                                       PM_FPA_FILE_SUBKERNEL);
    301347    if (!kernel) {
    302348        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to define file PPSUB.OUTPUT.KERNELS");
     
    305351
    306352    // psPhot input
    307     if (data->photometry) {
     353    if (data->photometry || 1) {
    308354        psphotModelClassInit();        // load implementation-specific models
    309355
    310356        pmFPAfile *psphot = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT");
    311357        if (!psphot) {
    312             psError(PS_ERR_IO, false, "Failed to build FPA from PSPHOT.INPUT");
     358            psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.INPUT");
    313359            return false;
    314360        }
    315361        if (psphot->type != PM_FPA_FILE_IMAGE) {
    316             psError(PS_ERR_IO, true, "PSPHOT.INPUT is not of type IMAGE");
    317             return false;
    318         }
     362            psError(psErrorCodeLast(), true, "PSPHOT.INPUT is not of type IMAGE");
     363            return false;
     364        }
     365        // specify the number of psphot input images
     366        psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
    319367        pmFPAfileActivate(config->files, false, "PSPHOT.INPUT");
    320368
    321         // Internal-ish file for getting the PSF from the minuend
    322         pmFPAfile *psf = pmFPAfileDefineOutputFromFile(config, psphot, "PSPHOT.PSF.LOAD");
     369        // Internal file for getting the PSF from the minuend
     370        pmFPAfile *psf = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.PSF.LOAD");
    323371        if (!psf) {
    324             psError(PS_ERR_IO, false, "Failed to build FPA from PSPHOT.PSF.LOAD");
     372            psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.PSF.LOAD");
    325373            return false;
    326374        }
    327375        if (psf->type != PM_FPA_FILE_PSF) {
    328             psError(PS_ERR_IO, true, "PSPHOT.PSF.LOAD is not of type PSF");
     376            psError(psErrorCodeLast(), true, "PSPHOT.PSF.LOAD is not of type PSF");
    329377            return false;
    330378        }
     
    332380
    333381        if (!psphotDefineFiles(config, psphot)) {
    334             psError(PS_ERR_UNKNOWN, false, "Unable to set up psphot files.");
     382            psError(psErrorCodeLast(), false, "Unable to set up psphot files.");
    335383            return false;
    336384        }
     
    343391                                                 PM_FPA_FILE_CMF);
    344392        if (!outSources) {
    345             psError(PS_ERR_UNKNOWN, false, "Unable to set up output source file.");
     393            psError(psErrorCodeLast(), false, "Unable to set up output source file.");
    346394            return false;
    347395        }
     
    352400                                                     PM_FPA_FILE_CMF);
    353401            if (!invSources) {
    354                 psError(PS_ERR_UNKNOWN, false, "Unable to set up inverse source file.");
     402                psError(psErrorCodeLast(), false, "Unable to set up inverse source file.");
    355403                return false;
    356404            }
Note: See TracChangeset for help on using the changeset viewer.