IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18590


Ignore:
Timestamp:
Jul 16, 2008, 5:34:22 PM (18 years ago)
Author:
Paul Price
Message:

Making UpdateImage look like WriteImage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/psFitsImage.c

    r18580 r18590  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2008-07-16 23:05:06 $
     9 *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2008-07-17 03:34:22 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    703703    psFitsCompression *compress = NULL; // FITS compression parameters; to save state
    704704
     705    bool success = true;                // Successful update?
    705706    double bscale = NAN, bzero = NAN;   // Scale and zero point to put in header
    706707    long blank = 0;                     // Blank (undefined) value for image
     
    710711    if (!diskImage) {
    711712        psError(PS_ERR_UNKNOWN, false, "Unable to convert image to desired disk format.");
    712         goto UPDATE_FAIL;
     713        success = false;
     714        goto UPDATE_DONE;
    713715    }
    714716
     
    720722        if (!psFitsSetCompression(fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) {
    721723            psError(PS_ERR_IO, false, "Unable to unset compression.");
    722             goto UPDATE_FAIL;
     724            success = false;
     725            goto UPDATE_DONE;
    723726        }
    724727    }
     
    729732    int dataType;                       // cfitsio data type
    730733    if (!p_psFitsTypeToCfitsio(diskImage->type.type, &bitPix, &cfitsioBzero, &dataType)) {
    731         goto UPDATE_FAIL;
     734        success = false;
     735        goto UPDATE_DONE;
    732736    }
    733737    if (cfitsioBzero != 0.0) {
     
    751755        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
    752756                _("Current FITS HDU has %ld z-planes, but z-plane %d was specified."), nAxes[2], z);
    753         goto UPDATE_FAIL;
     757        success = false;
     758        goto UPDATE_DONE;
    754759    }
    755760
     
    773778                "Input image [size of %ix%i] at position (%i,%i) does not all lay in the %lix%li FITS image.",
    774779                numCols, numRows, x0, y0, nAxes[0], nAxes[1]);
    775         goto UPDATE_FAIL;
     780        success = false;
     781        goto UPDATE_DONE;
    776782    }
    777783
     
    782788    fits_write_subset(fits->fd, dataType, firstPixel, lastPixel, diskImage->data.V[0], &status);
    783789    if (psFitsError(status, true, "Could not write data to file.")) {
    784         goto UPDATE_FAIL;
     790        success = false;
     791        goto UPDATE_DONE;
    785792    }
    786793
     
    790797    ffrdef(fits->fd, &status);
    791798    if (psFitsError(status, true, "Could not re-scan HDU.")) {
    792         goto UPDATE_FAIL;
    793     }
    794 
    795     psFree(diskImage);
    796     return true;
    797 
    798 UPDATE_FAIL:
     799        success = false;
     800        goto UPDATE_DONE;
     801    }
     802
     803UPDATE_DONE:
    799804    psFree(diskImage);
    800805    if (compress) {
     
    803808        psFree(compress);
    804809    }
    805     return false;
     810
     811    return success;
    806812}
    807813
Note: See TracChangeset for help on using the changeset viewer.