IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 1, 2007, 3:10:48 PM (19 years ago)
Author:
Paul Price
Message:

Reinstating the use of BLANK.HEADERS. This should properly be considered as an ugly hack.

File:
1 edited

Legend:

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

    r15151 r15157  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-10-01 21:37:21 $
     5 *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-10-02 01:10:48 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4141#include "pmSourceIO.h"
    4242
     43#define BLANK_HEADERS "BLANK.HEADERS"   // Name of metadata in camera configuration containing header names
     44                                        // for putting values into a blank PHU
     45
    4346// translations between psphot object types and dophot object types
    4447int pmSourceGetDophotType (pmSource *source)
     
    336339                    // this hdu->header acts as the PHU: set EXTEND to be true
    337340                    psMetadataAddBool (hdu->header, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
    338                     file->wrote_phu = true;
     341                    file->wrote_phu = true;
    339342                }
    340343
     
    435438    psMetadata *outhead = psMetadataAlloc();
    436439    if (phu) {
    437         psMetadataCopy (outhead, phu->header);
     440        psMetadataCopy (outhead, phu->header);
    438441    } else {
    439         pmConfigConformHeader (outhead, file->format);
    440 
    441         // XXX need to finish this:
    442         // psMetadata *blankHeaders = psMetadataLookupMetadata(NULL, file->camera, "BLANK.HEADERS"); // File information
    443         // psMetadataItem *item = NULL;
    444         // while (item = psMetadatagetAndIncrement (blankHeaders)) {
    445            
    446 
    447         psMetadata *fileData = psMetadataLookupMetadata(NULL, file->format, "FILE"); // File information
    448         const char *fpaNameHdr = psMetadataLookupStr(NULL, fileData, "FPA.NAME");
    449         if (fpaNameHdr && strlen(fpaNameHdr) > 0) {
    450             const char *fpaName = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.NAME");
    451             psMetadataAddStr(outhead, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName);
    452         }
     442        pmConfigConformHeader (outhead, file->format);
     443
     444        // We need to get some FPA-level concepts in there
     445        // This is a hack, not very pretty.  But then, so is writing the FPA in this manner without
     446        // using the pmFPAMosaic functions....
     447
     448        psMetadata *headers = psMetadataLookupMetadata(NULL, file->fpa->camera,
     449                                                       BLANK_HEADERS); // Header names
     450        if (!headers) {
     451            psError(PS_ERR_UNEXPECTED_NULL, false,
     452                    "Unable to find %s metadata within camera configuration", BLANK_HEADERS);
     453            psFree(outhead);
     454            return false;
     455        }
     456
     457        {
     458            const char *mjdName = psMetadataLookupStr(NULL, headers, "FPA.TIME"); // Header name
     459            if (!mjdName || strlen(mjdName) == 0) {
     460                psError(PS_ERR_UNEXPECTED_NULL, false,
     461                        "Unable to find FPA.TIME in %s within camera configuration.", BLANK_HEADERS);
     462                psFree(outhead);
     463                return false;
     464            }
     465            psTime *time = psMetadataLookupTime(NULL, file->fpa->concepts,
     466                                                "FPA.TIME"); // Time of observation
     467            double mjd = psTimeToMJD(time); // The MJD of observation
     468            psMetadataAddF64(outhead, PS_LIST_TAIL, mjdName, PS_META_REPLACE,
     469                             "Time of observation", mjd);
     470        }
     471
     472        {
     473            const char *expName = psMetadataLookupStr(NULL, headers, "FPA.EXPOSURE"); // Header name
     474            if (!expName || strlen(expName) == 0) {
     475                psError(PS_ERR_UNEXPECTED_NULL, false,
     476                        "Unable to find FPA.EXPOSURE in %s within camera configuration.",
     477                        BLANK_HEADERS);
     478                psFree(outhead);
     479                return false;
     480            }
     481            float exptime = psMetadataLookupF32(NULL, file->fpa->concepts,
     482                                                "FPA.EXPOSURE"); // Exposure time
     483            psMetadataAddF32(outhead, PS_LIST_TAIL, expName, PS_META_REPLACE,
     484                             "Exposure time (sec)", exptime);
     485        }
     486
     487        {
     488            const char *amName = psMetadataLookupStr(NULL, headers, "FPA.AIRMASS"); // Header name
     489            if (!amName || strlen(amName) == 0) {
     490                psError(PS_ERR_UNEXPECTED_NULL, false,
     491                        "Unable to find FPA.AIRMASS in %s within camera configuration.",
     492                        BLANK_HEADERS);
     493                psFree(outhead);
     494                return false;
     495            }
     496            float airmass = psMetadataLookupF32(NULL, file->fpa->concepts, "FPA.AIRMASS"); // Airmass
     497            psMetadataAddF32(outhead, PS_LIST_TAIL, amName, PS_META_REPLACE,
     498                             "Observation airmass", airmass);
     499        }
     500
     501        psMetadata *fileData = psMetadataLookupMetadata(NULL, file->format, "FILE"); // File information
     502        const char *fpaNameHdr = psMetadataLookupStr(NULL, fileData, "FPA.NAME");
     503        if (fpaNameHdr && strlen(fpaNameHdr) > 0) {
     504            const char *fpaName = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.NAME");
     505            psMetadataAddStr(outhead, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName);
     506        }
    453507    }
    454508
     
    456510    psMetadata *updates = psMetadataLookupPtr (&status, file->fpa->analysis, "PSASTRO.HEADER");
    457511    if (updates) {
    458         psMetadataCopy (outhead, updates);
     512        psMetadataCopy (outhead, updates);
    459513    }
    460514
Note: See TracChangeset for help on using the changeset viewer.