IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 6, 2007, 5:09:52 PM (19 years ago)
Author:
eugene
Message:

merging changes from eam_branch_20071015 (read compressed images, clean addstar I/O, other minor issues)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libfits/table/F_read_T.c

    r7054 r15487  
    4141
    4242    /* skip to next header */
    43     Nbytes = gfits_matrix_size (header);
     43    Nbytes = gfits_data_size (header);
    4444    fseek (f, Nbytes, SEEK_CUR);
    4545    gfits_free_header (header);
     
    5454
    5555  /* find buffer size */
    56   Nbytes = gfits_matrix_size (table[0].header);
     56  Nbytes = gfits_data_size (table[0].header);
    5757  ALLOCATE (table[0].buffer, char, Nbytes);
    5858
     
    7575  Nx = table[0].header[0].Naxis[0];
    7676  Ny = table[0].header[0].Naxis[1];
    77   table[0].size = gfits_matrix_size (table[0].header);
     77  table[0].size = gfits_data_size (table[0].header);
    7878  table[0].pad = table[0].size - Nx*Ny;
    7979
     
    120120
    121121    /* find buffer size */
    122     Nbytes = gfits_matrix_size (header);
     122    Nbytes = gfits_data_size (header);
    123123
    124124    /* check if this is the correct extension or not */
     
    152152    ALLOCATE (table[0].row, int, MAX (1, Nrow));   
    153153    for (i = 0; i < Nrow; i++) table[0].row[i] = row[i];
    154     table[0].size   = gfits_matrix_size (table[0].header);
     154    table[0].size   = gfits_data_size (table[0].header);
    155155    table[0].pad    = table[0].size - Nx*Ny;
    156156    return (TRUE);
    157157  }
    158158}       
    159 
    160 # if (0)
    161 /*********************** fits read table ***********************************/
    162 /* a poor function: read only the first table, regardless of name */
    163 /* keep until we are sure ohana code does not use it  */
    164 int gfits_read_table (char *filename, FTable *table) {
    165 
    166   FILE *f;
    167   Header header;
    168   int status, i, nbytes, Nbytes, matrix_size;
    169 
    170   if (!gfits_read_header (filename, &header)) {
    171     fprintf (stderr, "error reading header of FITS file %s\n", filename);
    172     return (FALSE);
    173   }
    174 
    175   if (!gfits_read_Theader (filename, &table[0].header)) {
    176     fprintf (stderr, "error reading Theader of FITS file %s\n", filename);
    177     return (FALSE);
    178   }
    179 
    180   if ((f = fopen (filename, "r")) == NULL) {
    181     gfits_free_header (&header);
    182     gfits_free_header (&table[0].header);
    183     return (FALSE);
    184   }
    185 
    186   matrix_size = gfits_matrix_size (&header);
    187 
    188   Nbytes = header.size + matrix_size + table[0].header.size;
    189   fseek (f, Nbytes, 0);
    190   gfits_free_header (&header);
    191  
    192   gfits_scan (&table[0].header, "TFIELDS", "%d", 1, &table[0].Nfields);
    193 
    194   /* place the field sizes in the structure? */
    195   table[0].bitpix = table[0].header.bitpix;
    196   table[0].Naxes  = table[0].header.Naxes;
    197   for (i = 0; i < FT_MAX_NAXES; i++)
    198     table[0].Naxis[i] = table[0].header.Naxis[i];
    199 
    200   Nbytes = gfits_matrix_size (&table[0].header);
    201   ALLOCATE (table[0].buffer, char, Nbytes);
    202   nbytes = fread (table[0].buffer, sizeof(char), Nbytes, f);
    203   if (nbytes != Nbytes) {
    204     fprintf (stderr, "error reading in table data from FITS file %s\n", filename);
    205     fclose (f);
    206     return (FALSE);
    207   }
    208   table[0].size = Nbytes;
    209   fclose (f);
    210   return (TRUE);
    211 }
    212 # endif
    213 
    214159
    215160int gfits_fread_header_extname (FILE *f, Header *header, char *extname) {
     
    223168  if (!strcasecmp (extname, "PHU")) return (TRUE);
    224169
    225   Nbytes = gfits_matrix_size (header);
     170  Nbytes = gfits_data_size (header);
    226171  fseek (f, Nbytes, SEEK_CUR);
    227172
     
    229174    gfits_scan (header, "EXTNAME", "%s", 1, current);
    230175    if (!strcmp (current, extname)) return (TRUE);
    231     Nbytes = gfits_matrix_size (header);
     176    Nbytes = gfits_data_size (header);
    232177    fseek (f, Nbytes, SEEK_CUR);
    233178  }
Note: See TracChangeset for help on using the changeset viewer.