IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 13, 2007, 5:22:48 PM (19 years ago)
Author:
Paul Price
Message:

Adding const to pmConfig parameter, where possible.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmSourceIO.c

    r12706 r12832  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-03-31 04:18:04 $
     5 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-04-14 03:22:48 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6666
    6767// Given a FITS file pointer, write the table of object data
    68 bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file, pmConfig *config)
     68bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    6969{
    7070
     
    125125
    126126// read in all chip-level Objects files for this FPA
    127 bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
     127bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    128128{
    129129
     
    140140
    141141// read in all cell-level Objects files for this chip
    142 bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
     142bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    143143{
    144144
     
    155155
    156156// read in all readout-level Objects files for this cell
    157 bool pmCellWriteObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
     157bool pmCellWriteObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    158158{
    159159
     
    170170
    171171// write out all readout-level Objects files for this cell
    172 bool pmReadoutWriteObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
     172bool pmReadoutWriteObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    173173{
    174174
     
    260260        // we only need a PHU if chips->n > 1 and file->fileLevel == FPA
    261261        // otherwise, the chip header fills the PHU location
    262         // XXX this code could be placed in a 'pmSource_CMF_WritePHU' function and called
    263         // from pmFPAfileIO.c.
     262        // XXX this code could be placed in a 'pmSource_CMF_WritePHU' function and called
     263        // from pmFPAfileIO.c.
    264264        if ((file->fileLevel == PM_FPA_LEVEL_FPA) && (file->fpa->chips->n > 1) && !file->phu) {
    265265
     
    275275                pmConfigConformHeader (outhead, file->format);
    276276
    277                 psMetadata *fileData = psMetadataLookupMetadata(NULL, file->format, "FILE"); // File information
    278                 const char *fpaNameHdr = psMetadataLookupStr(NULL, fileData, "FPA.NAME");
    279                 if (fpaNameHdr && strlen(fpaNameHdr) > 0) {
    280                     const char *fpaName = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.NAME");
    281                     psMetadataAddStr(outhead, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName);
    282                 }
     277                psMetadata *fileData = psMetadataLookupMetadata(NULL, file->format, "FILE"); // File information
     278                const char *fpaNameHdr = psMetadataLookupStr(NULL, fileData, "FPA.NAME");
     279                if (fpaNameHdr && strlen(fpaNameHdr) > 0) {
     280                    const char *fpaName = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.NAME");
     281                    psMetadataAddStr(outhead, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName);
     282                }
    283283            }
    284284
     
    298298        // lookup the EXTNAME values used for table data and image header segments
    299299        char *rule = NULL;
    300         // Menu of EXTNAME rules
    301         psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES"); 
    302         if (!menu) {
    303             psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
    304             return false;
    305         }
    306         // EXTNAME for image header
    307         rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
    308         if (!rule) {
    309             psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
    310             return false;
    311         }
     300        // Menu of EXTNAME rules
     301        psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
     302        if (!menu) {
     303            psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
     304            return false;
     305        }
     306        // EXTNAME for image header
     307        rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
     308        if (!rule) {
     309            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
     310            return false;
     311        }
    312312        headname = pmFPAfileNameFromRule (rule, file, view);
    313         // EXTNAME for table data
    314         rule = psMetadataLookupStr(&status, menu, "CMF.DATA"); 
    315         if (!rule) {
    316             psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
    317             return false;
    318         }
     313        // EXTNAME for table data
     314        rule = psMetadataLookupStr(&status, menu, "CMF.DATA");
     315        if (!rule) {
     316            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
     317            return false;
     318        }
    319319        dataname = pmFPAfileNameFromRule (rule, file, view);
    320320
     
    348348        }
    349349
    350         // create a header to hold the output data
    351         outhead = psMetadataAlloc ();
    352 
    353         // determine the output table format
    354         psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
    355         if (!status) {
    356             psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
    357             return false;
    358         }
    359         exttype = psMemIncrRefCounter (psMetadataLookupStr(&status, recipe, "OUTPUT.FORMAT"));
    360         if (!exttype) {
    361             exttype = psStringCopy ("SMPDATA");
    362         }
    363 
    364         // write the links to the image header
     350        // create a header to hold the output data
     351        outhead = psMetadataAlloc ();
     352
     353        // determine the output table format
     354        psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
     355        if (!status) {
     356            psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
     357            return false;
     358        }
     359        exttype = psMemIncrRefCounter (psMetadataLookupStr(&status, recipe, "OUTPUT.FORMAT"));
     360        if (!exttype) {
     361            exttype = psStringCopy ("SMPDATA");
     362        }
     363
     364        // write the links to the image header
    365365        psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTHEAD", PS_META_REPLACE, "name of image extension w/", headname);
    366366        psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", exttype);
    367367        psFree (exttype);
    368368
    369         // XXX these are case-sensitive since the EXTYPE is case-sensitive
    370         status = false;
    371         if (!strcmp (exttype, "SMPDATA")) {
    372             status = pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname);
    373         }
    374         if (!strcmp (exttype, "PS1_DEV_0")) {
    375             status = pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname);
    376         }
     369        // XXX these are case-sensitive since the EXTYPE is case-sensitive
     370        status = false;
     371        if (!strcmp (exttype, "SMPDATA")) {
     372            status = pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname);
     373        }
     374        if (!strcmp (exttype, "PS1_DEV_0")) {
     375            status = pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname);
     376        }
    377377
    378378        if (!status) {
     
    400400
    401401// Given a FITS file pointer, read the table of object data
    402 bool pmFPAviewReadObjects (const pmFPAview *view, pmFPAfile *file, pmConfig *config)
     402bool pmFPAviewReadObjects (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    403403{
    404404    pmFPA *fpa = file->fpa;
     
    439439
    440440// read in all chip-level Objects files for this FPA
    441 bool pmFPAReadObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
     441bool pmFPAReadObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    442442{
    443443    for (int i = 0; i < fpa->chips->n; i++) {
     
    449449
    450450// read in all cell-level Objects files for this chip
    451 bool pmChipReadObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
     451bool pmChipReadObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    452452{
    453453    chip->data_exists = false;
     
    455455        pmCell *cell = chip->cells->data[i];
    456456        pmCellReadObjects (cell, view, file, config);
    457         if (!cell->data_exists) continue;
    458         chip->data_exists = true;
     457        if (!cell->data_exists) continue;
     458        chip->data_exists = true;
    459459    }
    460460    return true;
     
    462462
    463463// read in all readout-level Objects files for this cell
    464 bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
     464bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    465465{
    466466    // multiple readout mode is not yet defined for CMP or CMF files
     
    475475        pmReadout *readout = cell->readouts->data[i];
    476476        pmReadoutReadObjects (readout, view, file, config);
    477         if (!readout->data_exists) {
    478             continue;
    479         }
    480 
    481         // load in the concept information for this cell
    482         if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
    483             //psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell");
    484             //return false;
    485             psWarning("Difficulty reading concepts for cell; attempting to proceed.");
    486         }
     477        if (!readout->data_exists) {
     478            continue;
     479        }
     480
     481        // load in the concept information for this cell
     482        if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
     483            //psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell");
     484            //return false;
     485            psWarning("Difficulty reading concepts for cell; attempting to proceed.");
     486        }
    487487        cell->data_exists = true;
    488488    }
     
    491491
    492492// read in all readout-level Objects files for this cell
    493 bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
     493bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    494494{
    495495
     
    500500    switch (file->type) {
    501501      case PM_FPA_FILE_OBJ:
    502         psError(PS_ERR_UNKNOWN, true, "OBJ is not supported as an input object format");
    503         return false;
     502        psError(PS_ERR_UNKNOWN, true, "OBJ is not supported as an input object format");
     503        return false;
    504504
    505505      case PM_FPA_FILE_SX:
    506         psError(PS_ERR_UNKNOWN, true, "SX is not supported as an input object format");
    507         return false;
     506        psError(PS_ERR_UNKNOWN, true, "SX is not supported as an input object format");
     507        return false;
    508508
    509509      case PM_FPA_FILE_CMP:
     
    530530        psString realname = pmConfigConvertFilename (file->filename, config, create);
    531531
    532         // read the PHU from this file
     532        // read the PHU from this file
    533533        file->fits = psFitsOpen (realname, "r");
    534534        if (hdu->header != NULL) {
     
    549549        // lookup the EXTNAME values used for table data and image header segments
    550550        char *rule = NULL;
    551         // Menu of EXTNAME rules
     551        // Menu of EXTNAME rules
    552552        psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
    553         if (!menu) {
    554             psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
    555             return false;
    556         }
    557         // EXTNAME for image header
    558         rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
    559         if (!rule) {
    560             psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
    561             return false;
    562         }
     553        if (!menu) {
     554            psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
     555            return false;
     556        }
     557        // EXTNAME for image header
     558        rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
     559        if (!rule) {
     560            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
     561            return false;
     562        }
    563563        char *headname = pmFPAfileNameFromRule (rule, file, view);
    564         // EXTNAME for table data
     564        // EXTNAME for table data
    565565        rule = psMetadataLookupStr(&status, menu, "CMF.DATA");
    566         if (!rule) {
    567             psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
    568             return false;
    569         }
     566        if (!rule) {
     567            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
     568            return false;
     569        }
    570570        char *dataname = pmFPAfileNameFromRule (rule, file, view);
    571571
    572         // advance to the IMAGE HEADER extension
     572        // advance to the IMAGE HEADER extension
    573573        if (hdu->header == NULL) {
    574             // if the IMAGE header does not exist, we have no data for this view
     574            // if the IMAGE header does not exist, we have no data for this view
    575575            if (!psFitsMoveExtName (file->fits, headname)) {
    576                 readout->data_exists = false;
    577                 psFree (headname);
    578                 psFree (dataname);
    579                 return true;
    580             }
     576                readout->data_exists = false;
     577                psFree (headname);
     578                psFree (dataname);
     579                return true;
     580            }
    581581            hdu->header = psFitsReadHeader (NULL, file->fits);
    582582        }
     
    587587        if (extdata) {
    588588            // if EXTDATA is defined in the header, use that value for 'dataname'
    589             psFree (dataname);
    590             dataname = psMemIncrRefCounter (extdata);
    591         }
    592        
    593         // advance to the table data extension
    594         // since we have read the IMAGE header, the TABLE header should exist
     589            psFree (dataname);
     590            dataname = psMemIncrRefCounter (extdata);
     591        }
     592
     593        // advance to the table data extension
     594        // since we have read the IMAGE header, the TABLE header should exist
    595595        if (!psFitsMoveExtName (file->fits, dataname)) {
    596596            psAbort("cannot find data extension %s in %s", dataname, file->filename);
    597597        }
    598598
    599         psMetadata *tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header
    600         if (!tableHeader) psAbort("cannot read table header");
     599        psMetadata *tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header
     600        if (!tableHeader) psAbort("cannot read table header");
    601601
    602602        char *exttype = psMetadataLookupStr (NULL, tableHeader, "EXTTYPE");
    603         if (!exttype) psAbort("cannot read table type");
    604 
    605         // XXX these are case-sensitive since the EXTYPE is case-sensitive
    606         if (!strcmp (exttype, "SMPDATA")) {
    607             sources = pmSourcesRead_SMPDATA (file->fits, hdu->header);
    608         }
    609         if (!strcmp (exttype, "PS1_DEV_0")) {
    610             sources = pmSourcesRead_PS1_DEV_0 (file->fits, hdu->header);
    611         }
     603        if (!exttype) psAbort("cannot read table type");
     604
     605        // XXX these are case-sensitive since the EXTYPE is case-sensitive
     606        if (!strcmp (exttype, "SMPDATA")) {
     607            sources = pmSourcesRead_SMPDATA (file->fits, hdu->header);
     608        }
     609        if (!strcmp (exttype, "PS1_DEV_0")) {
     610            sources = pmSourcesRead_PS1_DEV_0 (file->fits, hdu->header);
     611        }
    612612
    613613        psTrace("psModules.objects", 6, "read CMF table from %s : %s : %s", file->filename, headname, dataname);
    614         psFree (headname);
     614        psFree (headname);
    615615        psFree (dataname);
    616         psFree (tableHeader);
     616        psFree (tableHeader);
    617617        break;
    618618
Note: See TracChangeset for help on using the changeset viewer.