IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 13, 2007, 5:20:22 PM (19 years ago)
Author:
magnier
Message:

create pmPSF_WritePHU

File:
1 edited

Legend:

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

    r13526 r14207  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-05-26 02:52:27 $
     8 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-07-14 03:20:22 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    224224    bool status;
    225225    pmHDU *hdu;
    226     pmHDU *phu;
    227226    char *headName, *tableName, *residName;
    228227
     
    240239    // XXX this code could be placed in a 'pmPSF_WritePHU' function and called
    241240    // from pmFPAfileIO.c.
    242     if ((file->fileLevel == PM_FPA_LEVEL_FPA) && (file->fpa->chips->n > 1) && !file->phu) {
    243 
    244         // find the FPA phu
    245         phu = pmFPAviewThisPHU (view, file->fpa);
    246 
    247         // if there is no PHU, this is a single header+image (extension-less) file
    248         // if there is a PHU, write it out as a 'blank'
    249         psMetadata *outhead = psMetadataAlloc();
    250         if (phu) {
    251             psMetadataCopy (outhead, phu->header);
    252         } else {
    253             pmConfigConformHeader (outhead, file->format);
    254 
    255             psMetadata *fileData = psMetadataLookupMetadata(NULL, file->format, "FILE"); // File information
    256             const char *fpaNameHdr = psMetadataLookupStr(NULL, fileData, "FPA.NAME");
    257             if (fpaNameHdr && strlen(fpaNameHdr) > 0) {
    258                 const char *fpaName = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.NAME");
    259                 psMetadataAddStr(outhead, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName);
    260             }
    261         }
    262 
    263         psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
    264         psFitsWriteBlank (file->fits, outhead, "");
    265         file->phu = true;
    266         psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type);
    267         psFree (outhead);
    268     }
    269241
    270242    // define the EXTNAME values used for image header, table data, and residual image segments
     
    315287        psMetadataAddStr (hdu->header, PS_LIST_TAIL, "EXTRESID", PS_META_REPLACE, "name of resid extension", residName);
    316288        psMetadataAddStr (hdu->header, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", "IMAGE");
    317         if (!file->phu) {
     289        if (!file->wrote_phu) {
    318290            // this hdu->header acts as the PHU: set EXTEND to be true
    319291            psMetadataAddBool (hdu->header, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
     292            file->wrote_phu = true;
    320293        }
    321294
     
    471444}
    472445
     446// if this file needs to have a PHU written out, write one
     447bool pmPSF_WritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config) {
     448
     449    // not needed if already written
     450    if (file->wrote_phu) return true;
     451
     452    // not needed if not FPA
     453    // XXX this prevents us from defining a SPLIT/MEF CMF file...
     454    if (file->fileLevel != PM_FPA_LEVEL_FPA) return true;
     455
     456    // not needed if only one chip
     457    if (file->fpa->chips->n == 1) return true;
     458
     459    // find the FPA phu
     460    pmHDU *phu = pmFPAviewThisPHU (view, file->fpa);
     461
     462    // if there is no PHU, this is a single header+image (extension-less) file. This could be
     463    // the case for an input SPLIT set of files being written out as a MEF.  if there is a PHU,
     464    // write it out as a 'blank'
     465    psMetadata *outhead = psMetadataAlloc();
     466    if (phu) {
     467        psMetadataCopy (outhead, phu->header);
     468    } else {
     469        pmConfigConformHeader (outhead, file->format);
     470
     471        psMetadata *fileData = psMetadataLookupMetadata(NULL, file->format, "FILE"); // File information
     472        const char *fpaNameHdr = psMetadataLookupStr(NULL, fileData, "FPA.NAME");
     473        if (fpaNameHdr && strlen(fpaNameHdr) > 0) {
     474            const char *fpaName = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.NAME");
     475            psMetadataAddStr(outhead, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName);
     476        }
     477    }
     478
     479    psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
     480    psFitsWriteBlank (file->fits, outhead, "");
     481    file->wrote_phu = true;
     482
     483    psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type);
     484    psFree (outhead);
     485
     486    return true;
     487}
     488
    473489bool pmFPAviewReadPSFmodel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    474490{
Note: See TracChangeset for help on using the changeset viewer.