IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 25, 2007, 4:52:53 PM (19 years ago)
Author:
magnier
Message:

added blocking to make the steps clearer

File:
1 edited

Legend:

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

    r13347 r13527  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-05-11 03:44:16 $
     5 *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-05-26 02:52:53 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    310310        }
    311311
    312         // lookup the EXTNAME values used for table data and image header segments
    313         char *rule = NULL;
    314         // Menu of EXTNAME rules
    315         psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
    316         if (!menu) {
    317             psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
    318             return false;
    319         }
    320         // EXTNAME for image header
    321         rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
    322         if (!rule) {
    323             psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
    324             return false;
    325         }
    326         headname = pmFPAfileNameFromRule (rule, file, view);
    327         // EXTNAME for table data
    328         rule = psMetadataLookupStr(&status, menu, "CMF.DATA");
    329         if (!rule) {
    330             psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
    331             return false;
    332         }
    333         dataname = pmFPAfileNameFromRule (rule, file, view);
    334 
    335         // this header block is new, write it to disk
    336         if (hdu->header != file->header) {
    337             // XXX I was building a new copy, why?  supplement the output header
    338             // outhead = psMetadataCopy (NULL, hdu->header);
    339 
    340             // add EXTNAME, EXTHEAD, EXTTYPE to header
    341             // psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "extension name", headname);
    342             psMetadataAddStr (hdu->header, PS_LIST_TAIL, "EXTDATA", PS_META_REPLACE, "name of table extension", dataname);
    343             psMetadataAddStr (hdu->header, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", "IMAGE");
    344             if (!file->phu) {
    345                 // this hdu->header acts as the PHU: set EXTEND to be true
    346                 psMetadataAddBool (hdu->header, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
    347             }
    348 
    349             // save psphot and psastro metadata in the image and table headers
    350             updates = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.HEADER");
    351             if (updates) {
    352                 psMetadataCopy (hdu->header, updates);
    353             }
    354             updates = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.HEADER");
    355             if (updates) {
    356                 psMetadataCopy (hdu->header, updates);
    357             }
    358 
    359             psFitsWriteBlank (file->fits, hdu->header, headname);
    360             psTrace ("pmFPAfile", 5, "wrote ext head %s (type: %d)\n", file->filename, file->type);
    361             file->header = hdu->header;
    362         }
    363 
    364         // create a header to hold the output data
    365         outhead = psMetadataAlloc ();
    366 
    367         // determine the output table format
    368         psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
    369         if (!status) {
    370             psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
    371             return false;
    372         }
    373         exttype = psMemIncrRefCounter (psMetadataLookupStr(&status, recipe, "OUTPUT.FORMAT"));
    374         if (!exttype) {
    375             exttype = psStringCopy ("SMPDATA");
    376         }
    377 
    378         // write the links to the image header
    379         psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTHEAD", PS_META_REPLACE, "name of image extension w/", headname);
    380         psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", exttype);
    381         psFree (exttype);
    382 
    383         // XXX these are case-sensitive since the EXTYPE is case-sensitive
    384         status = false;
    385         if (!strcmp (exttype, "SMPDATA")) {
    386             status = pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname);
    387         }
    388         if (!strcmp (exttype, "PS1_DEV_0")) {
    389             status = pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname);
    390         }
    391 
    392         if (!status) {
    393             psError(PS_ERR_IO, false, "writing CMF data to %s with format %s\n", file->filename, exttype);
    394             psFree (headname);
    395             psFree (dataname);
    396             psFree (outhead);
    397             return false;
    398         }
     312        // define the EXTNAME values for the different data segments:
     313        {
     314            // lookup the EXTNAME values used for table data and image header segments
     315            char *rule = NULL;
     316
     317            // Menu of EXTNAME rules
     318            psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
     319            if (!menu) {
     320                psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
     321                return false;
     322            }
     323
     324            // EXTNAME for image header
     325            rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
     326            if (!rule) {
     327                psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
     328                return false;
     329            }
     330            headname = pmFPAfileNameFromRule (rule, file, view);
     331
     332            // EXTNAME for table data
     333            rule = psMetadataLookupStr(&status, menu, "CMF.DATA");
     334            if (!rule) {
     335                psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
     336                return false;
     337            }
     338            dataname = pmFPAfileNameFromRule (rule, file, view);
     339        }
     340
     341        // write out the IMAGE header segment
     342        {
     343            // this header block is new, write it to disk
     344            if (hdu->header != file->header) {
     345                // add EXTNAME, EXTHEAD, EXTTYPE to header
     346                psMetadataAddStr (hdu->header, PS_LIST_TAIL, "EXTDATA", PS_META_REPLACE, "name of table extension", dataname);
     347                psMetadataAddStr (hdu->header, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", "IMAGE");
     348                if (!file->phu) {
     349                    // this hdu->header acts as the PHU: set EXTEND to be true
     350                    psMetadataAddBool (hdu->header, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
     351                }
     352
     353                // save psphot and psastro metadata in the image and table headers
     354                updates = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.HEADER");
     355                if (updates) {
     356                    psMetadataCopy (hdu->header, updates);
     357                }
     358                updates = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.HEADER");
     359                if (updates) {
     360                    psMetadataCopy (hdu->header, updates);
     361                }
     362
     363                psFitsWriteBlank (file->fits, hdu->header, headname);
     364                psTrace ("pmFPAfile", 5, "wrote ext head %s (type: %d)\n", file->filename, file->type);
     365                file->header = hdu->header;
     366            }
     367        }
     368
     369        // write out the TABLE data segment
     370        {
     371            // create a header to hold the output data
     372            outhead = psMetadataAlloc ();
     373
     374            // determine the output table format
     375            psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
     376            if (!status) {
     377                psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
     378                return false;
     379            }
     380            exttype = psMemIncrRefCounter (psMetadataLookupStr(&status, recipe, "OUTPUT.FORMAT"));
     381            if (!exttype) {
     382                exttype = psStringCopy ("SMPDATA");
     383            }
     384
     385            // write the links to the image header
     386            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTHEAD", PS_META_REPLACE, "name of image extension w/", headname);
     387            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", exttype);
     388            psFree (exttype);
     389
     390            // XXX these are case-sensitive since the EXTYPE is case-sensitive
     391            status = false;
     392            if (!strcmp (exttype, "SMPDATA")) {
     393                status = pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname);
     394            }
     395            if (!strcmp (exttype, "PS1_DEV_0")) {
     396                status = pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname);
     397            }
     398
     399            if (!status) {
     400                psError(PS_ERR_IO, false, "writing CMF data to %s with format %s\n", file->filename, exttype);
     401                psFree (headname);
     402                psFree (dataname);
     403                psFree (outhead);
     404                return false;
     405            }
     406        }
    399407
    400408        psTrace ("pmFPAfile", 5, "wrote ext data %s (type: %d)\n", file->filename, file->type);
Note: See TracChangeset for help on using the changeset viewer.