IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 25, 2006, 2:48:20 PM (20 years ago)
Author:
Paul Price
Message:

Fixing problem that prevented us from writing a PHU consisting of a header only --- need to call fits_create_img in psFitsWriteHeader if there are not currently any HDUs. This generates the primary HDU (without having to put in the required headers manually), and allows subsequent calls to psFitsWriteImage to generate a new HDU (without having to put in the required headers manually). Required keywords are written by cfitsio.

File:
1 edited

Legend:

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

    r7161 r7224  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-05-22 22:38:27 $
     9 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-05-26 00:48:20 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    331331    }
    332332
    333     int chdu = psFitsGetExtNum(fits);
    334     int hdus = psFitsGetSize(fits);
     333    int chdu = psFitsGetExtNum(fits);   // Current HDU number
     334    int hdus = psFitsGetSize(fits);     // Number of HDUs in file
    335335    if (! after) {
    336336        if (chdu == 0) {
     
    346346        status = 0;
    347347        fits_create_img(fits->fd, bitPix, naxis, naxes, &status);
    348 
    349348    } else {
    350349        fits_insert_img(fits->fd, bitPix, naxis, naxes, &status);
     
    363362
    364363    if (header) {
    365         // Update header with BITPIX, NAXIS[12], BSCALE, BZERO so we don't clobber the basic header
    366         psMetadataAddS32(header, PS_LIST_TAIL, "BITPIX", PS_META_REPLACE, "Bits per pixel", bitPix);
    367         psMetadataAddS32(header, PS_LIST_TAIL, "NAXIS",  PS_META_REPLACE, "Number of dimensions", naxis);
    368         psMetadataAddS32(header, PS_LIST_TAIL, "NAXIS1", PS_META_REPLACE, "Number of columns", numCols);
    369         psMetadataAddS32(header, PS_LIST_TAIL, "NAXIS2", PS_META_REPLACE, "Number of rows", numRows);
    370         psMetadataAddF64(header, PS_LIST_TAIL, "BSCALE", PS_META_REPLACE, "Pixel value scale", 1.0);
    371         psMetadataAddF64(header, PS_LIST_TAIL, "BZERO",  PS_META_REPLACE, "Pixel value offset", bZero);
    372         if (extname && strlen(extname) > 0) {
    373             psMetadataAddStr(header, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "Extenion Name", extname);
    374         }
    375364        psFitsWriteHeader(header, fits);
    376     } else {
    377         // Write the necessary headers manually
    378         fits_write_key_dbl(fits->fd, "BZERO", bZero, 12, "Pixel Value Offset", &status);
    379         fits_write_key_dbl(fits->fd, "BSCALE", 1.0, 12, "Pixel Value Scale", &status);
    380         // Regrettably have to cast away "const" on extname, because CFITSIO is horrible
    381         fits_write_key_str(fits->fd, "EXTNAME", (char *)extname, "Extension name", &status);
    382     }
    383 
     365    }
    384366    if (input->parent == NULL) { // if no parent, assume that the image data is contiguous
    385367        fits_write_img(fits->fd,
     
    402384    }
    403385
    404     if ( status != 0) {
     386    if (status != 0) {
    405387        char fitsErr[MAX_STRING_LENGTH];
    406388        (void)fits_get_errstatus(status, fitsErr);
Note: See TracChangeset for help on using the changeset viewer.