Changeset 38425
- Timestamp:
- Jun 7, 2015, 11:42:53 AM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/libfits
- Files:
-
- 1 added
- 7 edited
-
Makefile (modified) (1 diff)
-
matrix/F_matrix.c (modified) (4 diffs)
-
table/F_table_varlength.c (modified) (2 diffs)
-
table/F_uncompress_T.c (modified) (1 diff)
-
table/F_write_T.c (modified) (8 diffs)
-
table/F_write_TH.c (modified) (2 diffs)
-
test/compress.sh (modified) (3 diffs)
-
test/tcomptiming.c (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/Makefile
r38418 r38425 27 27 28 28 # zlib 29 TESTPROG = imagecomp tablecomp ricetest29 TESTPROG = imagecomp tablecomp tcomptiming ricetest 30 30 $(TESTPROG) : % : $(TESTBIN)/% 31 31 test: $(TESTPROG) -
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_matrix.c
r38329 r38425 1 1 # include <ohana.h> 2 2 # include <gfitsio.h> 3 4 off_t gfits_data_size (Header *header) {5 6 int i;7 off_t Nrec, size;8 9 if (header[0].Naxes == 0) return (0);10 11 size = abs(header[0].bitpix / 8);12 13 for (i = 0; i < header[0].Naxes; i++)14 size *= header[0].Naxis[i];15 16 // XXX do I multiply this times gcount?17 size += header[0].pcount;18 19 /* round up to next complete block */20 if (size % FT_RECORD_SIZE) {21 Nrec = 1 + (int) (size / FT_RECORD_SIZE);22 size = FT_RECORD_SIZE * Nrec;23 }24 25 return (size);26 }27 3 28 4 off_t gfits_heap_start (Header *header) { … … 43 19 off_t gfits_data_min_size (Header *header) { 44 20 45 int i;46 off_t size;21 off_t size = gfits_heap_start (header); 22 size += header[0].pcount; 47 23 48 if (header[0].Naxes == 0) return (0); 49 50 size = abs(header[0].bitpix / 8); 51 52 for (i = 0; i < header[0].Naxes; i++) 53 size *= header[0].Naxis[i]; 54 55 // XXX do I multiply this times gcount? 56 size += header[0].pcount; 24 // XXX what do I do with gcount? 57 25 58 26 return (size); … … 61 29 off_t gfits_data_pad_size (off_t rawsize) { 62 30 63 off_t Nrec, size; 64 65 size = rawsize; 31 off_t size = rawsize; 66 32 67 33 /* round up to next complete block */ 68 34 if (rawsize % FT_RECORD_SIZE) { 69 Nrec = 1 + (int) (rawsize / FT_RECORD_SIZE);35 off_t Nrec = 1 + (int) (rawsize / FT_RECORD_SIZE); 70 36 size = FT_RECORD_SIZE * Nrec; 71 37 } … … 73 39 return (size); 74 40 } 41 42 off_t gfits_data_size (Header *header) { 43 off_t rawsize = gfits_data_min_size(header); 44 off_t size = gfits_data_pad_size (rawsize); 45 46 return (size); 47 } 48 -
branches/eam_branches/ohana.20150429/src/libfits/table/F_table_varlength.c
r38342 r38425 157 157 158 158 // extend the buffer size to add the new data 159 off_t Nbytes = heap_offset + Ndata;159 off_t Nbytes = gfits_data_pad_size (heap_offset + Ndata); 160 160 REALLOCATE (table->buffer, char, Nbytes); 161 161 … … 198 198 table->header->pcount = pcount; 199 199 table->datasize = gfits_data_size (table->header); 200 myAssert (table->datasize == Nbytes, "inconsistent header and data"); 200 201 201 202 return TRUE; -
branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c
r38418 r38425 179 179 180 180 // allocate the intermediate storage buffers 181 int Nraw_alloc = max_width*ztilelen + 100 ;181 int Nraw_alloc = max_width*ztilelen + 1000; 182 182 ALLOCATE (raw, char, Nraw_alloc); 183 183 ALLOCATE (zdata, char, max_width*ztilelen); -
branches/eam_branches/ohana.20150429/src/libfits/table/F_write_T.c
r38329 r38425 14 14 15 15 status = fseeko (f, 0LL, SEEK_END); /* write table to end of file! */ 16 if (status) { perror ("fseeko: "); return (FALSE); } 16 17 status = gfits_fwrite_table (f, table); 17 18 … … 26 27 27 28 Nbytes = fwrite (table[0].buffer, sizeof(char), table[0].datasize, f); 28 29 if (Nbytes != table[0].datasize) return (FALSE); 29 if (Nbytes != table[0].datasize) { perror ("fwrite: "); return (FALSE); } 30 30 return (TRUE); 31 31 } … … 45 45 /* file pointer is at beginning of desired table data */ 46 46 start = ftello (f); 47 if (start < 0) { perror ("ftello: "); return FALSE; } 47 48 48 49 for (i = 0; i < Nrow; i++) { … … 50 51 fseeko (f, offset, SEEK_SET); 51 52 Nbytes = fwrite (table[0].buffer[i], sizeof (char), Nx, f); 52 if (Nbytes != Nx) { return (FALSE); }53 if (Nbytes != Nx) { perror ("fwrite: "); return (FALSE); } 53 54 } 54 55 … … 58 59 59 60 offset = start + Nx*Ny; 60 fseeko (f, offset, SEEK_SET); 61 int status = fseeko (f, offset, SEEK_SET); 62 if (status) { perror ("fseeko: "); return FALSE; } 63 61 64 Nbytes = fwrite (pad, sizeof (char), Npad, f); 62 if (Nbytes != Npad) { return (FALSE); }65 if (Nbytes != Npad) { perror ("fwrite: "); return (FALSE); } 63 66 free (pad); 64 67 … … 97 100 // cursor must be at start of the table (after table header) 98 101 if (fseeko (f, Nskip, SEEK_CUR)) { 102 perror ("fseeko: "); 99 103 fprintf (stderr, "can't seek table start\n"); 100 104 return (FALSE); … … 102 106 103 107 Nwrite = fwrite (ftable[0].buffer, sizeof (char), Nbytes, f); 104 if (Nwrite != Nbytes) { 105 return (FALSE); 106 } 108 if (Nwrite != Nbytes) { perror ("fwrite: "); return (FALSE); } 107 109 108 110 if (Ntotal >= Ndisk) { … … 113 115 free (pad); 114 116 115 if (Nbytes != Npad) return (FALSE);117 if (Nbytes != Npad) { perror ("fwrite: "); return (FALSE); } 116 118 } 117 119 -
branches/eam_branches/ohana.20150429/src/libfits/table/F_write_TH.c
r27435 r38425 14 14 15 15 status = fseeko (f, 0LL, SEEK_END); /* write header to end of file! */ 16 if (status) { perror ("fseeko: "); return (FALSE); } 16 17 status = gfits_fwrite_Theader (f, header); 17 18 … … 26 27 27 28 Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].datasize, f); 29 if (Nbytes != header[0].datasize) { perror ("fwrite: "); return (FALSE); } 28 30 29 if (Nbytes != header[0].datasize) return (FALSE);30 31 return (TRUE); 31 32 } -
branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh
r38418 r38425 1 1 input tap.dvo 2 3 macro tests 4 test_image_all 5 test_table_all_rnd 6 end 2 7 3 8 macro test_image_all … … 308 313 end 309 314 310 311 315 macro test_table_all_rnd 312 316 … … 334 338 # lrnd generates rnd int between 0 and 0x7fffff (2^31 - 1 inclusive) 335 339 336 $NPT = 1000 340 $NPT = 1000000 337 341 # $NPT = 30 338 342 create ni 0 $NPT -int
Note:
See TracChangeset
for help on using the changeset viewer.
