- Timestamp:
- Oct 23, 2007, 10:45:20 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20071015/Ohana/src/opihi/cmd.data/rd.c
r13479 r15353 86 86 } 87 87 } 88 88 89 /* FITS extension by name */ 89 90 if (ccdsel) { … … 92 93 CCDKeyword = get_variable ("CCDKEYWORD"); 93 94 if (CCDKeyword == (char *) NULL) { 94 gprint (GP_ERR, "CCDKEYWORD variable is not set; ");95 gprint (GP_ERR, "using EXTNAME as default\n");95 // gprint (GP_ERR, "CCDKEYWORD variable is not set; "); 96 // gprint (GP_ERR, "using EXTNAME as default\n"); 96 97 CCDKeyword = strcreate ("EXTNAME"); 97 98 } … … 106 107 return (FALSE); 107 108 } 108 if (!gfits_scan (&buf[0].header, CCDKeyword, "%s", 1, ID)) { 109 110 // for compressed data tables, EXTNAME may be duplicated, with the first one containing the 111 // word 'COMPRESSED_IMAGE'. in this case, check the second EXTNAME, if CCDKeyword == EXTNAME 112 // this may have to be a more obscure test specifically for 'imcopy' data... 113 // need to check each header, since file may contain a mix 114 115 Nword = 1; 116 IsCompressed = FALSE; 117 if (gfits_extension_is_compressed_data (&buf[0].header)) { 118 if (!strcmp (CCDKeyword, "EXTNAME")) Nword = 2; 119 IsCompressed = TRUE; 120 } 121 if (!gfits_scan (&buf[0].header, CCDKeyword, "%s", Nword, ID)) { 109 122 gprint (GP_ERR, "%s not in header\n", CCDKeyword); 110 123 DeleteBuffer (buf); … … 123 136 /* fix up header, if needed */ 124 137 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); 138 if (!IsCompressed) { 139 gfits_extended_to_primary (buf[0].header, TRUE, "Standard FITS"); 140 } 132 141 } else { 133 142 gfits_fread_header (f, &buf[0].header); … … 135 144 136 145 /* for JustHead, we skip reading the data segment */ 146 // XXX for compressed data, we need to convert the header to the equivalent uncompressed version 137 147 if (JustHead) { 138 / * should be in CreateMatrix / CreateBuffer function */148 // XXX what are we doing here exactly? 139 149 buf[0].header.Naxes = 0; 140 150 ALLOCATE (buf[0].matrix.buffer, char, 1); … … 164 174 165 175 /* 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); 176 if (IsCompressed) { 177 FTable ftable; 178 Header theader; 179 ftable.header = &theader; 180 gfits_copy_header (&buf[0].header, ftable.header); 181 status = gfits_fread_table (f, &ftable); // XXX does this do more than read the bytes? 182 status = gfits_uncompress_image (&buf[0].header, &buf[0].matrix, ftable, ccdsel || extend); 183 gfits_free_table (&ftable); 184 // XXX this currently does not work for a cube (we get a cube back, not a specific plane) 185 } else { 186 sprintf (region, "-1 -1 -1 -1 %d %d", (plane - 1), plane); 187 status = gfits_fread_matrix_segment (f, &buf[0].matrix, &buf[0].header, region); 188 fclose (f); 189 } 169 190 170 191 if (!status) {
Note:
See TracChangeset
for help on using the changeset viewer.
