IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 2, 2006, 3:02:08 PM (20 years ago)
Author:
Paul Price
Message:

Applying RHL patch. Generally improves the error handling and traceback. pmConcepts.c and pmConceptsRead.c done by PAP (RHL did this also, but I had already done them). Resolved conflicts, except for pmFPAfile.c, which uses psAbort in some instances where RHL's patch had psError; leave this for Gene to decide.

Location:
trunk/psModules/src/objects
Files:
12 edited

Legend:

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

    r6960 r7311  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-04-23 01:07:51 $
     8 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-06-03 01:02:08 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9797    // the ApTrend components are (x, y, r2rflux, flux)
    9898    psf->ApTrend = psPolynomial4DAlloc (PS_POLYNOMIAL_ORD, 2, 2, 1, 1);
    99     pmPSF_MaskApTrend (psf, PM_PSF_SKYBIAS);
     99    pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_SKYBIAS);
    100100
    101101    if (psf->poissonErrors) {
     
    239239 * to enable the specific subset of the coefficients
    240240 **********************************************/
    241 bool pmPSF_MaskApTrend (pmPSF *psf, pmPSF_ApTrendOptions option)
     241bool pmPSF_MaskApTrend (psPolynomial4D *trend,
     242                        pmPSF_ApTrendOptions option)
    242243{
    243244
    244245    switch (option) {
    245246    case PM_PSF_NONE:
    246         maskAllTerms (psf->ApTrend);
     247        maskAllTerms (trend);
    247248        return true;
    248249
    249250    case PM_PSF_CONSTANT:
    250         maskAllTerms (psf->ApTrend);
    251         psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
     251        maskAllTerms (trend);
     252        trend->mask[0][0][0][0] = 0;  // unmask constant
    252253        return true;
    253254
    254255    case PM_PSF_SKYBIAS:
    255         maskAllTerms (psf->ApTrend);
    256         psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
    257         psf->ApTrend->mask[0][0][1][0] = 0;  // unmask skybias
     256        maskAllTerms (trend);
     257        trend->mask[0][0][0][0] = 0;  // unmask constant
     258        trend->mask[0][0][1][0] = 0;  // unmask skybias
    258259        return true;
    259260
    260261    case PM_PSF_SKYSAT:
    261         maskAllTerms (psf->ApTrend);
    262         psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
    263         psf->ApTrend->mask[0][0][1][0] = 0;  // unmask skybias
    264         psf->ApTrend->mask[0][0][0][1] = 0;  // unmask skybias
     262        maskAllTerms (trend);
     263        trend->mask[0][0][0][0] = 0;  // unmask constant
     264        trend->mask[0][0][1][0] = 0;  // unmask skybias
     265        trend->mask[0][0][0][1] = 0;  // unmask skysat
    265266        return true;
    266267
    267268    case PM_PSF_XY_LIN:
    268         maskAllTerms (psf->ApTrend);
    269         psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
    270         psf->ApTrend->mask[1][0][0][0] = 0;  // unmask x
    271         psf->ApTrend->mask[0][1][0][0] = 0;  // unmask y
     269        maskAllTerms (trend);
     270        trend->mask[0][0][0][0] = 0;  // unmask constant
     271        trend->mask[1][0][0][0] = 0;  // unmask x
     272        trend->mask[0][1][0][0] = 0;  // unmask y
    272273        return true;
    273274
    274275    case PM_PSF_XY_QUAD:
    275         maskAllTerms (psf->ApTrend);
    276         psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
    277         psf->ApTrend->mask[1][0][0][0] = 0;  // unmask x
    278         psf->ApTrend->mask[2][0][0][0] = 0;  // unmask x^2
    279         psf->ApTrend->mask[1][1][0][0] = 0;  // unmask x y
    280         psf->ApTrend->mask[0][1][0][0] = 0;  // unmask y
    281         psf->ApTrend->mask[0][2][0][0] = 0;  // unmask y^2
     276        maskAllTerms (trend);
     277        trend->mask[0][0][0][0] = 0;  // unmask constant
     278        trend->mask[1][0][0][0] = 0;  // unmask x
     279        trend->mask[2][0][0][0] = 0;  // unmask x^2
     280        trend->mask[1][1][0][0] = 0;  // unmask x y
     281        trend->mask[0][1][0][0] = 0;  // unmask y
     282        trend->mask[0][2][0][0] = 0;  // unmask y^2
    282283        return true;
    283284
    284285    case PM_PSF_SKY_XY_LIN:
    285         maskAllTerms (psf->ApTrend);
    286         psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
    287         psf->ApTrend->mask[1][0][0][0] = 0;  // unmask x
    288         psf->ApTrend->mask[0][1][0][0] = 0;  // unmask y
    289         psf->ApTrend->mask[0][0][1][0] = 0;  // unmask skybias
     286        maskAllTerms (trend);
     287        trend->mask[0][0][0][0] = 0;  // unmask constant
     288        trend->mask[1][0][0][0] = 0;  // unmask x
     289        trend->mask[0][1][0][0] = 0;  // unmask y
     290        trend->mask[0][0][1][0] = 0;  // unmask skybias
    290291        return true;
    291292
    292293    case PM_PSF_SKYSAT_XY_LIN:
    293         maskAllTerms (psf->ApTrend);
    294         psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
    295         psf->ApTrend->mask[1][0][0][0] = 0;  // unmask x
    296         psf->ApTrend->mask[0][1][0][0] = 0;  // unmask y
    297         psf->ApTrend->mask[0][0][1][0] = 0;  // unmask skybias
    298         psf->ApTrend->mask[0][0][0][1] = 0;  // unmask skysat
     294        maskAllTerms (trend);
     295        trend->mask[0][0][0][0] = 0;  // unmask constant
     296        trend->mask[1][0][0][0] = 0;  // unmask x
     297        trend->mask[0][1][0][0] = 0;  // unmask y
     298        trend->mask[0][0][1][0] = 0;  // unmask skybias
     299        trend->mask[0][0][0][1] = 0;  // unmask skysat
    299300        return true;
    300301
    301302    case PM_PSF_ALL:
    302303    default:
    303         maskAllTerms (psf->ApTrend);
    304         psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
    305         psf->ApTrend->mask[0][0][1][0] = 0;  // unmask skybias
    306         psf->ApTrend->mask[0][0][0][1] = 0;  // unmask skysat
    307 
    308         psf->ApTrend->mask[1][0][0][0] = 0;  // unmask x
    309         psf->ApTrend->mask[2][0][0][0] = 0;  // unmask x^2
    310         psf->ApTrend->mask[1][1][0][0] = 0;  // unmask x y
    311         psf->ApTrend->mask[0][1][0][0] = 0;  // unmask y
    312         psf->ApTrend->mask[0][2][0][0] = 0;  // unmask y^2
     304        maskAllTerms (trend);
     305        trend->mask[0][0][0][0] = 0;  // unmask constant
     306        trend->mask[0][0][1][0] = 0;  // unmask skybias
     307        trend->mask[0][0][0][1] = 0;  // unmask skysat
     308
     309        trend->mask[1][0][0][0] = 0;  // unmask x
     310        trend->mask[2][0][0][0] = 0;  // unmask x^2
     311        trend->mask[1][1][0][0] = 0;  // unmask x y
     312        trend->mask[0][1][0][0] = 0;  // unmask y
     313        trend->mask[0][2][0][0] = 0;  // unmask y^2
    313314        return true;
    314315    }
  • trunk/psModules/src/objects/pmPSF.h

    r6873 r7311  
    3131    psArray *params;   ///< Model parameters (psPolynomial2D)
    3232    psPolynomial1D *ChiTrend;  ///< Chisq vs flux fit (correction for systematic errors)
    33     psPolynomial4D *ApTrend;  ///< ApResid vs (x,y,rflux) (rflux = ten(0.4*mInst)
    34     pmGrowthCurve *growth;  ///< apMag vs Radius
     33    psPolynomial4D *ApTrend;  ///< ApResid vs (x,y,rflux) (rflux = ten(0.4*mInst))
     34    //pmGrowthCurve *growth;  ///< apMag vs Radius // move to end as gdb is confused by it here
    3535    float ApResid;   ///< apMag - psfMag (for PSF stars)
    3636    float dApResid;   ///< scatter of ApResid
     
    4141    int nApResid;   ///< number of stars used to measure ApResid
    4242    bool poissonErrors;
     43    pmGrowthCurve *growth;  ///< apMag vs Radius
    4344}
    4445pmPSF;
     
    100101);
    101102
    102 bool pmPSF_MaskApTrend (pmPSF *psf, pmPSF_ApTrendOptions option);
     103bool pmPSF_MaskApTrend (psPolynomial4D *trend, pmPSF_ApTrendOptions option);
    103104
    104105# endif
  • trunk/psModules/src/objects/pmPSF_IO.c

    r6872 r7311  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-04-17 18:01:05 $
     8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-06-03 01:02:08 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    287287{
    288288
    289     int Nfail;
     289    unsigned int Nfail;
    290290    char *filename;
    291291
  • trunk/psModules/src/objects/pmPSFtry.c

    r7283 r7311  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-06-02 02:16:05 $
     7 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-06-03 01:02:08 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    263263    psLogMsg ("pmPSFtryMetric", 4, "fit stats: %f +/- %f\n", stats->sampleMedian, stats->sampleStdev);
    264264
    265     pmPSF_MaskApTrend (psfTry->psf, PM_PSF_SKYBIAS);
     265    pmPSF_MaskApTrend (psfTry->psf->ApTrend, PM_PSF_SKYBIAS);
    266266    psfTry->psf->ApTrend->coeff[0][0][0][0] = poly->coeff[0];
    267267    psfTry->psf->ApTrend->coeff[0][0][1][0] = 0;
  • trunk/psModules/src/objects/pmPSFtry.h

    r6873 r7311  
    66 *  @author EAM, IfA
    77 *
     8 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-06-03 01:02:08 $
    810 *
    911 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7678 *
    7779 */
    78 pmPSFtry *pmPSFtryAlloc(
    79     psArray *stars,                     ///< Add comment.
    80     char *modelName,                     ///< Add comment.
    81     bool poissonErrors   // use poissonian or constant errors?
    82 );
    83 
     80pmPSFtry *pmPSFtryAlloc (psArray *sources, char *modelName, bool poissonErrors);
    8481
    8582/** pmPSFtryModel()
     
    9087 *
    9188 */
    92 pmPSFtry *pmPSFtryModel(
    93     psArray *sources,                   ///< Add comment.
    94     char *modelName,                    ///< Add comment.
    95     float radius,                     ///< Add comment.
    96     bool poissonErrors   // use poissonian or constant errors?
    97 );
    98 
     89pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors);
    9990
    10091/** pmPSFtryMetric()
  • trunk/psModules/src/objects/pmPeaks.c

    r6943 r7311  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-04-21 21:26:44 $
     8 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-06-03 01:02:08 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9494pmPeakAlloc(): Allocate the pmPeak data structure and set appropriate members.
    9595*****************************************************************************/
     96static void peakFree(pmPeak *tmp)
     97{} // used by pmIsPeak()
     98
    9699pmPeak *pmPeakAlloc(psS32 x,
    97100                    psS32 y,
     
    100103{
    101104    psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
     105    static int id = 1;
    102106    pmPeak *tmp = (pmPeak *) psAlloc(sizeof(pmPeak));
     107    *(int *)&tmp->id = id++;
    103108    tmp->x = x;
    104109    tmp->y = y;
     
    106111    tmp->type = type;
    107112
     113    psMemSetDeallocator(tmp, (psFreeFunc) peakFree);
     114
    108115    psTrace(__func__, 3, "---- %s() end ----\n", __func__);
    109116    return(tmp);
     117}
     118
     119bool pmIsPeak(const psPtr ptr)
     120{
     121    return (psMemGetDeallocator(ptr) == (psFreeFunc)peakFree);
    110122}
    111123
  • trunk/psModules/src/objects/pmPeaks.h

    r6872 r7311  
    1010 *  @author GLG, MHPCC
    1111 *
    12  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-04-17 18:01:05 $
     12 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-06-03 01:02:08 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4747typedef struct
    4848{
     49    const int id;   ///< Unique ID for object
    4950    int x;                              ///< X-coordinate of peak pixel.
    5051    int y;                              ///< Y-coordinate of peak pixel.
     
    6667);
    6768
     69bool pmIsPeak(const psPtr ptr);
    6870
    6971/** pmFindVectorPeaks()
  • trunk/psModules/src/objects/pmSource.c

    r7283 r7311  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-06-02 02:16:05 $
     8 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-06-03 01:02:08 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4646{
    4747    psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
     48    static int id = 1;
    4849    pmSource *tmp = (pmSource *) psAlloc(sizeof(pmSource));
     50    *(int *)&tmp->id = id++;
    4951    tmp->peak = NULL;
    5052    tmp->pixels = NULL;
     
    6971}
    7072
     73bool pmIsSource(const psPtr ptr)
     74{
     75    return (psMemGetDeallocator(ptr) == (psFreeFunc)sourceFree);
     76}
     77
    7178// x,y are defined in the parent image coords of readout->image
    7279bool pmSourceDefinePixels(pmSource *mySource,
     
    8289    srcRegion = psRegionForImage (readout->image, srcRegion);
    8390
    84     mySource->pixels = psImageSubset(readout->image, srcRegion);
    85     mySource->weight = psImageSubset(readout->weight, srcRegion);
    86     mySource->mask   = psImageSubset(readout->mask,  srcRegion);
     91    mySource->pixels = psMemIncrRefCounter(psImageSubset(readout->image, srcRegion));
     92    mySource->weight = psMemIncrRefCounter(psImageSubset(readout->weight, srcRegion));
     93    mySource->mask   = psMemIncrRefCounter(psImageSubset(readout->mask,  srcRegion));
    8794    mySource->region = srcRegion;
    8895
     
    123130        psFree (mySource->mask);
    124131
    125         mySource->pixels = psImageSubset(readout->image,  newRegion);
    126         mySource->weight = psImageSubset(readout->weight, newRegion);
    127         mySource->mask   = psImageSubset(readout->mask,   newRegion);
     132        mySource->pixels = psMemIncrRefCounter(psImageSubset(readout->image,  newRegion));
     133        mySource->weight = psMemIncrRefCounter(psImageSubset(readout->weight, newRegion));
     134        mySource->mask   = psMemIncrRefCounter(psImageSubset(readout->mask,   newRegion));
    128135        mySource->region = newRegion;
    129136    }
  • trunk/psModules/src/objects/pmSource.h

    r6905 r7311  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-04-19 20:29:57 $
     5 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-06-03 01:02:08 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7373typedef struct
    7474{
     75    const int id;   ///< Unique ID for object
    7576    pmPeak *peak;   ///< Description of peak pixel.
    7677    psImage *pixels;   ///< Rectangular region including object pixels.
     
    114115pmSource  *pmSourceAlloc();
    115116
     117bool pmIsSource(const psPtr ptr);
    116118
    117119/** pmSourceDefinePixels()
  • trunk/psModules/src/objects/pmSourceFitModel.c

    r6960 r7311  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-04-23 01:07:51 $
     8 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-06-03 01:02:08 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    515515    psTrace (__func__, 5, "fitting function\n");
    516516    fitStatus = psMinimizeLMChi2(myMin, covar, params, constrain, x, y, yErr, pmModelFitSet);
     517    if (!fitStatus) {
     518        psError(PS_ERR_UNKNOWN, false, "Failed to fit model\n");
     519    }
    517520
    518521    // parameter errors from the covariance matrix
  • trunk/psModules/src/objects/pmSourceIO.c

    r7306 r7311  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-06-03 00:40:28 $
     5 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-06-03 01:02:08 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5757}
    5858
    59 // Given a FITS file pointer, read the table of object data
     59// Given a FITS file pointer, write the table of object data
    6060bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file)
    6161{
     
    6464
    6565    if (view->chip == -1) {
    66         pmFPAWriteObjects (fpa, view, file);
     66        if (!pmFPAWriteObjects (fpa, view, file)) {
     67            psError(PS_ERR_IO, false, "Failed to write objects from fpa");
     68            return false;
     69        }
    6770        return true;
    6871    }
    6972
    7073    if (view->chip >= fpa->chips->n) {
     74        psError(PS_ERR_UNKNOWN, false, "Writing chip == %d (>= chips->n == %d)", view->chip, fpa->chips->n);
    7175        return false;
    7276    }
     
    7478
    7579    if (view->cell == -1) {
    76         pmChipWriteObjects (chip, view, file);
     80        if (!pmChipWriteObjects (chip, view, file)) {
     81            psError(PS_ERR_IO, false, "Failed to write objects from chip");
     82            return false;
     83        }
    7784        return true;
    7885    }
    7986
    8087    if (view->cell >= chip->cells->n) {
     88        psError(PS_ERR_UNKNOWN, false, "Writing cell == %d (>= cells->n == %d)",
     89                view->cell, chip->cells->n);
    8190        return false;
    8291    }
     
    8493
    8594    if (view->readout == -1) {
    86         pmCellWriteObjects (cell, view, file);
     95        if (!pmCellWriteObjects (cell, view, file)) {
     96            psError(PS_ERR_IO, false, "Failed to write objects from cell");
     97            return false;
     98        }
     99
    87100        return true;
    88101    }
    89102
    90103    if (view->readout >= cell->readouts->n) {
     104        psError(PS_ERR_UNKNOWN, false, "Writing readout == %d (>= readouts->n == %d)",
     105                view->readout, cell->readouts->n);
    91106        return false;
    92107    }
    93108    pmReadout *readout = cell->readouts->data[view->readout];
    94109
    95     pmReadoutWriteObjects (readout, view, file);
     110    if (!pmReadoutWriteObjects (readout, view, file)) {
     111        psError(PS_ERR_IO, false, "Failed to write objects from readout %d", view->readout);
     112        return false;
     113    }
     114
    96115    return true;
    97116}
     
    104123
    105124        pmChip *chip = fpa->chips->data[i];
    106         pmChipWriteObjects (chip, view, file);
     125        if (!pmChipWriteObjects (chip, view, file)) {
     126            psError(PS_ERR_IO, false, "Failed to write %dth chip", i);
     127            return false;
     128        }
    107129    }
    108130    return true;
     
    116138
    117139        pmCell *cell = chip->cells->data[i];
    118         pmCellWriteObjects (cell, view, file);
     140        if (!pmCellWriteObjects (cell, view, file)) {
     141            psError(PS_ERR_IO, false, "Failed to write %dth cell", i);
     142            return false;
     143        }
    119144    }
    120145    return true;
     
    128153
    129154        pmReadout *readout = cell->readouts->data[i];
    130         pmReadoutWriteObjects (readout, view, file);
     155        if (!pmReadoutWriteObjects (readout, view, file)) {
     156            psError(PS_ERR_IO, false, "Failed to write %dth readout", i);
     157            return false;
     158        }
    131159    }
    132160    return true;
     
    181209        psMetadataCopy (outhead, updates);
    182210
    183         pmSourcesWriteCMP (sources, filename, outhead);
     211        bool status = pmSourcesWriteCMP (sources, filename, outhead);
    184212        psFree (outhead);
    185213        psFree (filename);
     214
     215        if (!status) {
     216            psError(PS_ERR_IO, false, "Failed to write CMP file\n");
     217            return false;
     218        }
    186219        break;
    187220
  • trunk/psModules/src/objects/pmSourceIO_CMP.c

    r7306 r7311  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-06-03 00:40:46 $
     5 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-06-03 01:02:08 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6969
    7070    psFits *fits = psFitsOpen (filename, "w");
    71     psFitsWriteBlank(fits, header);
    72     psFitsClose (fits);
     71    if (fits == NULL) {
     72        psError(PS_ERR_IO, false, "can't open output file for write %s\n", filename);
     73        return false;
     74    }
     75    if (!psFitsWriteBlank(fits, header)) {
     76        psError(PS_ERR_IO, false, "Writing header to %s\n", filename);
     77        (void)psFitsClose(fits);
     78        return false;
     79    }
     80    if (!psFitsClose(fits)) {
     81        const psErrorCode code = psErrorCodeLast();
     82
     83        if (code == PS_ERR_BAD_FITS) {
     84            psErrorClear();
     85        } else {
     86            psError(PS_ERR_IO, false, "Closing %s\n", filename);
     87            return false;
     88        }
     89    }
    7390
    7491    // re-open, add data to end of file
    7592    FILE *f = fopen (filename, "a+");
    7693    if (f == NULL) {
    77         psLogMsg ("WriteSourceOBJ", 3, "can't open output file for output %s\n", filename);
     94        psLogMsg ("WriteSourceOBJ", 3, "can't reopen output file for append %s\n", filename);
     95        psError(PS_ERR_IO, false, "can't open output file for output %s\n", filename);
    7896        return false;
    7997    }
Note: See TracChangeset for help on using the changeset viewer.