Changeset 15487 for trunk/Ohana/src/opihi/cmd.data/rd.c
- Timestamp:
- Nov 6, 2007, 5:09:52 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/rd.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/rd.c
r13479 r15487 5 5 6 6 int i, N, status, plane, Nplane, extend, Nextend, Nskip, JustHead; 7 int ccdsel, done ;7 int ccdsel, done, Nword, IsCompressed; 8 8 char region[512], *ccdid, *filename; 9 9 FILE *f; … … 85 85 return (FALSE); 86 86 } 87 if (gfits_extension_is_compressed (&buf[0].header)) { 88 IsCompressed = TRUE; 89 } 87 90 } 91 88 92 /* FITS extension by name */ 89 93 if (ccdsel) { … … 92 96 CCDKeyword = get_variable ("CCDKEYWORD"); 93 97 if (CCDKeyword == (char *) NULL) { 94 gprint (GP_ERR, "CCDKEYWORD variable is not set; ");95 gprint (GP_ERR, "using EXTNAME as default\n");98 // gprint (GP_ERR, "CCDKEYWORD variable is not set; "); 99 // gprint (GP_ERR, "using EXTNAME as default\n"); 96 100 CCDKeyword = strcreate ("EXTNAME"); 97 101 } … … 106 110 return (FALSE); 107 111 } 108 if (!gfits_scan (&buf[0].header, CCDKeyword, "%s", 1, ID)) { 112 113 // for compressed data tables, EXTNAME may be duplicated, with the first one containing the 114 // word 'COMPRESSED_IMAGE'. in this case, check the second EXTNAME, if CCDKeyword == EXTNAME 115 // this may have to be a more obscure test specifically for 'imcopy' data... 116 // need to check each header, since file may contain a mix 117 118 Nword = 1; 119 IsCompressed = FALSE; 120 if (gfits_extension_is_compressed (&buf[0].header)) { 121 if (!strcmp (CCDKeyword, "EXTNAME")) Nword = 2; 122 IsCompressed = TRUE; 123 } 124 if (!gfits_scan (&buf[0].header, CCDKeyword, "%s", Nword, ID)) { 109 125 gprint (GP_ERR, "%s not in header\n", CCDKeyword); 110 126 DeleteBuffer (buf); … … 123 139 /* fix up header, if needed */ 124 140 if (extend || ccdsel) { 125 static char simple[] = "SIMPLE = T / Standard FITS"; 126 int Ns, No; 127 128 Ns = strlen (simple); 129 No = 80 - Ns; 130 strncpy (buf[0].header.buffer, simple, Ns); 131 memset (&buf[0].header.buffer[Ns], ' ', No); 141 if (!IsCompressed) { 142 gfits_extended_to_primary (&buf[0].header, TRUE, "Standard FITS"); 143 } 132 144 } else { 133 145 gfits_fread_header (f, &buf[0].header); … … 135 147 136 148 /* for JustHead, we skip reading the data segment */ 149 // XXX for compressed data, we need to convert the header to the equivalent uncompressed version 137 150 if (JustHead) { 138 / * should be in CreateMatrix / CreateBuffer function */151 // XXX what are we doing here exactly? 139 152 buf[0].header.Naxes = 0; 140 153 ALLOCATE (buf[0].matrix.buffer, char, 1); … … 164 177 165 178 /* load matrix data */ 166 sprintf (region, "-1 -1 -1 -1 %d %d", (plane - 1), plane); 167 status = gfits_fread_matrix_segment (f, &buf[0].matrix, &buf[0].header, region); 168 fclose (f); 179 if (IsCompressed) { 180 FTable ftable; 181 Header theader; 182 ftable.header = &theader; 183 gfits_copy_header (&buf[0].header, ftable.header); 184 status = gfits_fread_ftable_data (f, &ftable); // XXX does this do more than read the bytes? 185 status = gfits_uncompress_image (&buf[0].header, &buf[0].matrix, &ftable, !(ccdsel || extend)); 186 gfits_free_table (&ftable); 187 // XXX this currently does not work for a cube (we get a cube back, not a specific plane) 188 } else { 189 sprintf (region, "-1 -1 -1 -1 %d %d", (plane - 1), plane); 190 status = gfits_fread_matrix_segment (f, &buf[0].matrix, &buf[0].header, region); 191 fclose (f); 192 } 169 193 170 194 if (!status) {
Note:
See TracChangeset
for help on using the changeset viewer.
