IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 15, 2008, 5:51:49 PM (18 years ago)
Author:
eugene
Message:

extensive fixes to make these two programs actually work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dvoTools/src/dvoMakeCorrLoop.c

    r11804 r20180  
    55#include "dvoMakeCorr.h"
    66
     7// XXX currently, the input image (the grid map generated by relphot) does not supply enough
     8// header information so the camera and format can be identified.
     9
    710bool dvoMakeCorrLoop (pmConfig *config, dvoMakeCorrOptions *options) {
    811
     
    1013    pmChip *chip;
    1114    pmCell *cell;
    12     pmReadout *readout;
     15    psRegion fullImage = {0, 0, 0, 0};
    1316
    1417    // psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, RECIPE_NAME);
     18
     19    // use the reference image to identify the desired extension from DVOCORR.INPUT
     20    pmFPAfile *refhead = psMetadataLookupPtr(&status, config->files, "DVOCORR.REFHEAD");
     21    if (!status) {
     22        psErrorStackPrint(stderr, "Can't find reference image\n");
     23        exit(EXIT_FAILURE);
     24    }
    1525
    1626    pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "DVOCORR.INPUT");
     
    2939    }
    3040
     41    // XXX for now, do not use the I/O system to read this file; do it manually
     42    if (!pmFPAfileOpen (input, view, config)) {
     43        psError(PS_ERR_UNKNOWN, false, "failed to open grid file\n");
     44        psFree (view);
     45        return false;
     46    }
     47    input->state = PM_FPA_STATE_INACTIVE; 
     48
    3149    // process each chip in the FPA
    32     while ((chip = pmFPAviewNextChip(view, input->fpa, 1)) != NULL) {
     50    while ((chip = pmFPAviewNextChip(view, refhead->fpa, 1)) != NULL) {
    3351        psLogMsg ("dvoMakeCorrLoop", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    3452        if (!chip->process || !chip->file_exists) continue;
     
    3957        }
    4058
     59        // load the input data for this extension
     60        pmChip *inChip = pmFPAviewThisChip (view, input->fpa);
     61        char *inName = psMetadataLookupStr (&status, inChip->concepts, "CHIP.NAME");
     62        psFitsMoveExtName (input->fits, inName);
     63        psImage *inImage = psFitsReadImage (input->fits, fullImage, 0);
     64        assert (inImage);
     65
    4166        // process each cell in the Chip
    42         while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
     67        while ((cell = pmFPAviewNextCell(view, refhead->fpa, 1)) != NULL) {
    4368            psLogMsg ("dvoMakeCorrLoop", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    4469            if (!cell->process || !cell->file_exists) continue;
     
    4974            }
    5075
    51             // process each of the readouts
    52             while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    53                 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    54                     psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d, cell %d, readout %d in dvoMakeCorr\n", view->chip, view->cell, view->readout);
    55                     psFree (view);
    56                     return false;
    57                 }
    58                 if (!readout->data_exists) continue;
     76            // XXX put the function here which unbins the input image
     77            dvoMakeCorrUnbin (config, view, "DVOCORR.OUTPUT", inImage, inChip, "DVOCORR.REFHEAD");
    5978
    60                 // XXX put the function here which unbins the input image
    61                 dvoMakeCorrUnbin (config, view, "DVOCORR.OUTPUT", "DVOCORR.INPUT", "DVOCORR.REFHEAD");
    62 
    63                 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    64                     psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d, cell %d, readout %d in dvoMakeCorr\n", view->chip, view->cell, view->readout);
    65                     psFree (view);
    66                     return false;
    67                 }
    68             }
    6979            if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    7080                psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d, cell %d in dvoMakeCorr\n", view->chip, view->cell);
     
    7383            }
    7484        }
     85        psFree (inImage);
     86
    7587        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    7688            psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in dvoMakeCorr\n", view->chip);
     
    8597    }
    8698
     99    pmFPAfileClose (input, view);
    87100    psFree (view);
    88101
Note: See TracChangeset for help on using the changeset viewer.