IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7726


Ignore:
Timestamp:
Jun 28, 2006, 9:21:35 AM (20 years ago)
Author:
magnier
Message:

fixes for correct PHU/HDU output handling

Location:
trunk/psModules/src/camera
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAfileFitsIO.c

    r7712 r7726  
    7373
    7474// given an already-opened fits file, write the components corresponding
    75 // to the specified view
     75// to the specified view. when the file was opened, pmFPA/Chip/CellWrite was
     76// called on it with blank=true to write the (possible) blank PHU
     77// do NOT call the functions below with blank=true or they will write
     78// out data in an inconsistent fashion
     79// the calls below should recurse down the element to write out all components.
    7680bool pmFPAviewWriteFitsImage (const pmFPAview *view, pmFPAfile *file)
    7781{
     
    8488    // pmFPAWrite takes care of all PHUs as needed
    8589    if (view->chip == -1) {
    86         pmFPAWrite(fpa, fits, NULL, true, true);
     90        pmFPAWrite(fpa, fits, NULL, false, true);
    8791        return true;
    8892    }
     
    9498    pmChip *chip = fpa->chips->data[view->chip];
    9599
    96 
     100    if (view->cell == -1) {
     101        pmChipWrite (chip, fits, NULL, false, true);
     102        return true;
     103    }
     104
     105    if (view->cell >= chip->cells->n) {
     106        psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %d", view->cell, chip->cells->n);
     107        return false;
     108    }
     109    pmCell *cell = chip->cells->data[view->cell];
     110
     111    if (view->readout == -1) {
     112        return pmCellWrite (cell, fits, NULL, false);
     113    }
     114    psError(PS_ERR_UNKNOWN, true, "Returning false");
     115    return false;
     116
     117    // XXX disable readout write for now
    97118    #if 0
    98     // XXX This no longer required since we write the PHU at open.
    99 
    100     // do we need to write out a PHU for this entry?
    101     if (file->phu == NULL) {
     119
     120    if (view->readout >= cell->readouts->n) {
     121        psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouts->n == %d",
     122                view->readout, cell->readouts->n);
     123        return false;
     124    }
     125    pmReadout *readout = cell->readouts->data[view->readout];
     126
     127    if (view->nRows == 0) {
     128        pmReadoutWrite (readout, fits, NULL, NULL);
     129    } else {
     130        pmReadoutWriteSegment (readout, fits, view->nRows, view->iRows, NULL, NULL);
     131    }
     132    return true;
     133    #endif
     134}
     135
     136// this old code was used to write the blank by hand.
     137// pmFPAWrite now takes care of this choice.
     138# if 0
     139// do we need to write out a PHU for this entry?
     140if (file->phu == NULL)
     141    {
    102142        pmHDU *hdu = pmFPAviewThisHDU (view, file->fpa);
    103143        pmHDU *phu = pmFPAviewThisPHU (view, file->fpa);
     
    119159        }
    120160    }
    121     #endif
    122 
    123     if (view->cell == -1) {
    124         pmChipWrite (chip, fits, NULL, true, true);
    125         return true;
    126     }
    127 
    128     if (view->cell >= chip->cells->n) {
    129         psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %d", view->cell, chip->cells->n);
    130         return false;
    131     }
    132     pmCell *cell = chip->cells->data[view->cell];
    133 
    134     if (view->readout == -1) {
    135         return pmCellWrite (cell, fits, NULL, true);
    136     }
    137     psError(PS_ERR_UNKNOWN, true, "Returning false");
    138     return false;
    139 
    140     // XXX disable readout write for now
    141     #if 0
    142 
    143     if (view->readout >= cell->readouts->n) {
    144         psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouts->n == %d",
    145                 view->readout, cell->readouts->n);
    146         return false;
    147     }
    148     pmReadout *readout = cell->readouts->data[view->readout];
    149 
    150     if (view->nRows == 0) {
    151         pmReadoutWrite (readout, fits, NULL, NULL);
    152     } else {
    153         pmReadoutWriteSegment (readout, fits, view->nRows, view->iRows, NULL, NULL);
    154     }
    155     return true;
    156     #endif
    157 }
     161# endif
    158162
    159163// given an already-opened fits file, read the components corresponding
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r7711 r7726  
    9898        // open the FITS types:
    9999    case PM_FPA_FILE_IMAGE:
    100     case PM_FPA_FILE_CMF:
    101100        psTrace ("pmFPAfile", 5, "opening %s (type: %d)\n", file->filename, file->type);
    102101        file->fits = psFitsOpen (file->filename, mode);
     
    107106        file->state = PM_FPA_STATE_OPEN;
    108107
    109         // In some cases, I need to call pmFPAAddSourceFromHeader after I've opened the file
     108        // In some cases, I need to call pmFPAAddSourceFromHeader after I've opened the file,
    110109        // specifically if I have not called this function on startup.  This happens for the
    111110        // images supplied by the detrend database, which are only identified here (above).
     
    160159        }
    161160        if (file->mode == PM_FPA_MODE_WRITE) {
    162             pmChip *chip;
    163             pmCell *cell;
    164161            switch (file->fileLevel) {
    165162            case PM_FPA_LEVEL_FPA:
    166                 pmFPAWrite (file->fpa, file->fits, NULL, false, false);
     163                pmFPAWrite (file->fpa, file->fits, NULL, true, false);
    167164                break;
    168             case PM_FPA_LEVEL_CHIP:
    169                 chip = pmFPAviewThisChip(view, file->fpa);
    170                 pmChipWrite (chip, file->fits, NULL, false, false);
    171                 break;
    172             case PM_FPA_LEVEL_CELL:
    173                 cell = pmFPAviewThisCell(view, file->fpa);
    174                 pmCellWrite(cell, file->fits, NULL, false);
    175                 break;
     165            case PM_FPA_LEVEL_CHIP: {
     166                    pmChip *chip = pmFPAviewThisChip(view, file->fpa);
     167                    pmChipWrite (chip, file->fits, NULL, true, false);
     168                    break;
     169                }
     170            case PM_FPA_LEVEL_CELL: {
     171                    pmCell *cell = pmFPAviewThisCell(view, file->fpa);
     172                    pmCellWrite(cell, file->fits, NULL, true);
     173                    break;
     174                }
    176175            default:
    177176                psAbort ("pmFPAfileIO", "fileLevel not correctly set");
     
    179178            }
    180179        }
     180        break;
     181
     182        // open the FITS object files
     183    case PM_FPA_FILE_CMF:
     184        psTrace ("pmFPAfile", 5, "opening %s (type: %d)\n", file->filename, file->type);
     185        file->fits = psFitsOpen (file->filename, mode);
     186        if (file->fits == NULL) {
     187            psError(PS_ERR_IO, false, "error opening file %s\n", file->filename);
     188            return false;
     189        }
     190        file->state = PM_FPA_STATE_OPEN;
    181191        break;
    182192
Note: See TracChangeset for help on using the changeset viewer.