IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 9, 2004, 4:50:16 PM (22 years ago)
Author:
desonia
Message:

Changed psList API for iterators, etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fileUtils/psFits.c

    r2375 r2681  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-11-16 20:00:21 $
     9 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-12-10 02:50:15 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    200200}
    201201
    202 psFitsType psFitsMoveExtName(psFits* fits,
    203                              const char* extname)
    204 {
    205     int status = 0;
    206 
    207     if (fits == NULL) {
    208         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    209                 PS_ERRORTEXT_psFits_NULL);
    210         return PS_FITS_TYPE_NONE;
     202bool psFitsMoveExtName(psFits* fits,
     203                       const char* extname)
     204{
     205    int status = 0;
     206
     207    if (fits == NULL) {
     208        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     209                PS_ERRORTEXT_psFits_NULL);
     210        return false;
    211211    }
    212212
     
    218218                PS_ERRORTEXT_psFits_EXTNAME_INVALID,
    219219                extname, fits->filename, fitsErr);
    220         return PS_FITS_TYPE_NONE;
    221     }
    222 
    223     return psFitsGetExtType(fits);
    224 }
    225 
    226 psFitsType psFitsMoveExtNum(psFits* fits,
    227                             int extnum,
    228                             bool relative)
    229 {
    230     if (fits == NULL) {
    231         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    232                 PS_ERRORTEXT_psFits_NULL);
    233         return PS_FITS_TYPE_NONE;
     220        return false;
     221    }
     222
     223    return true;
     224}
     225
     226bool psFitsMoveExtNum(psFits* fits,
     227                      int extnum,
     228                      bool relative)
     229{
     230    if (fits == NULL) {
     231        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     232                PS_ERRORTEXT_psFits_NULL);
     233        return false;
    234234    }
    235235
     
    249249                PS_ERRORTEXT_psFits_EXTNUM_INVALID,
    250250                extnum, fits->filename, fitsErr);
    251         return PS_FITS_TYPE_NONE;
    252     }
    253 
    254     return hdutype;
     251        return false;
     252    }
     253
     254    return true;
    255255}
    256256
     
    304304        psError(PS_ERR_BAD_PARAMETER_NULL, true,
    305305                PS_ERRORTEXT_psFits_NULL);
    306         return PS_FITS_TYPE_NONE;
     306        return 0;
    307307    }
    308308
     
    316316                PS_ERRORTEXT_psFits_GETNUMHDUS_FAILED,
    317317                fits->filename, fitsErr);
    318         return -1;
     318        return 0;
    319319    }
    320320
    321321    return num;
    322 }
    323 
    324 bool psFitsCreateExt(psFits* fits)
    325 {
    326     if (fits == NULL) {
    327         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    328                 PS_ERRORTEXT_psFits_NULL);
    329         return false;
    330     }
    331 
    332     int status = 0;
    333 
    334     fits_create_hdu(fits->p_fd,&status);
    335 
    336     if ( status != 0) {
    337         char fitsErr[MAX_STRING_LENGTH];
    338         (void)fits_get_errstatus(status, fitsErr);
    339         psError(PS_ERR_IO, true,
    340                 PS_ERRORTEXT_psFits_CREATE_HDU_FAILED,
    341                 fits->filename, fitsErr);
    342         return false;
    343     }
    344 
    345     return true;
    346322}
    347323
     
    481457    }
    482458
    483     int status = 0;
    484 
    485459    int size = psFitsGetSize(fits);
    486     int position = psFitsGetExtNum(fits);
    487460
    488461    for (int lcv=0; lcv < size; lcv++) {
     
    502475        }
    503476    }
     477
     478    return out;
    504479}
    505480
    506481bool psFitsWriteImage(psFits* fits,
     482                      const psMetadata* header,
    507483                      const psImage* input,
    508                       int x,
    509                       int y,
    510                       int z)
     484                      int numZPlanes)
    511485{
    512486
     
    526500
    527501    int status = 0;
    528 
    529     psFitsType fitsType = psFitsGetExtType(fits);
    530 
    531     if (fitsType != PS_FITS_TYPE_IMAGE && fitsType != PS_FITS_TYPE_ANY) {
    532         psError(PS_ERR_IO, true,
    533                 PS_ERRORTEXT_psFits_NOT_IMAGE_TYPE);
    534         return false;
    535     }
    536502
    537503    // determine the FITS-equivalent parameters
     
    543509    }
    544510
    545     if (fitsType == PS_FITS_TYPE_ANY) {
    546         int naxis = 3;
    547         long naxes[3];
    548 
    549         naxes[0] = numCols;
    550         naxes[1] = numRows;
    551         naxes[2] = z;
    552 
    553         if (z < 2) {
    554             naxis = 2;
    555         }
    556 
    557         /* write the required keys to make an empty HDU be an IMAGE HDU */
    558         fits_write_imghdr(fits->p_fd, bitPix, naxis, naxes, &status);
    559         if (bZero != 0) {        // set the bscale/bzero
    560             fits_write_key_dbl(fits->p_fd, "BZERO", bZero, 12, "Pixel Value Offset", &status);
    561             fits_write_key_dbl(fits->p_fd, "BSCALE", 1.0, 12, "Pixel Value Scale", &status);
    562             // don't think this is needed: fits_set_bscale(fits->p_fd, bScale, bZero, &status);
    563         }
    564     }
    565 
    566     long firstPixel[3];         /* First Pixel to read */
    567     long lastPixel[3];          /* Last Pixel to read */
    568     firstPixel[0] = x + 1;
    569     firstPixel[1] = y + 1;
    570     firstPixel[2] = z + 1;
    571 
    572     lastPixel[0] = firstPixel[0] + numCols - 1;
    573     lastPixel[1] = firstPixel[1] + numRows - 1;
    574     lastPixel[2] = z + 1;
    575 
    576     fits_write_subset(fits->p_fd, dataType, firstPixel, lastPixel, input->data.V[0], &status);
     511    int naxis = 3;
     512    long naxes[3];
     513
     514    naxes[0] = numCols;
     515    naxes[1] = numRows;
     516    naxes[2] = numZPlanes;
     517
     518    if (numZPlanes < 2) {
     519        naxis = 2;
     520    }
     521
     522    fits_create_img(fits->p_fd, bitPix, naxis, naxes, &status);
     523
     524    if (bZero != 0) {        // set the bscale/bzero
     525        fits_write_key_dbl(fits->p_fd, "BZERO", bZero, 12, "Pixel Value Offset", &status);
     526        fits_write_key_dbl(fits->p_fd, "BSCALE", 1.0, 12, "Pixel Value Scale", &status);
     527        fits_set_bscale(fits->p_fd, 1.0, bZero, &status);
     528    }
     529
     530    // write the header, if any.
     531    if (header != NULL) {
     532        psFitsWriteHeader(fits, header);
     533    }
     534
     535    long firstPixel = (numZPlanes-1)*numRows*numCols; // start write in last z-plane
     536
     537    if (input->parent == NULL) { // if no parent, assume that the image data is contiguous
     538        fits_write_img(fits->p_fd,
     539                       dataType,              // datatype
     540                       firstPixel,                     // writing to the first z-plane
     541                       numCols*numRows,       // number of elements to write, i.e., the whole image
     542                       input->data.V[0],      // the data
     543                       &status);
     544    } else { // image data may not be contiguous; write one row at a time
     545        for (int row = 0; row < numRows; row++) {
     546            fits_write_img(fits->p_fd,
     547                           dataType,          // datatype
     548                           firstPixel,
     549                           numCols,           // number of elements to write, i.e., one row's worth
     550                           input->data.V[row],// the raw row data
     551                           &status);
     552            firstPixel += numCols;  // move to next row
     553        }
     554    }
    577555
    578556    if ( status != 0) {
     
    589567}
    590568
     569bool psFitsWriteHeader(psMetadata* header,
     570                       psFits* fits)
     571{
     572
     573    if (fits == NULL) {
     574        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     575                PS_ERRORTEXT_psFits_NULL);
     576        return false;
     577    }
     578
     579    if (header == NULL) {
     580        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     581                PS_ERRORTEXT_psFits_METADATA_NULL);
     582        return false;
     583    }
     584
     585
     586    return true;
     587}
     588
    591589psMetadata* psFitsReadTableRow(psFits* fits,
    592590                               int row)
    593 {
    594 }
     591{}
    595592
    596593psArray* psFitsReadTableColumn(psFits* fits,
    597594                               const char* colname)
    598 {
    599 }
     595{}
    600596
    601597psVector* psFitsReadTableColumnNum(psFits* fits,
    602598                                   const char* colname)
    603 {
    604 }
     599{}
    605600
    606601
    607602psArray* psFitsReadTable(psFits* fits)
    608 {
    609 }
     603{}
    610604
    611605bool psFitsWriteTable(psFits* fits,
    612606                      psArray* table)
    613 {
    614 }
     607{}
Note: See TracChangeset for help on using the changeset viewer.