Changeset 38441 for trunk/Ohana/src/libfits/table/F_get_column.c
- Timestamp:
- Jun 12, 2015, 6:18:23 PM (11 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/libfits/table/F_get_column.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
-
Property svn:mergeinfo
set to
/branches/eam_branches/ohana.20150429 merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Ohana/src/libfits/table/F_get_column.c
r37039 r38441 17 17 18 18 void *gfits_get_bintable_column_data (Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol) { 19 void *data = gfits_get_bintable_column_data_raw (header, table, label, type, Nrow, Ncol, FALSE); 20 return data; 21 } 22 23 void *gfits_get_bintable_column_data_raw (Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol, char nativeOrder) { 19 24 20 25 off_t Nx, Ny; … … 71 76 } 72 77 73 /* convert data in-situ with correct type, byte swap and Bzero/Bscale */ 78 // NOTE: we have already copied the data to 'array', so the blocks below 79 // only need to swap if this is a direct copy 74 80 Pin = array; 75 81 Pout = array; 82 int directCopy = (Bzero == 0.0) && (Bscale == 1.0); 83 84 /* convert data in-situ with correct type, byte swap and Bzero/Bscale */ 76 85 if (!strcmp (type, "char")) { 77 86 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 78 *(char *)Pout = *(char *)Pin*Bscale + Bzero;87 if (!directCopy) { *(char *)Pout = *(char *)Pin*Bscale + Bzero; } 79 88 } 80 89 } 81 90 if (!strcmp (type, "byte")) { 82 91 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 83 *(char *)Pout = *(char *)Pin*Bscale + Bzero;92 if (!directCopy) { *(char *)Pout = *(char *)Pin*Bscale + Bzero; } 84 93 } 85 94 } … … 87 96 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 88 97 # ifdef BYTE_SWAP 89 SWAP_BYTE;90 # endif 91 *(short *)Pout = *(short *)Pin*Bscale + Bzero;98 if (!nativeOrder) { SWAP_BYTE; } 99 # endif 100 if (!directCopy) { *(short *)Pout = *(short *)Pin*Bscale + Bzero; } 92 101 } 93 102 } … … 95 104 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 96 105 # ifdef BYTE_SWAP 97 SWAP_WORD;98 # endif 99 *(int *)Pout = *(int *)Pin*Bscale + Bzero;106 if (!nativeOrder) { SWAP_WORD; } 107 # endif 108 if (!directCopy) { *(int *)Pout = *(int *)Pin*Bscale + Bzero; } 100 109 } 101 110 } 102 111 if (!strcmp (type, "int64_t")) { 103 if ((Bzero == 0.0) && (Bscale == 1.0)) { 104 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 105 # ifdef BYTE_SWAP 106 SWAP_DBLE; 107 # endif 108 *(int64_t *)Pout = *(int64_t *)Pin; 109 } 110 } else { 111 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 112 # ifdef BYTE_SWAP 113 SWAP_DBLE; 114 # endif 115 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; 116 } 112 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 113 # ifdef BYTE_SWAP 114 if (!nativeOrder) { SWAP_DBLE; } 115 # endif 116 if (!directCopy) { *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; } 117 117 } 118 118 } … … 120 120 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 121 121 # ifdef BYTE_SWAP 122 SWAP_WORD;123 # endif 124 *(float *)Pout = *(float *)Pin*Bscale + Bzero;122 if (!nativeOrder) { SWAP_WORD; } 123 # endif 124 if (!directCopy) { *(float *)Pout = *(float *)Pin*Bscale + Bzero; } 125 125 } 126 126 } … … 128 128 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 129 129 # ifdef BYTE_SWAP 130 SWAP_DBLE; 131 # endif 132 *(double *)Pout = *(double *)Pin*Bscale + Bzero; 133 } 134 } 130 if (!nativeOrder) { SWAP_DBLE; } 131 # endif 132 if (!directCopy) { *(double *)Pout = *(double *)Pin*Bscale + Bzero; } 133 } 134 } 135 136 // check that we supplied a valid type 135 137 136 138 *Ncol = Nval; … … 174 176 if (!gfits_get_bintable_column_type_by_N (header, N, type, Nval)) return FALSE; 175 177 return (TRUE); 178 } 179 180 /***********************/ 181 int gfits_get_bintable_column_raw (Header *header, FTable *table, char *label, void **data, char nativeOrder) { 182 183 char type[16]; 184 off_t Nrow; 185 int Ncol; 186 187 char *array = gfits_get_bintable_column_data_raw (header, table, label, type, &Nrow, &Ncol, nativeOrder); 188 if (array == NULL) return (FALSE); 189 190 *data = array; 191 return TRUE; 176 192 } 177 193
Note:
See TracChangeset
for help on using the changeset viewer.
