IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 3, 2007, 6:23:32 PM (19 years ago)
Author:
Paul Price
Message:

Ensure PHU has been conformed to the camera format.

File:
1 edited

Legend:

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

    r15157 r15213  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-10-02 01:10:48 $
     5 *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-10-04 04:23:32 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    352352                }
    353353
     354                pmConfigConformHeader(hdu->header, file->format);
     355
    354356                psFitsWriteBlank (file->fits, hdu->header, headname);
    355357                psTrace ("pmFPAfile", 5, "wrote ext head %s (type: %d)\n", file->filename, file->type);
     
    439441    if (phu) {
    440442        psMetadataCopy (outhead, phu->header);
    441     } else {
    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) {
     443    }
     444
     445    pmConfigConformHeader (outhead, file->format);
     446
     447    // We need to get some FPA-level concepts in there
     448    // This is a hack, not very pretty.  But then, so is writing the FPA in this manner without
     449    // using the pmFPAMosaic functions....
     450
     451    psMetadata *headers = psMetadataLookupMetadata(NULL, file->fpa->camera, BLANK_HEADERS); // Header names
     452    if (!headers) {
     453        psError(PS_ERR_UNEXPECTED_NULL, false,
     454                "Unable to find %s metadata within camera configuration", BLANK_HEADERS);
     455        psFree(outhead);
     456        return false;
     457    }
     458
     459    {
     460        const char *mjdName = psMetadataLookupStr(NULL, headers, "FPA.TIME"); // Header name
     461        if (!mjdName || strlen(mjdName) == 0) {
    451462            psError(PS_ERR_UNEXPECTED_NULL, false,
    452                     "Unable to find %s metadata within camera configuration", BLANK_HEADERS);
     463                    "Unable to find FPA.TIME in %s within camera configuration.", BLANK_HEADERS);
    453464            psFree(outhead);
    454465            return false;
    455466        }
    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         }
     467        psTime *time = psMetadataLookupTime(NULL, file->fpa->concepts, "FPA.TIME"); // Time of observation
     468        double mjd = psTimeToMJD(time); // The MJD of observation
     469        psMetadataAddF64(outhead, PS_LIST_TAIL, mjdName, PS_META_REPLACE,
     470                         "Time of observation", mjd);
     471    }
     472
     473    {
     474        const char *expName = psMetadataLookupStr(NULL, headers, "FPA.EXPOSURE"); // Header name
     475        if (!expName || strlen(expName) == 0) {
     476            psError(PS_ERR_UNEXPECTED_NULL, false,
     477                    "Unable to find FPA.EXPOSURE in %s within camera configuration.",
     478                    BLANK_HEADERS);
     479            psFree(outhead);
     480            return false;
     481        }
     482        float exptime = psMetadataLookupF32(NULL, file->fpa->concepts,
     483                                            "FPA.EXPOSURE"); // Exposure time
     484        psMetadataAddF32(outhead, PS_LIST_TAIL, expName, PS_META_REPLACE,
     485                         "Exposure time (sec)", exptime);
     486    }
     487
     488    {
     489        const char *amName = psMetadataLookupStr(NULL, headers, "FPA.AIRMASS"); // Header name
     490        if (!amName || strlen(amName) == 0) {
     491            psError(PS_ERR_UNEXPECTED_NULL, false,
     492                    "Unable to find FPA.AIRMASS in %s within camera configuration.",
     493                    BLANK_HEADERS);
     494            psFree(outhead);
     495            return false;
     496        }
     497        float airmass = psMetadataLookupF32(NULL, file->fpa->concepts, "FPA.AIRMASS"); // Airmass
     498        psMetadataAddF32(outhead, PS_LIST_TAIL, amName, PS_META_REPLACE,
     499                         "Observation airmass", airmass);
     500    }
     501
     502    psMetadata *fileData = psMetadataLookupMetadata(NULL, file->format, "FILE"); // File information
     503    const char *fpaNameHdr = psMetadataLookupStr(NULL, fileData, "FPA.NAME");
     504    if (fpaNameHdr && strlen(fpaNameHdr) > 0) {
     505        const char *fpaName = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.NAME");
     506        psMetadataAddStr(outhead, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName);
    507507    }
    508508
Note: See TracChangeset for help on using the changeset viewer.