IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 24, 2007, 8:01:21 AM (19 years ago)
Author:
eugene
Message:

psphot image loop now performs the mosaicing function first

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotImageLoop.c

    r11310 r12587  
    11# include "psphot.h"
    22
    3 // XXX the errors in the pmFPAfileIOChecks could also be due to a programming or config error
    4 // XXX we need to either handle those errors or handle the error in pmFPAfileIOChecks and exit
    53bool psphotImageLoop (pmConfig *config) {
    64
     
    108    pmReadout *readout;
    119
     10    pmFPAfile *load = psMetadataLookupPtr (&status, config->files, "PSPHOT.LOAD");
     11    if (!status) {
     12        psError(PSPHOT_ERR_PROG, false, "Can't find input data!");
     13        return false;
     14    }
    1215    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
    1316    if (!status) {
     
    2528    }
    2629
    27     while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
     30    // for psphot, we force data to be read at the chip level
     31    while ((chip = pmFPAviewNextChip (view, load->fpa, 1)) != NULL) {
    2832        psLogMsg ("psphot", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    2933        if (! chip->process || ! chip->file_exists) { continue; }
     34
     35        // load just the input image data (image, mask, weight)
     36        pmFPAfileActivate (config->files, false, NULL);
     37        pmFPAfileActivate (config->files, true, "PSPHOT.LOAD");
     38        pmFPAfileActivate (config->files, true, "PSPHOT.MASK");
     39        pmFPAfileActivate (config->files, true, "PSPHOT.WEIGHT");
    3040        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    3141            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
     
    3343            return false;
    3444        }
     45        pmFPAfileActivate (config->files, true, NULL);
    3546       
     47        // mosaic the cells of a chip into a single contiguous chip.
     48        // this probably needs to return a new fpa?
     49        if (!psphotMosaicChip(config, view, "PSPHOT.INPUT", "PSPHOT.LOAD")) {
     50            psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chip.\n");
     51            return false;
     52        }
     53
     54        // try to load the data
     55        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
     56            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
     57            psFree (view);
     58            return false;
     59        }
     60
     61        // there is now only a single chip (multiple readouts?). loop over it and process
     62        // XXX activate / de-activate files? no I/O here?
    3663        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    3764            psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    38             if (! cell->process || ! cell->file_exists) { continue; }
    39             if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    40                 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
    41                 psFree (view);
    42                 return false;
    43             }
     65            // if (! cell->process || ! cell->file_exists) { continue; }
     66            if (! cell->process) { continue; }
    4467           
    4568            // process each of the readouts
    4669            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    47                 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    48                     psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
    49                     psFree (view);
    50                     return false;
    51                 }
    52                
     70                psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    5371                if (! readout->data_exists) { continue; }
    54                
     72
    5573                // run the actual photometry analysis
     74                // XXX calling psphotReadout here will operate on the mosaic'ed chips (for each readout)
    5675                if (!psphotReadout (config, view)) {
    5776                    psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
     
    5978                    return false;
    6079                }
    61 
    62                 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    63                     psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
    64                     psFree (view);
    65                     return false;
    66                 }
    67             }
    68             if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    69                 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
    70                 psFree (view);
    71                 return false;
    7280            }
    7381        }
     82
     83        // save output which is saved at the chip level
    7484        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    7585            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
     
    7888        }
    7989    }
     90    // save output which is saved at the fpa level
    8091    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    8192        psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n");
     
    101112// PSPHOT.PSF     : sample PSF images
    102113
     114// PSPHOT.MASK
     115// PSPHOT.WEIGHT
     116//
Note: See TracChangeset for help on using the changeset viewer.