- Timestamp:
- May 3, 2010, 8:45:22 AM (16 years ago)
- Location:
- branches/simmosaic_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simmosaic_branches
- Property svn:mergeinfo changed
-
branches/simmosaic_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simmosaic_branches/Ohana/src/tools/src/ftable.c
r16387 r27839 8 8 void list_extnames (char *file); 9 9 void print_layout (Header *header); 10 int ByteSwap (char *ptr, int size, int nitems, char *type);11 10 int Binary; 12 11 13 12 int main (int argc, char **argv) { 14 13 15 int i, N, Nx, Ny, Nbytes, Nread;16 int N extend, Column, Row, ListExtname, Layout;14 off_t i, Nx, Ny, Nbytes, Nread, Row; 15 int N, Nextend, Column, ListExtname, Layout; 17 16 char *Extname, *Colname, *line, ttype[80]; 18 17 FTable table; … … 94 93 exit (1); 95 94 } 96 table. size = Nbytes;97 98 gfits_scan (table.header, "NAXIS1", "% d", 1,&Nx);99 gfits_scan (table.header, "NAXIS2", "% d", 1,&Ny);95 table.datasize = Nbytes; 96 97 gfits_scan (table.header, "NAXIS1", "%lld", 1, (long long *) &Nx); 98 gfits_scan (table.header, "NAXIS2", "%lld", 1, (long long *) &Ny); 100 99 101 100 /* print a column */ … … 122 121 char *print_table_row (char *row, Header *header) { 123 122 124 int i, j, Nx, Nfields, Nbytes, Nvals, Oout, Oin; 123 off_t Nx; 124 int i, j, Nfields, Nbytes, Nvals, Oout, Oin; 125 125 char field[16], type[16], format[16], *line; 126 126 127 gfits_scan (header, "NAXIS1", "% d", 1,&Nx);127 gfits_scan (header, "NAXIS1", "%lld", 1, (long long *) &Nx); 128 128 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 129 129 … … 160 160 161 161 FILE *f; 162 int i, Naxis, Nelem, Ncomp, extend, Nbytes, status; 162 off_t Nbytes, Nelem; 163 int i, Naxis, Ncomp, extend, status; 163 164 char extname[82], exttype[82], axisname[32]; 164 165 Header header; … … 169 170 exit (1); 170 171 } 171 172 /*173 if (!gfits_fread_header (f, &header)) {174 fprintf (stderr, "can't read header from %s\n", file);175 exit (1);176 }177 Nbytes = gfits_data_size (&header);178 fseek (f, Nbytes, SEEK_CUR);179 */180 172 181 173 fprintf (stdout, "%-30s %-15s NAXIS NAXIS(i)...\n", "extname", "datatype"); … … 217 209 for (i = 0; i < Naxis; i++) { 218 210 sprintf (axisname, "NAXIS%d", i+1); 219 status = gfits_scan (&header, axisname, "% d", 1,&Nelem);211 status = gfits_scan (&header, axisname, "%lld", 1, (long long *) &Nelem); 220 212 if (!status) { 221 213 fprintf (stderr, "missing %s\n", axisname); 222 214 } 223 fprintf (stdout, " %7 d",Nelem);215 fprintf (stdout, " %7lld", (long long) Nelem); 224 216 } 225 217 fprintf (stdout, "\n"); … … 228 220 if (Ncomp == 0) { 229 221 extend = FALSE; 230 gfits_scan (&header, "EXTEND", "%t", 1, &extend);222 gfits_scan_alt (&header, "EXTEND", "%t", 1, &extend); 231 223 if (!extend) { 232 224 fprintf (stderr, "no extensions listed in file\n"); … … 235 227 236 228 Nbytes = gfits_data_size (&header); 237 fseek (f, Nbytes, SEEK_CUR);229 fseeko (f, Nbytes, SEEK_CUR); 238 230 239 231 Ncomp ++; … … 245 237 FILE *load_extension (char *file, int Nextend, char *Extname, Header *header) { 246 238 247 int i, extend, Nbytes; 239 off_t Nbytes; 240 int i, extend; 248 241 char extname[82]; 249 242 FILE *f; … … 264 257 /* check for existence of extensions */ 265 258 extend = FALSE; 266 gfits_scan (header, "EXTEND", "%t", 1, &extend);259 gfits_scan_alt (header, "EXTEND", "%t", 1, &extend); 267 260 if (!extend) { 268 261 fprintf (stderr, "no extensions listed in file\n"); … … 271 264 /* skip first data array */ 272 265 Nbytes = gfits_data_size (header); 273 fseek (f, Nbytes, SEEK_CUR);266 fseeko (f, Nbytes, SEEK_CUR); 274 267 275 268 /* search for extension of interest */ … … 281 274 282 275 Nbytes = gfits_data_size (header); 283 fseek (f, Nbytes, SEEK_CUR);276 fseeko (f, Nbytes, SEEK_CUR); 284 277 gfits_free_header (header); 285 278 } … … 292 285 void print_column (FTable *table, int Column, char *Colname) { 293 286 294 int i, j, Nfields, Nstart, Nv, Nb, Nx, Ny; 287 off_t Nx, Ny; 288 int i, j, Nfields, Nstart, Nv, Nb; 295 289 Header *header; 296 290 char format[16], field[16], type[16], *line, *data; … … 300 294 301 295 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 302 gfits_scan (header, "NAXIS1", "% d", 1,&Nx);303 gfits_scan (header, "NAXIS2", "% d", 1,&Ny);296 gfits_scan (header, "NAXIS1", "%lld", 1, (long long *) &Nx); 297 gfits_scan (header, "NAXIS2", "%lld", 1, (long long *) &Ny); 304 298 305 299 if (Colname != (char *) NULL) { … … 362 356 fprintf (stdout, "%d ", *(int *)line); 363 357 } 358 if (!strcmp (type, "int64_t")) { 359 memcpy (line, &data[i*Nv*Nb + Nb*j], Nb); 360 fprintf (stdout, "%lld ", (long long) *(int64_t*)line); 361 } 364 362 if (!strcmp (type, "float")) { 365 363 memcpy (line, &data[i*Nv*Nb + Nb*j], Nb); … … 390 388 sprintf (field, "TTYPE%d", i); 391 389 gfits_scan (header, field, "%s", 1, type); 392 gfits_scan (header, field, "%C", 1, comment);390 gfits_scan_alt (header, field, "%C", 1, comment); 393 391 sprintf (field, "TFORM%d", i); 394 392 gfits_scan (header, field, "%s", 1, format);
Note:
See TracChangeset
for help on using the changeset viewer.
