IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26713


Ignore:
Timestamp:
Jan 28, 2010, 4:42:38 PM (16 years ago)
Author:
eugene
Message:

updates from the trunk

Location:
branches/eam_branches/20091201/Ohana/src/libfits/table
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/Ohana/src/libfits/table/F_define_column.c

    r7054 r26713  
    2323  sprintf (field, "TFORM%d", Nfields);
    2424  gfits_modify (header, field, "%s", 1, format);
    25   sprintf (field, "TSCAL%d", Nfields);
    26   gfits_modify (header, field, "%lf", 1, bscale);
    27   sprintf (field, "TZERO%d", Nfields);
    28   gfits_modify (header, field, "%lf", 1, bzero);
     25
     26  // add scaling parameters unless they amount to a noop
     27  if ((bscale != 1.0) || (bzero != 0.0)) {
     28      sprintf (field, "TSCAL%d", Nfields);
     29      gfits_modify (header, field, "%lf", 1, bscale);
     30      sprintf (field, "TZERO%d", Nfields);
     31      gfits_modify (header, field, "%lf", 1, bzero);
     32  }
    2933
    3034  /* update TFIELDS & NAXIS1 */
  • branches/eam_branches/20091201/Ohana/src/libfits/table/F_get_column.c

    r16810 r26713  
    11# include <ohana.h>
    22# include <gfitsio.h>
     3#include <inttypes.h>
    34# define SWAP_BYTE { \
    45  char tmp; \
     
    9394    }
    9495  }
     96  if (!strcmp (type, "int64_t")) {
     97    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
     98# ifdef BYTE_SWAP
     99      SWAP_DBLE;
     100# endif
     101      *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
     102    }
     103  }
    95104  if (!strcmp (type, "float")) {
    96105    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
     
    218227# endif
    219228      *(int *)Pout = *(int *)Pin*Bscale + Bzero;
     229    }
     230  }
     231  if (!strcmp (type, "int64_t")) {
     232    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
     233# ifdef BYTE_SWAP
     234      SWAP_DBLE;
     235# endif
     236      *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
    220237    }
    221238  }
     
    349366    }
    350367  }
     368  if (!strcmp (type, "int64_t")) {
     369    ALLOCATE (array, char, Ny*8);
     370    Pout = array;
     371    for (i = 0; i < Ny; i++, Pin+=Nx, Pout+=8) {
     372      memcpy (line, Pin, Nval*Nbytes);
     373      sscanf (line, "%" PRId64, (int64_t *)Pout);
     374    }
     375  }
    351376  if (!strcmp (type, "float")) {
    352377    ALLOCATE (array, char, Ny*4);
  • branches/eam_branches/20091201/Ohana/src/libfits/table/F_table_format.c

    r15487 r26713  
    1717
    1818  *Nbytes = 0;
    19   if (*Fchar == 'X') { *Nbytes = 1;  strcpy (type, "char");   *Nval = 1 + (int) Nv / 8; }
    20   if (*Fchar == 'L') { *Nbytes = 1;  strcpy (type, "char");   *Nval = Nv;               }
    21   if (*Fchar == 'A') { *Nbytes = 1;  strcpy (type, "char");   *Nval = Nv;               }
    22   if (*Fchar == 'B') { *Nbytes = 1;  strcpy (type, "char");   *Nval = Nv;               }
    23   if (*Fchar == 'I') { *Nbytes = 2;  strcpy (type, "short");  *Nval = Nv;               }
    24   if (*Fchar == 'J') { *Nbytes = 4;  strcpy (type, "int");    *Nval = Nv;               }
    25   if (*Fchar == 'E') { *Nbytes = 4;  strcpy (type, "float");  *Nval = Nv;               }
    26   if (*Fchar == 'D') { *Nbytes = 8;  strcpy (type, "double"); *Nval = Nv;               }
    27   if (*Fchar == 'P') { *Nbytes = 8;  strcpy (type, "var");    *Nval = 2*Nv;             }
    28   if (*Fchar == 'C') { *Nbytes = 8;  strcpy (type, "float");  *Nval = 2*Nv;             }
    29   if (*Fchar == 'M') { *Nbytes = 16; strcpy (type, "double"); *Nval = 2*Nv;             }
    30   if (!*Nbytes) { return (FALSE); }
     19  switch (*Fchar) {
     20  case  'X':
     21    { *Nbytes = 1;  strcpy (type, "char");   *Nval = 1 + (int) Nv / 8; }
     22    break;
     23  case  'L':
     24    { *Nbytes = 1;  strcpy (type, "char");   *Nval = Nv;               }
     25    break;
     26  case  'A':
     27    { *Nbytes = 1;  strcpy (type, "char");   *Nval = Nv;               }
     28    break;
     29  case  'B':
     30    { *Nbytes = 1;  strcpy (type, "char");   *Nval = Nv;               }
     31    break;
     32  case  'I':
     33    { *Nbytes = 2;  strcpy (type, "short");  *Nval = Nv;               }
     34    break;
     35  case  'J':
     36    { *Nbytes = 4;  strcpy (type, "int");    *Nval = Nv;               }
     37    break;
     38  case  'K':
     39    { *Nbytes = 8;  strcpy (type, "int64_t"); *Nval = Nv;              }
     40    break;
     41  case  'E':
     42    { *Nbytes = 4;  strcpy (type, "float");  *Nval = Nv;               }
     43    break;
     44  case  'D':
     45    { *Nbytes = 8;  strcpy (type, "double"); *Nval = Nv;               }
     46    break;
     47  case  'P':
     48    { *Nbytes = 8;  strcpy (type, "var");    *Nval = 2*Nv;             }
     49    break;
     50  case  'C':
     51    { *Nbytes = 8;  strcpy (type, "float");  *Nval = 2*Nv;             }
     52    break;
     53  case  'M':
     54    { *Nbytes = 16; strcpy (type, "double"); *Nval = 2*Nv;             }
     55    break;
     56  default:
     57    return (FALSE);
     58  }
    3159
    3260  return (TRUE);
     
    3967   I - 16 bit int
    4068   J - 32 bit int
     69   K - 64 bit int
    4170   A - char
    4271   E - float
     
    199228  short *tmpShort;
    200229  int *tmpInt;
     230  int64_t *tmpInt64;
    201231
    202232  off = 0;
     
    229259        continue;
    230260    }
     261    if ((tscale == 1.0) && (tzero == 0.0)) {
     262        off += Nchar;
     263        continue;
     264    }
    231265
    232266    if (!strcmp (type, "char"))   {
     
    252286          *tmpInt = *tmpInt * tscale + tzero;
    253287        }
     288      }
     289    }
     290    if (!strcmp (type, "int64_t"))   {
     291      for (j = 0; j < Ny; j++) {
     292        for (n = 0; n < Nval; n++) {
     293          tmpInt64 = (int64_t *)&ftable[0].buffer[j*Nx + n*Nbytes + off];
     294          *tmpInt64 = *tmpInt64 * tscale + tzero;
     295        }
    254296      }
    255297    }
     
    269311  short *tmpShort;
    270312  int *tmpInt;
     313  int64_t *tmpInt64;
    271314
    272315  off = 0;
     
    299342        continue;
    300343    }
     344    if ((tscale == 1.0) && (tzero == 0.0)) {
     345        off += Nchar;
     346        continue;
     347    }
    301348
    302349    if (!strcmp (type, "char"))   {
     
    324371      }
    325372    }
     373    if (!strcmp (type, "int64_t"))   {
     374      for (j = 0; j < Ny; j++) {
     375        for (n = 0; n < Nval; n++) {
     376          tmpInt64 = (int64_t *)&ftable[0].buffer[j*Nx + n*Nbytes + off];
     377          *tmpInt64 = *tmpInt64 * tscale + tzero;
     378        }
     379      }
     380    }
    326381    off += Nchar;
    327382  }
Note: See TracChangeset for help on using the changeset viewer.