Changeset 15174
- Timestamp:
- Oct 3, 2007, 10:16:49 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_070920/psLib/src/fits/psFitsHeader.c
r15168 r15174 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.34.4. 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-10-03 03:01:45$9 * @version $Revision: 1.34.4.6 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-10-03 20:16:49 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 72 72 PS_ASSERT_FITS_NON_NULL(fits, false); 73 73 74 if (!fits->comp ression) {74 if (!fits->compConvention) { 75 75 // User has turned off compression conventions; doesn't want any nasty surprises 76 76 return false; … … 90 90 int status = 0; // CFITSIO status 91 91 fits_get_hdrspace(fits->fd, &numKeys, 0, &status); 92 if (numKeys > =NUM_EMPTY_KEYS) {92 if (numKeys > NUM_EMPTY_KEYS) { 93 93 return false; 94 94 } … … 140 140 141 141 return false; 142 } 143 144 char *p_psFitsHeaderParseString(char *string) 145 { 146 if (!string || strlen(string) == 0) { 147 return string; 148 } 149 150 char *fixed = string; // Fixed version of the string 151 // remove the single-quotes at front/end 152 if (fixed[0] == '\'' && fixed[strlen(string)-1] == '\'') { 153 string[strlen(string)-1] = '\0'; // Remove the trailing quote 154 fixed += 1; // Advance past the leading quote 155 } 156 // Remove trailing spaces, which are not significant, according to the FITS standard 157 // http://archive.stsci.edu/fits/fits_standard/node31.html 158 char *lastSpace = NULL; // The last space in the string 159 while (strlen(fixed) > 1 && (lastSpace = strrchr(fixed, ' ')) && lastSpace[1] == '\0') { 160 // This is a trailing space, not a leading space. 161 lastSpace[0] = '\0'; // Truncate the string here 162 } 163 164 return fixed; 142 165 } 143 166 … … 217 240 break; 218 241 case 'C': { 219 char *keyValueFixed = keyValue; // Fixed version of the string 220 // remove the single-quotes at front/end 221 if (keyValueFixed[0] == '\'' && keyValueFixed[strlen(keyValue)-1] == '\'') { 222 keyValue[strlen(keyValue)-1] = '\0'; // Remove the trailing quote 223 keyValueFixed += 1; // Advance past the leading quote 224 } 225 // Remove trailing spaces, which are not significant, according to the FITS standard 226 // http://archive.stsci.edu/fits/fits_standard/node31.html 227 char *lastSpace = NULL; // The last space in the string 228 while (strlen(keyValueFixed) > 1 && (lastSpace = strrchr(keyValueFixed, ' ')) && 229 lastSpace[1] == '\0') { 230 // This is a trailing space, not a leading space. 231 lastSpace[0] = '\0'; // Truncate the string here 232 } 233 234 // Need to trap NAN, INF and -INF written by psFitsWriteHeader. 235 // cfitsio won't write these, so we write them as strings, and then have to trap them on read. 236 if (strcasecmp(keyValueFixed, "NAN") == 0) { 237 success = psMetadataAddF32(header, PS_LIST_TAIL, keyName, dupFlag, keyComment, NAN); 238 } else if (strcasecmp(keyValueFixed, "INF") == 0) { 239 success = psMetadataAddF32(header, PS_LIST_TAIL, keyName, dupFlag, keyComment, INFINITY); 240 } else if (strcasecmp(keyValueFixed, "-INF") == 0) { 241 success = psMetadataAddF32(header, PS_LIST_TAIL, keyName, dupFlag, keyComment, -INFINITY); 242 } else { 243 success = psMetadataAddStr(header, PS_LIST_TAIL, keyName, dupFlag, keyComment, 244 keyValueFixed); 245 } 246 break; 242 char *keyValueFixed = p_psFitsHeaderParseString(keyValue); // Fixed version of the string 243 244 // Need to trap NAN, INF and -INF written by psFitsWriteHeader. 245 // cfitsio won't write these, so we write them as strings, and then have to trap them on read. 246 if (strcasecmp(keyValueFixed, "NAN") == 0) { 247 success = psMetadataAddF32(header, PS_LIST_TAIL, keyName, dupFlag, keyComment, NAN); 248 } else if (strcasecmp(keyValueFixed, "INF") == 0) { 249 success = psMetadataAddF32(header, PS_LIST_TAIL, keyName, dupFlag, keyComment, INFINITY); 250 } else if (strcasecmp(keyValueFixed, "-INF") == 0) { 251 success = psMetadataAddF32(header, PS_LIST_TAIL, keyName, dupFlag, keyComment, -INFINITY); 252 } else if (!fits->compConvention || 253 (strcmp(keyName, "EXTNAME") != 0 || strcmp(keyValueFixed, "COMPRESSED_IMAGE") != 0)) { 254 // Ignore EXTNAME=COMPRESSED_IMAGE if compression convention is to be respected 255 success = psMetadataAddStr(header, PS_LIST_TAIL, keyName, dupFlag, keyComment, 256 keyValueFixed); 247 257 } 258 break; 259 } 248 260 case 'L': { 249 bool temp = (keyValue[0] == 'T') ? 1 : 0;250 success = psMetadataAddBool(header, PS_LIST_TAIL, keyName, dupFlag, keyComment, temp);251 break;252 }261 bool temp = (keyValue[0] == 'T') ? 1 : 0; 262 success = psMetadataAddBool(header, PS_LIST_TAIL, keyName, dupFlag, keyComment, temp); 263 break; 264 } 253 265 default: 254 266 psError(PS_ERR_IO, true, _("Specified FITS metadata type, %c, is not supported."), keyType);
Note:
See TracChangeset
for help on using the changeset viewer.
