IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 3, 2009, 4:39:36 PM (17 years ago)
Author:
Paul Price
Message:

Moving in some stuff from pap_branch_20081216 to set the image and source identifiers in FITS files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAWrite.c

    r19385 r21279  
    107107    if (writeBlank || writeImage) {
    108108
    109         pmFPAUpdateNames(cell->parent->parent, cell->parent, cell);
    110109        pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS |
    111110                                 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE;
     
    157156
    158157        if (writeBlank || writeImage) {
    159             pmFPAUpdateNames(chip->parent, chip, NULL);
    160158            pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS |
    161159                                     PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE;
     
    221219
    222220        if (writeBlank || writeImage) {
    223             pmFPAUpdateNames(fpa, NULL, NULL);
    224221            pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS |
    225222                                     PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE;
     
    255252
    256253// Update the FPA.OBS, CHIP.NAME and CELL.NAME in the FITS header, if required
    257 bool pmFPAUpdateNames(pmFPA *fpa, pmChip *chip, pmCell *cell)
    258 {
    259     pmHDU *hdu = pmHDUGetHighest(fpa, chip, cell); // Highest HDU, i.e., the PHU
    260     if (!hdu) {
     254bool pmFPAUpdateNames(pmFPA *fpa, pmChip *chip, pmCell *cell, psS64 imageId, psS64 sourceId)
     255{
     256    pmHDU *hduHigh = pmHDUGetHighest(fpa, chip, cell); // Highest HDU, i.e., the PHU
     257    if (!hduHigh) {
     258        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find PHU.\n");
     259        return false;
     260    }
     261    if (!hduHigh->header) {
     262        hduHigh->header = psMetadataAlloc();
     263    }
     264    if (!pmHDUWriteIdentifiers(hduHigh, imageId, sourceId)) {
     265        psError(PS_ERR_UNKNOWN, false, "Unable to write identifiers to header.");
     266        return false;
     267    }
     268
     269    pmHDU *hduLow = pmHDUGetLowest(fpa, chip, cell); // Lowest HDU, i.e., the extension
     270    if (!hduLow) {
    261271        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find HDU.\n");
    262272        return false;
    263273    }
    264     if (!hdu->header) {
    265         hdu->header = psMetadataAlloc();
    266     }
     274    if (!hduLow->header) {
     275        hduLow->header = psMetadataAlloc();
     276    }
     277    if (hduLow != hduHigh && !pmHDUWriteIdentifiers(hduLow, imageId, sourceId)) {
     278        psError(PS_ERR_UNKNOWN, false, "Unable to write identifiers to header.");
     279        return false;
     280    }
     281
    267282    bool mdok;                          // Status of MD lookup
    268     psMetadata *fileData = psMetadataLookupMetadata(&mdok, hdu->format, "FILE"); // File information
     283    psMetadata *fileData = psMetadataLookupMetadata(&mdok, hduHigh->format, "FILE"); // File information
    269284    if (!mdok || !fileData) {
    270285        psError(PS_ERR_UNKNOWN, true, "Unable to find FILE information in camera format.\n");
     
    275290        if (mdok && fpaObsHdr && strlen(fpaObsHdr) > 0) {
    276291            const char *fpaObs = psMetadataLookupStr(NULL, fpa->concepts, "FPA.OBS");
    277             psMetadataAddStr(hdu->header, PS_LIST_TAIL, fpaObsHdr, PS_META_REPLACE,
     292            psMetadataAddStr(hduHigh->header, PS_LIST_TAIL, fpaObsHdr, PS_META_REPLACE,
    278293                             "Observation identifier", fpaObs);
    279294        }
     
    298313        }
    299314
    300         psMetadataAddStr(hdu->header, PS_LIST_TAIL, contentKey, PS_META_REPLACE, "Content of file", content);
     315        psMetadataAddStr(hduHigh->header, PS_LIST_TAIL, contentKey, PS_META_REPLACE,
     316                         "Content of file", content);
    301317        psFree(content);                // Drop reference
    302318    }
Note: See TracChangeset for help on using the changeset viewer.