IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 17, 2008, 12:38:15 PM (18 years ago)
Author:
Paul Price
Message:

The FPA format in psastroDataSave was bad: the GPC1 inputs (which is used for the output) had HDUs in the chips, but the output format is supposed to have an HDU in the FPA. It comes down to a pmFPAfileSuitableFPA not being called at the right place. To fix this, I've sprinkled calls to pmFPAfileSuitableFPA in all the FITS writing functions. This provides the HDU in the right place to these functions. pmFPAfileSuitableFPA should now automatically take care of header conformity, updating concepts, etc. Now, if adding a function to write FITS data, you should make sure that you call pmFPAfileSuitableFPA to get the right format, HDU, header keywords, etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/astrom/pmAstrometryRefstars.c

    r17062 r18601  
    11/* @file  pmAstrometryRefstars.c
    22 * @brief Functions to write (and read?) astrometric reference stars
    3  * 
     3 *
    44 * @ingroup AstroImage
    55 *
    66 * @author EAM, IfA
    7  * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-03-20 00:27:00 $
     7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2008-07-17 22:38:15 $
    99 * Copyright 2008 Institute for Astronomy, University of Hawaii
    1010 */
     
    3232#include "pmFPAview.h"
    3333#include "pmFPAfile.h"
     34#include "pmFPAfileFitsIO.h"
    3435#include "pmAstrometryObjects.h"
    3536#include "pmAstrometryRefstars.h"
     
    144145}
    145146
    146 bool pmAstromRefstarsWritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config) {
    147 
    148     // output header data 
     147bool pmAstromRefstarsWritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config) {
     148
     149    // output header data
    149150    psMetadata *outhead = psMetadataAlloc();
    150151
    151152    // use the FPA phu to generate the PHU header
    152     pmHDU *phu = file->fpa->hdu;
     153    pmFPA *fpa = pmFPAfileSuitableFPA(file, view, config, false); // Suitable FPA for writing
     154    pmHDU *phu = psMemIncrRefCounter(fpa->hdu);
     155    psFree(fpa);
    153156
    154157    // if there is no FPA PHU, this is a single header+image (extension-less) file. This could be
     
    156159    // write it out as a 'blank'
    157160    if (phu) {
    158         psMetadataCopy (outhead, phu->header);
     161        psMetadataCopy (outhead, phu->header);
    159162    } else {
    160         pmConfigConformHeader (outhead, file->format);
    161     }
     163        pmConfigConformHeader (outhead, file->format);
     164    }
     165    psFree(phu);
    162166
    163167    psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
     
    256260
    257261    // set the extname : we are really only allowed one entry per chip; check this here?
    258     char *chiprule = psStringCopy ("{CHIP.NAME}"); 
     262    char *chiprule = psStringCopy ("{CHIP.NAME}");
    259263    char *chipname = pmFPAfileNameFromRule (chiprule, file, view);
    260264
    261265    for (int i = 0; i < refstars->n; i++) {
    262266      psMetadata *row = psMetadataAlloc ();
    263                
     267
    264268      pmAstromObj *ref = refstars->data[i];
    265269
    266       psMetadataAddF64(row,    PS_LIST_TAIL, "RA",      PS_META_REPLACE, "degrees", PS_DEG_RAD*ref->sky->r);
    267       psMetadataAddF64(row,    PS_LIST_TAIL, "DEC",     PS_META_REPLACE, "degrees", PS_DEG_RAD*ref->sky->d);
    268       psMetadataAddF32(row,    PS_LIST_TAIL, "TP_X",    PS_META_REPLACE, "microns", ref->TP->x);
    269       psMetadataAddF32(row,    PS_LIST_TAIL, "TP_Y",    PS_META_REPLACE, "microns", ref->TP->y);
    270       psMetadataAddF32(row,    PS_LIST_TAIL, "FP_X",    PS_META_REPLACE, "microns", ref->FP->x);
    271       psMetadataAddF32(row,    PS_LIST_TAIL, "FP_Y",    PS_META_REPLACE, "microns", ref->FP->y);
    272       psMetadataAddF32(row,    PS_LIST_TAIL, "CHIP_X",  PS_META_REPLACE, "microns", ref->chip->x);
    273       psMetadataAddF32(row,    PS_LIST_TAIL, "CHIP_Y",  PS_META_REPLACE, "microns", ref->chip->y);
    274       psMetadataAddF32(row,    PS_LIST_TAIL, "MAG",     PS_META_REPLACE, "microns", ref->Mag);
     270      psMetadataAddF64(row,    PS_LIST_TAIL, "RA",      PS_META_REPLACE, "degrees", PS_DEG_RAD*ref->sky->r);
     271      psMetadataAddF64(row,    PS_LIST_TAIL, "DEC",     PS_META_REPLACE, "degrees", PS_DEG_RAD*ref->sky->d);
     272      psMetadataAddF32(row,    PS_LIST_TAIL, "TP_X",    PS_META_REPLACE, "microns", ref->TP->x);
     273      psMetadataAddF32(row,    PS_LIST_TAIL, "TP_Y",    PS_META_REPLACE, "microns", ref->TP->y);
     274      psMetadataAddF32(row,    PS_LIST_TAIL, "FP_X",    PS_META_REPLACE, "microns", ref->FP->x);
     275      psMetadataAddF32(row,    PS_LIST_TAIL, "FP_Y",    PS_META_REPLACE, "microns", ref->FP->y);
     276      psMetadataAddF32(row,    PS_LIST_TAIL, "CHIP_X",  PS_META_REPLACE, "microns", ref->chip->x);
     277      psMetadataAddF32(row,    PS_LIST_TAIL, "CHIP_Y",  PS_META_REPLACE, "microns", ref->chip->y);
     278      psMetadataAddF32(row,    PS_LIST_TAIL, "MAG",     PS_META_REPLACE, "microns", ref->Mag);
    275279      psMetadataAddF32(row,    PS_LIST_TAIL, "MAG_ERR", PS_META_REPLACE, "microns", ref->dMag);
    276280
     
    281285        psError(PS_ERR_IO, false, "writing refstars\n");
    282286        psFree (table);
    283         psFree (header);
    284         psFree (chiprule);
    285         psFree (chipname);
     287        psFree (header);
     288        psFree (chiprule);
     289        psFree (chipname);
    286290        return false;
    287291    }
Note: See TracChangeset for help on using the changeset viewer.