IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15248


Ignore:
Timestamp:
Oct 8, 2007, 4:56:23 PM (19 years ago)
Author:
Paul Price
Message:

Adding function to return the number of rows in a FITS table. Also asserting that FITS files are writable when they need to be.

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

Legend:

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

    r15179 r15248  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-10-03 21:27:21 $
     9 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-10-09 02:56:23 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3434#define MAX_STRING_LENGTH 256  // maximum length string for FITS routines
    3535
     36long psFitsTableSize(const psFits *fits)
     37{
     38    PS_ASSERT_FITS_NON_NULL(fits, 0);
     39
     40    int status = 0;                     // CFITSIO status
     41    long numRows;                       // Number of rows
     42    if (fits_get_num_rows(fits->fd, &numRows, &status)) {
     43        psFitsError(status, true, "Unable to determine number of rows in table.");
     44        return 0;
     45    }
     46
     47    return numRows;
     48}
    3649
    3750psMetadata* psFitsReadTableRow(const psFits* fits,
     
    388401{
    389402    PS_ASSERT_FITS_NON_NULL(fits, false);
     403    PS_ASSERT_FITS_WRITABLE(fits, false);
    390404    if (!psFitsMoveLast(fits)) {
    391405        psError(PS_ERR_UNKNOWN, false, "Unable to move to last extension to write table");
     
    465479{
    466480    PS_ASSERT_FITS_NON_NULL(fits, false);
     481    PS_ASSERT_FITS_WRITABLE(fits, false);
    467482    PS_ASSERT_ARRAY_NON_NULL(table, false);
    468483
     
    719734{
    720735    PS_ASSERT_FITS_NON_NULL(fits, false);
     736    PS_ASSERT_FITS_WRITABLE(fits, false);
    721737    PS_ASSERT_METADATA_NON_NULL(data, false);
    722738    PS_ASSERT_INT_NONNEGATIVE(row, false);
  • trunk/psLib/src/fits/psFitsTable.h

    r11248 r15248  
    55 * @author Robert DeSonia, MHPCC
    66 *
    7  * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-01-23 22:47:23 $
     7 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2007-10-09 02:56:23 $
    99 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1010 */
     
    2323#include "psMetadata.h"
    2424#include "psImage.h"
     25
     26/// Return the number of rows in the current table
     27///
     28/// The current HDU type must be either PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE.
     29long psFitsTableSize(const psFits *fits ///< FITS file
     30                     );
    2531
    2632/** Reads a table row.  The current HDU type must be either
Note: See TracChangeset for help on using the changeset viewer.