IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15335


Ignore:
Timestamp:
Oct 19, 2007, 1:52:39 PM (19 years ago)
Author:
Paul Price
Message:

Adding psFitsFloat.[ch] for quantising (and unquantising) floating-point images and setting BSCALE and BZERO. It isn't in a usable state yet, but checking in to the tree for safety. It's not activate in the build.

Location:
trunk/psLib/src/fits
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/Makefile.am

    r8914 r15335  
    99        psFitsImage.c \
    1010        psFitsTable.c
     11#       psFitsFloat.c
    1112
    1213EXTRA_DIST = fits.i
     
    1718        psFitsImage.h \
    1819        psFitsTable.h
     20#       psFitsFloat.h
    1921
    2022CLEANFILES = *~ *.bb *.bbg *.da
  • trunk/psLib/src/fits/psFits.c

    r15179 r15335  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.72 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-10-03 21:27:21 $
     9 *  @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-10-19 23:52:39 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    163163    fits->extword = NULL;
    164164    fits->conventions.compression = true;
     165    fits->conventions.psBitpix = true;
     166    fits->bscale = 0.0;
     167    fits->bzero = 0.0;
    165168    psMemSetDeallocator(fits,(psFreeFunc)fitsFree);
    166169
     
    397400{
    398401    PS_ASSERT_FITS_NON_NULL(fits, false);
    399 
    400     if (! fits->writable) {
    401         psError(PS_ERR_IO, true,
    402                 _("The psFits object is not writable."));
    403         return false;
    404     }
     402    PS_ASSERT_FITS_WRITABLE(fits, false);
    405403
    406404    // move to the specified HDU
     
    431429{
    432430    PS_ASSERT_FITS_NON_NULL(fits, false);
     431    PS_ASSERT_FITS_WRITABLE(fits, false);
    433432    PS_ASSERT_STRING_NON_EMPTY(extname, false);
    434 
    435     if (! fits->writable) {
    436         psError(PS_ERR_IO, true,
    437                 _("The psFits object is not writable."));
    438         return false;
    439     }
    440433
    441434    // move to the specified HDU
     
    509502bool psFitsTruncate(psFits* fits)
    510503{
    511     PS_ASSERT_FITS_NON_NULL(fits, NULL);
    512 
    513     if (! fits->writable) {
    514         psError(PS_ERR_IO, true,
    515                 _("The psFits object is not writable."));
    516         return PS_FITS_TYPE_NONE;
    517     }
     504    PS_ASSERT_FITS_NON_NULL(fits, false);
     505    PS_ASSERT_FITS_WRITABLE(fits, false);
    518506
    519507    int newEnd = psFitsGetExtNum(fits);
     
    547535{
    548536    PS_ASSERT_FITS_NON_NULL(fits, false);
     537    PS_ASSERT_FITS_WRITABLE(fits, false);
    549538
    550539    // convert psFitsCompressionType to cfitsio compression types
  • trunk/psLib/src/fits/psFits.h

    r15249 r15335  
    44 * @author Robert DeSonia, MHPCC
    55 *
    6  * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-10-09 03:00:05 $
     6 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-10-19 23:52:39 $
    88 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    99 */
     
    5757    struct {
    5858        bool compression;               ///< Compression convention: handling of compressed images
     59        bool psBitpix;                  ///< Pan-STARRS BITPIX for floating-point conversion
    5960    } conventions;                      ///< Conventions to honour
     61    double bscale;                      ///< Scaling to apply when reading FITS data; 0 for auto
     62    double bzero;                       ///< Zero point to apply when reading FITS data; auto if bscale = 0
    6063} psFits;
    6164
  • trunk/psLib/src/fits/psFitsHeader.c

    r15191 r15335  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-10-04 01:16:33 $
     9 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-10-19 23:52:39 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    593593{
    594594    PS_ASSERT_FITS_NON_NULL(fits, false);
     595    PS_ASSERT_FITS_WRITABLE(fits, false);
    595596    PS_ASSERT_METADATA_NON_NULL(output, false);
    596597
     
    604605{
    605606    PS_ASSERT_FITS_NON_NULL(fits, false);
     607    PS_ASSERT_FITS_WRITABLE(fits, false);
    606608
    607609    // We allow output == NULL in order to write a minimal header.
  • trunk/psLib/src/fits/psFitsImage.c

    r15179 r15335  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-10-03 21:27:21 $
     9 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-10-19 23:52:39 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    185185}
    186186
     187
     188bool psFitsImageSize(int *numCols, int *numRows, psElemType *type, const psFits *fits, psRegion region)
     189{
     190    PS_ASSERT_FITS_NON_NULL(fits, NULL);
     191
     192    if (psFitsCheckSingleCompressedImagePHU(fits, NULL)) {
     193        // This is really what we want, not the empty PHU
     194        psTrace("psLib.fits", 1,
     195                "This PHU should really be a compressed image --- reading that image instead.");
     196    }
     197
     198    p_psFitsReadInfo *info = p_psFitsReadInfoAlloc(fits, region, 0); // How big the region to read is
     199
     200    if (numCols) {
     201        *numCols = info->lastPixel[0] - info->firstPixel[0] + 1;
     202    }
     203    if (numRows) {
     204        *numRows = info->lastPixel[1] - info->firstPixel[1] + 1;
     205    }
     206    if (type) {
     207        *type = info->psDatatype;
     208    }
     209
     210    psFree(info);
     211
     212    return true;
     213}
     214
     215
    187216// Read into an extant image of just the right size
    188217static bool fitsReadImage(psImage *output,   // Output image
     
    287316{
    288317    PS_ASSERT_FITS_NON_NULL(fits, false);
     318    PS_ASSERT_FITS_WRITABLE(fits, false);
    289319    PS_ASSERT_IMAGE_NON_NULL(input, false);
    290320    // this is equivalent to insert after the last HDU
     
    302332{
    303333    PS_ASSERT_FITS_NON_NULL(fits, false);
     334    PS_ASSERT_FITS_WRITABLE(fits, false);
    304335    PS_ASSERT_IMAGE_NON_NULL(input, false);
    305336
     
    402433{
    403434    PS_ASSERT_FITS_NON_NULL(fits, false);
     435    PS_ASSERT_FITS_WRITABLE(fits, false);
    404436    PS_ASSERT_IMAGE_NON_NULL(input, false);
    405437
     
    556588{
    557589    PS_ASSERT_FITS_NON_NULL(fits, false);
     590    PS_ASSERT_FITS_WRITABLE(fits, false);
    558591    PS_ASSERT_ARRAY_NON_NULL(input, false);
    559592
     
    622655{
    623656    PS_ASSERT_FITS_NON_NULL(fits, false);
     657    PS_ASSERT_FITS_WRITABLE(fits, false);
    624658    PS_ASSERT_ARRAY_NON_NULL(input, false);
    625659
  • trunk/psLib/src/fits/psFitsImage.h

    r11248 r15335  
    44 * @author Robert DeSonia, MHPCC
    55 *
    6  * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-01-23 22:47:23 $
     6 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-10-19 23:52:39 $
    88 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    99 */
     
    2121#include "psMetadata.h"
    2222#include "psImage.h"
     23
     24/// Return the dimensions and type of the FITS image
     25bool psFitsImageSize(int *numCols, int *numRows, ///< Size of image
     26                     psElemType *type,  ///< Type of image
     27                     const psFits *fits, ///< FITS file pointer
     28                     psRegion region    ///< Region in the FITS image to read
     29    );
    2330
    2431/** Reads an image, given the desired region and z-plane.
Note: See TracChangeset for help on using the changeset viewer.