IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 17, 2014, 10:14:43 AM (12 years ago)
Author:
eugene
Message:

distinguish "byte" and "char" column fields (char is interpretted as a string)

File:
1 edited

Legend:

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

    r35101 r37039  
    8181  Pin = data;
    8282  Pout = array;
     83  // does it makes sense to scale 'char' data?
    8384  if (!strcmp (type, "char")) {
     85    for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) {
     86      *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
     87    }
     88  }
     89  if (!strcmp (type, "byte")) {
    8490    for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) {
    8591      *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
     
    221227  Pout = array;
    222228
     229  // # define ASSIGN_DATA(ITYPE,INAME,ISIZE,OTYPE,ONAME)
     230  // if (!strcmp (intype, #ITYPE)) {
     231
    223232  /** input == char **/
    224233  if (!strcmp (outtype, "char") && !strcmp (intype, "char")) {
     
    228237    }
    229238  }
     239  if (!strcmp (outtype, "byte") && !strcmp (intype, "char")) {
     240    int NbytesIn = 1;
     241    for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {
     242      *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
     243    }
     244  }
    230245  if (!strcmp (outtype, "short") && !strcmp (intype, "char")) {
    231246    int NbytesIn = 1;
     
    265280  }
    266281  if (!strcmp (outtype, "double") && !strcmp (intype, "char")) {
     282    int NbytesIn = 1;
     283    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
     284      *(double *)Pout = (*(char *)Pin - Bzero) / Bscale;
     285# ifdef BYTE_SWAP
     286      SWAP_DBLE;
     287# endif
     288    }
     289  }
     290
     291  /** input == byte **/
     292  if (!strcmp (outtype, "char") && !strcmp (intype, "byte")) {
     293    int NbytesIn = 1;
     294    for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {
     295      *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
     296    }
     297  }
     298  if (!strcmp (outtype, "byte") && !strcmp (intype, "byte")) {
     299    int NbytesIn = 1;
     300    for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {
     301      *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
     302    }
     303  }
     304  if (!strcmp (outtype, "short") && !strcmp (intype, "byte")) {
     305    int NbytesIn = 1;
     306    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
     307      *(short *)Pout = (*(char *)Pin - Bzero) / Bscale;
     308# ifdef BYTE_SWAP
     309      SWAP_BYTE;
     310# endif
     311    } 
     312  }
     313  if (!strcmp (outtype, "int") && !strcmp (intype, "byte")) {
     314    int NbytesIn = 1;
     315    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
     316      *(int *)Pout = (*(char *)Pin - Bzero) / Bscale;
     317# ifdef BYTE_SWAP
     318      SWAP_WORD;
     319# endif
     320    }
     321  }
     322  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "byte")) {
     323    int NbytesIn = 1;
     324    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
     325      *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale;
     326# ifdef BYTE_SWAP
     327      SWAP_DBLE;
     328# endif
     329    }
     330  }
     331  if (!strcmp (outtype, "float") && !strcmp (intype, "byte")) {
     332    int NbytesIn = 1;
     333    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
     334      *(float *)Pout = (*(char *)Pin - Bzero) / Bscale;
     335# ifdef BYTE_SWAP
     336      SWAP_WORD;
     337# endif
     338    }
     339  }
     340  if (!strcmp (outtype, "double") && !strcmp (intype, "byte")) {
    267341    int NbytesIn = 1;
    268342    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
     
    281355    }
    282356  }
     357  if (!strcmp (outtype, "byte") && !strcmp (intype, "short")) {
     358    int NbytesIn = 2;
     359    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
     360      *(char *)Pout = (*(short *)Pin - Bzero) / Bscale;
     361    }
     362  }
    283363  if (!strcmp (outtype, "short") && !strcmp (intype, "short")) {
    284364    int NbytesIn = 2;
     
    334414    }
    335415  }
     416  if (!strcmp (outtype, "byte") && !strcmp (intype, "int")) {
     417    int NbytesIn = 4;
     418    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
     419      *(char *)Pout = (*(int *)Pin - Bzero) / Bscale;
     420    }
     421  }
    336422  if (!strcmp (outtype, "short") && !strcmp (intype, "int")) {
    337423    int NbytesIn = 4;
     
    387473    }
    388474  }
     475  if (!strcmp (outtype, "byte") && !strcmp (intype, "int64_t")) {
     476    int NbytesIn = 8;
     477    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
     478      *(char *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
     479    }
     480  }
    389481  if (!strcmp (outtype, "short") && !strcmp (intype, "int64_t")) {
    390482    int NbytesIn = 8;
     
    440532    }
    441533  }
     534  if (!strcmp (outtype, "byte") && !strcmp (intype, "float")) {
     535    int NbytesIn = 4;
     536    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
     537      *(char *)Pout = (*(float *)Pin - Bzero) / Bscale;
     538    }
     539  }
    442540  if (!strcmp (outtype, "short") && !strcmp (intype, "float")) {
    443541    int NbytesIn = 4;
     
    488586  /** input == double **/
    489587  if (!strcmp (outtype, "char") && !strcmp (intype, "double")) {
     588    int NbytesIn = 8;
     589    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
     590      *(char *)Pout = (*(double *)Pin - Bzero) / Bscale;
     591    }
     592  }
     593  if (!strcmp (outtype, "byte") && !strcmp (intype, "double")) {
    490594    int NbytesIn = 8;
    491595    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
Note: See TracChangeset for help on using the changeset viewer.