Changeset 15487 for trunk/Ohana/src/libfits/table/F_create_TH.c
- Timestamp:
- Nov 6, 2007, 5:09:52 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libfits/table/F_create_TH.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/table/F_create_TH.c
r7054 r15487 1 1 # include <ohana.h> 2 2 # include <gfitsio.h> 3 # define NBYTES 2880 3 4 4 5 /* a basic table header (extension) is different from a primary header … … 12 13 char axis[10]; 13 14 14 header[0].size = 2880; 15 ALLOCATE (header[0].buffer, char, 2880); 15 header[0].size = NBYTES; 16 17 ALLOCATE (header[0].buffer, char, NBYTES); 16 18 17 for (i = 0; i < 2880; i++)19 for (i = 0; i < NBYTES; i++) 18 20 header[0].buffer[i] = ' '; 19 21 strncpy (header[0].buffer, "END", 3); 20 22 21 23 gfits_modify (header, "XTENSION", "%s", 1, type); 22 gfits_modify (header, "BITPIX", "%d", 1, header[0].bitpix);23 gfits_modify (header, "NAXIS", "%d", 1, header[0].Naxes);24 gfits_modify (header, "BITPIX", "%d", 1, header[0].bitpix); 25 gfits_modify (header, "NAXIS", "%d", 1, header[0].Naxes); 24 26 25 27 for (i = 0; i < header[0].Naxes; i++) { … … 28 30 } 29 31 30 /* PCOUNT & GCOUNT are not implemented, but they are required to be here */ 31 gfits_modify (header, "PCOUNT", "%d", 1, 0); 32 gfits_modify (header, "GCOUNT", "%d", 1, 1); 32 gfits_modify (header, "PCOUNT", "%d", 1, header[0].pcount); 33 gfits_modify (header, "GCOUNT", "%d", 1, header[0].gcount); 33 34 if (!strcmp (type, "IMAGE")) { 34 35 gfits_modify (header, "BSCALE", "%lf", 1, header[0].bscale); … … 43 44 44 45 int i, valid; 45 char axis[10];46 46 47 47 /* check valid table types */ … … 51 51 if (!valid) return (FALSE); 52 52 53 /* create empty header buffer */ 54 header[0].size = 2880; 55 ALLOCATE (header[0].buffer, char, 2880); 56 57 for (i = 0; i < 2880; i++) 58 header[0].buffer[i] = ' '; 59 strncpy (header[0].buffer, "END", 3); 53 gfits_init_header (header); 60 54 61 /* a table has BITPIX = 8, NAXIS = 2 */62 55 header[0].simple = FALSE; 63 header[0].unsign = FALSE;64 header[0].extend = FALSE;65 header[0].bitpix = 8;66 header[0].bscale = 1;67 header[0].bzero = 0;68 56 header[0].Naxes = 2; 69 57 for (i = 0; i < FT_MAX_NAXES; i++) 70 58 header[0].Naxis[i] = 0; 71 72 /* required keywords */ 73 gfits_modify (header, "XTENSION", "%s", 1, type); 74 gfits_modify (header, "BITPIX", "%d", 1, header[0].bitpix); 75 gfits_modify (header, "NAXIS", "%d", 1, header[0].Naxes); 76 77 for (i = 0; i < header[0].Naxes; i++) { 78 sprintf (axis, "NAXIS%d", i + 1); 79 gfits_modify (header, axis, "%d", 1, header[0].Naxis[i], 1); 80 } 81 82 /* PCOUNT & GCOUNT are not implemented, but they are required to be here */ 83 gfits_modify (header, "PCOUNT", "%d", 1, 0); 84 gfits_modify (header, "GCOUNT", "%d", 1, 1); 85 if (!strcmp (type, "IMAGE")) { 86 gfits_modify (header, "BSCALE", "%lf", 1, header[0].bscale); 87 gfits_modify (header, "BZERO", "%lf", 1, header[0].bzero); 88 } 59 60 gfits_create_Theader (header, type); 89 61 90 62 gfits_modify (header, "TFIELDS", "%d", 1, 0);
Note:
See TracChangeset
for help on using the changeset viewer.
