IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 14, 2011, 4:41:16 PM (15 years ago)
Author:
bills
Message:

Post the results to the data store. Make programs work with outputs in nebulous

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psvideophot/src/psvideophotParseCamera.c

    r31290 r32556  
    77psvideophotOptions *psvideophotParseCamera(pmConfig *config)
    88{
    9     bool status = false;
    10 
    119    if (!psvideophotDefineFile(config, NULL, "PSVIDEOPHOT.INPUT", "INPUT", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_NONE)) {
    1210        psError(PS_ERR_IO, false, "Can't find an input image source");
     
    1614    psAssert(input, "We just put it there!");
    1715
     16#ifdef notyet
    1817    // add recipe options supplied on command line
     18    bool status = false;
    1919    psMetadata *recipe  = psMetadataLookupPtr(&status, config->recipes, RECIPE_NAME);
     20#endif
    2021
    2122    // parse the options from the metadata format to the psvideophotOptions structure
    2223    psvideophotOptions *options = psvideophotOptionsParse(config);
    2324
    24     // the following are defined from the argument list, if given,
    25     // otherwise they revert to the config information
    26     // not all input or output images are used in a given recipe
    27    
    28     int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS");
    29     if (nThreads > 0) {
    30         int nScanRows = psMetadataLookupS32(&status, recipe, "SCAN.ROWS");
    31         pmDetrendSetThreadTasks(nScanRows);
    32     }
    33 
    34     // the following files are output targets
    35     pmFPAfile *outImage = pmFPAfileDefineOutput(config, input->fpa, "PSVIDEOPHOT.OUTPUT");
    36     if (!outImage) {
    37         psError(PS_ERR_IO, false, _("Unable to generate output file from PSVIDEOPHOT.OUTPUT"));
    38         psFree(options);
    39         return NULL;
    40     }
    41     if (outImage->type != PM_FPA_FILE_OBJ) {
    42         psError(PS_ERR_IO, true, "PSVIDEOPHOT.OUTPUT is not of type OBJ");
    43         psFree(options);
    44         return NULL;
    45     }
    46    
    47     // XXX should these be bound explicitly to the outImage->fpa rather than the input->fpa?
    48     pmFPAfile *chipImage = pmFPAfileDefineChipMosaic(config, input->fpa, "PSVIDEOPHOT.CHIP");
    49     if (!chipImage) {
    50         psError(PS_ERR_IO, false, _("Unable to generate new file from PSVIDEOPHOT.CHIP"));
    51         psFree(options);
    52         return NULL;
    53     }
    54     if (chipImage->type != PM_FPA_FILE_OBJ) {
    55         psError(PS_ERR_IO, true, "PSVIDEOPHOT.CHIP is not of type OBJ");
    56         psFree(options);
    57         return NULL;
    58     }
    59    
    60 
    61     // chipImage    -> psphotInput  (pmFPAfileDefineFromFile)       : fpa is constructed
    62     // psphotInput  -> psphotOutput (pmFPAfileDefineOutputFromFile) : fpa is equated
    63     // psphotOutput -> psastroInput (pmFPAfileDefineInput)          : fpa is ref-copied
    64     // psastroInput -> psastroModel (pmFPAfileDefineFromArgs        : fpa is ref-copied
    65     // psastroInput -> psastroModel (pmFPAfileDefineFromConf        : fpa is constructed
    66     // psastroInput -> psastroModel (pmFPAfileDefineFromDetDB       : fpa is constructed (pmDetrendSelect uses input concepts )
    67 
    68     // For photometry, we operate on the chip-mosaicked image
    69     // we create a copy of the mosaicked image for psphot so we can write out a clean image
    70    
    71 
    72         // this file is just used as a carrier; output files (eg, PSPHOT.RESID) are defined by
    73         // psphotDefineFiles
    74         pmFPAfile *psphotInput = pmFPAfileDefineFromFile (config, chipImage, 1, 1, "PSPHOT.INPUT");
    75         PS_ASSERT (psphotInput, false);
    76 
    77         // specify the number of psphot input images
    78         psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
    79 
    80         // define associated psphot input/output files
    81         if (!psphotDefineFiles (config, psphotInput)) {
    82             psError(PSPHOT_ERR_CONFIG, false,
    83                     "Trouble defining the additional input/output files for psphot");
    84             return false;
    85         }
    86    
    87 
    88     // For photometry, we operate on the chip-mosaicked image
    89    
    90 
    91     // save any of these files?
    92     outImage->save   = options->BaseFITS;
    93    
    94 
    95     chipImage->save  = options->ChipFITS;
    96    
    97 
    98    
    99     // outImage is used as a carrier: input to chipImage -> require the data to remain at the CHIP level
    100     outImage->freeLevel = PS_MIN(outImage->freeLevel, PM_FPA_LEVEL_CHIP);
    101     outImage->dataLevel = outImage->freeLevel;
    102     outImage->fileLevel = PS_MIN(outImage->fileLevel, outImage->dataLevel);
    103 
    104     // outMask and outVariance must be freed at the same level as outImage (all freed by pmFPAFreeData)
    105    
    106 
    107     // the input data is the same as the outImage data : force the free levels to match
    108     input->freeLevel = PS_MIN(outImage->freeLevel, input->freeLevel);
    109 
    110     // define the binned target files (which may just be carriers for some camera configurations)
    111    
    112     // Chip selection: turn on only the chips specified (pass status to suppress missing-key log msg)
    113     char *chipLine = psMetadataLookupStr(&status, config->arguments, "CHIP_SELECTIONS");
    114     psArray *chips = psStringSplitArray(chipLine, ",", false);
    115     if (chips->n > 0) {
    116         pmFPASelectChip (input->fpa, -1, true); // deselect all chips
    117         for (int i = 0; i < chips->n; i++) {
    118             int chipNum = atoi(chips->data[i]);
    119             if (! pmFPASelectChip(input->fpa, chipNum, false)) {
    120                 psError(PS_ERR_IO, false, "Chip number %d doesn't exist in camera.\n", chipNum);
    121                 psFree(options);
    122                 return false;
    123             }
    124         }
    125     }
    126     psFree (chips);
    127 
    128     if (psMetadataLookupBool(NULL, config->arguments, "INPUT_IS_FRINGE")) {
    129         // It's a fringe file, so change the file type
    130         input->type = PM_FPA_FILE_FRINGE;
    131         outImage->type = PM_FPA_FILE_FRINGE;
    132     }
    133     if (psMetadataLookupBool(NULL, config->arguments, "INPUT_IS_DARK")) {
    134         // It's a dark file, so change the file type
    135         input->type = PM_FPA_FILE_DARK;
    136         outImage->type = PM_FPA_FILE_DARK;
    137         // Turn off compression --- there are just too many nasties that can happen
    138         psFree(outImage->compression);
    139         outImage->compression = NULL;
    140         psFree(outImage->options);
    141         outImage->options = NULL;
    142     }
    143 
    144     // Turn off mask and variance output if we're not doing anything interesting
    145    
    146     if (psTraceGetLevel("psvideophot.config") > 0) {
    147         // Get a look inside all the files.
    148         psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL);
    149         psMetadataItem *item;               // Item from iteration
    150         fprintf(stderr, "Files:\n");
    151         while ((item = psMetadataGetAndIncrement(filesIter))) {
    152             pmFPAfile *file = item->data.V; // File of interest
    153             fprintf(stderr, "%s: %p %p %p (%p) %p\n", file->name,
    154                     file->src, file->fpa,
    155                     file->camera, file->fpa->camera, file->format);
    156         }
    157         psFree(filesIter);
    158     }
    159 
    160     // Change the input dark type between the old (IMAGE) and new (multi-DARK).
    161     // Hopefully this is a temporary change until we all move over to using the new dark types
    162     bool mdok;                          // Status of MD lookup
    163     if (options->doDark && psMetadataLookupBool(&mdok, recipe, "OLDDARK")) {
    164         pmFPAfile *dark = psMetadataLookupPtr(NULL, config->files, "PSVIDEOPHOT.DARK");
    165         assert(dark);
    166         dark->type = PM_FPA_FILE_IMAGE;
    167     }
    168 
    16925    return (options);
    17026}
Note: See TracChangeset for help on using the changeset viewer.