IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10920


Ignore:
Timestamp:
Jan 5, 2007, 10:19:23 AM (19 years ago)
Author:
magnier
Message:

added EXTTYPE, EXTHEAD, EXTDATA to image/table data in CMF; fixed order issues

File:
1 edited

Legend:

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

    r10829 r10920  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-12-25 01:49:50 $
     5 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-01-05 20:19:23 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    168168
    169169    bool status;
     170    char *exttype;
    170171    char *realname;
    171172    char *filename;
     
    248249
    249250        // if file does not yet have a PHU, attempt to write one to disk
    250         if (file->phu == NULL) {
    251             // get the corresponding phu
     251        // we only need a PHU if chips->n > 1 and file->fileLevel == FPA
     252        // otherwise, the chip header fills the PHU location
     253        if ((file->fileLevel == PM_FPA_LEVEL_FPA) && (file->fpa->chips->n > 1) && !file->phu) {
     254
     255            // find the FPA phu
    252256            phu = pmFPAviewThisPHU (view, file->fpa);
    253257
    254258            // if there is no PHU, this is a single header+image (extension-less) file
    255259            // if there is a PHU, write it out as a 'blank'
     260            outhead = psMetadataAlloc();
    256261            if (phu) {
    257                 outhead = psMetadataCopy (NULL, phu->header);
    258 
    259                 // if we have mosaic-level astrometry information, add it here:
    260                 updates = psMetadataLookupPtr (&status, file->fpa->analysis, "PSASTRO.HEADER");
    261                 if (updates) {
    262                     psMetadataCopy (outhead, updates);
    263                 }
    264 
    265                 psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
    266                 // XXX what is the EXTNAME??
    267                 psFitsWriteBlank (file->fits, outhead, "");
    268                 file->phu = phu->header;
    269                 psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type);
    270                 psFree (outhead);
     262                psMetadataCopy (outhead, phu->header);
    271263            }
    272         }
     264
     265            // if we have mosaic-level astrometry information, add it here:
     266            updates = psMetadataLookupPtr (&status, file->fpa->analysis, "PSASTRO.HEADER");
     267            if (updates) {
     268                psMetadataCopy (outhead, updates);
     269            }
     270
     271            psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
     272            psFitsWriteBlank (file->fits, outhead, "");
     273            file->phu = true;
     274            psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type);
     275            psFree (outhead);
     276        }
     277
     278        // EXTNAME values used to for table data and image header segments
     279        dataname = pmFPAfileNameFromRule (file->extrule, file, view);
     280        headname = pmFPAfileNameFromRule (file->extxtra, file, view);
    273281
    274282        // this header block is new, write it to disk
    275283        if (hdu->header != file->header) {
    276             // determine name for header extension
    277             headname = pmFPAfileNameFromRule (file->extxtra, file, view);
    278284            outhead = psMetadataCopy (NULL, hdu->header);
    279             psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "extension name", headname);
    280             if (file->phu == NULL) {
     285
     286            // add EXTNAME, EXTHEAD, EXTTYPE to header
     287            // psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "extension name", headname);
     288            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTDATA", PS_META_REPLACE, "name of table extension", dataname);
     289            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", "IMAGE");
     290            if (!file->phu) {
    281291                // this hdu->header acts as the PHU: set EXTEND to be true
    282292                psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
    283293            }
    284294
    285             // XXX : see note below about DVO/addstar expectations
     295            // save psphot and psastro metadata in the image (not table) header
    286296            updates = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.HEADER");
    287297            if (updates) {
     
    298308            file->header = hdu->header;
    299309            psFree (outhead);
    300             psFree (headname);
    301         }
    302 
    303         // write this table to disk
    304         dataname = pmFPAfileNameFromRule (file->extrule, file, view);
    305 
    306         // XXX : currently, this is being added to the TABLE header
    307         //       this may be the correct location for a MEF file, but it is
    308         //       inconsistent with DVO/addstar expectations.  DVO/addstar
    309         //       currently only expects a single header/table pair, and the
    310         //       metadata are in the blank (image) header, not the table header
    311         //       it may be necessary to put the results from the first readout
    312         //       in the blank image header to cover this case.
    313         updates = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.HEADER");
    314         pmSourcesWriteCMF (file->fits, sources, updates, dataname);
     310        }
     311
     312        // create a header to hold the output data
     313        outhead = psMetadataAlloc ();
     314
     315        exttype = psStringCopy ("SMPDATA");  // XXX derive this from the recipes
     316        psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTHEAD", PS_META_REPLACE, "name of image extension w/", headname);
     317        psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", exttype);
     318        psFree (exttype);
     319
     320        pmSourcesWriteCMF (file->fits, sources, outhead, dataname);
    315321        psTrace ("pmFPAfile", 5, "wrote ext data %s (type: %d)\n", file->filename, file->type);
     322
     323        psFree (headname);
    316324        psFree (dataname);
     325        psFree (outhead);
    317326        break;
    318327
Note: See TracChangeset for help on using the changeset viewer.