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/objects/pmPSF_IO.c

    r18600 r18601  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2008-07-17 20:43:38 $
     8 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2008-07-17 22:38:15 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535#include "pmFPAview.h"
    3636#include "pmFPAfile.h"
     37#include "pmFPAfileFitsIO.h"
    3738
    3839#include "pmPeaks.h"
     
    107108}
    108109
    109 bool pmPSFmodelWriteForView (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     110bool pmPSFmodelWriteForView (const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    110111{
    111112    PS_ASSERT_PTR_NON_NULL(view, false);
     
    142143
    143144// read in all chip-level PSFmodel files for this FPA
    144 bool pmPSFmodelWriteFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     145bool pmPSFmodelWriteFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    145146{
    146147    PS_ASSERT_PTR_NON_NULL(view, false);
     
    164165
    165166// read in all cell-level PSFmodel files for this chip
    166 bool pmPSFmodelWriteChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     167bool pmPSFmodelWriteChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    167168{
    168169    PS_ASSERT_PTR_NON_NULL(view, false);
     
    185186//   - psf table (+header) : FITS Table
    186187bool pmPSFmodelWrite (psMetadata *analysis, const pmFPAview *view,
    187                       pmFPAfile *file, const pmConfig *config)
     188                      pmFPAfile *file, pmConfig *config)
    188189{
    189190    PS_ASSERT_PTR_NON_NULL(view, false);
     
    208209
    209210    // get the current header
    210     pmHDU *hdu = pmFPAviewThisHDU (view, file->fpa);
     211    pmFPA *fpa = pmFPAfileSuitableFPA(file, view, config, false); // Suitable FPA for writing
     212    pmHDU *hdu = psMemIncrRefCounter(pmFPAviewThisHDU(view, fpa));
     213    psFree(fpa);
    211214    if (!hdu) {
    212215        psError(PS_ERR_UNKNOWN, false, "Unable to find HDU");
     
    229232        if (!menu) {
    230233            psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
     234            psFree(hdu);
    231235            return false;
    232236        }
     
    236240        if (!rule) {
    237241            psError(PS_ERR_UNKNOWN, false, "missing entry for PSF.HEAD in EXTNAME.RULES in camera.config");
     242            psFree(hdu);
    238243            return false;
    239244        }
     
    245250            psError(PS_ERR_UNKNOWN, false, "missing entry for PSF.TABLE in EXTNAME.RULES in camera.config");
    246251            psFree (headName);
     252            psFree(hdu);
    247253            return false;
    248254        }
     
    255261            psFree (headName);
    256262            psFree (tableName);
     263            psFree(hdu);
    257264            return false;
    258265        }
     
    278285        psFree (headName);
    279286    }
     287    psFree(hdu);
    280288
    281289    // select the psf of interest
     
    481489
    482490// if this file needs to have a PHU written out, write one
    483 bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     491bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    484492{
    485493    PS_ASSERT_PTR_NON_NULL(view, false);
     
    496504    if (file->fpa->chips->n == 1) return true;
    497505
     506
    498507    // find the FPA phu
    499     pmHDU *phu = pmFPAviewThisPHU (view, file->fpa);
     508    pmFPA *fpa = pmFPAfileSuitableFPA(file, view, config, false); // Suitable FPA for writing
     509    pmHDU *phu = psMemIncrRefCounter(pmFPAviewThisPHU(view, fpa));
     510    psFree(fpa);
    500511
    501512    // if there is no PHU, this is a single header+image (extension-less) file. This could be
     
    508519        pmConfigConformHeader (outhead, file->format);
    509520    }
     521    psFree(phu);
    510522
    511523    psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
Note: See TracChangeset for help on using the changeset viewer.