- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psLib/src/fits/psFits.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/psLib/src/fits/psFits.c
r25049 r27840 149 149 int thisErrno = errno; // Error number 150 150 char errorBuf[MAX_STRING_LENGTH], *errorMsg; 151 #if (( _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE)151 #if (((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) || __APPLE__) 152 152 strerror_r(thisErrno, errorBuf, MAX_STRING_LENGTH); 153 153 errorMsg = errorBuf; … … 208 208 int thisErrno = errno; 209 209 char errorBuf[64], *errorMsg; 210 # if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE)210 #if (((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) || __APPLE__) 211 211 strerror_r (errno, errorBuf, 64); 212 212 errorMsg = errorBuf; … … 344 344 // Therefore, we implement our own version of moving to an extension specified by name. The pure cfitsio 345 345 // version is used if "conventions.compression" handling is turned off in the psFits structure. 346 bool psFitsMoveExtName(const psFits* fits, 347 const char* extname) 346 static bool fitsMoveExtName(const psFits* fits, // FITS file 347 const char* extname, // Extension name 348 bool errors // Generate errors? 349 ) 348 350 { 349 351 PS_ASSERT_FITS_NON_NULL(fits, false); … … 356 358 // User wants to use cfitsio. Good luck to them! 357 359 if (fits_movnam_hdu(fits->fd, ANY_HDU, (char*)extname, 0, &status) != 0) { 358 psFitsError(status, true, _("Could not find HDU '%s'"), extname); 360 if (errors) { 361 psFitsError(status, true, _("Could not find HDU '%s'"), extname); 362 } 359 363 return false; 360 364 } … … 378 382 if (fits_movabs_hdu(fits->fd, i, &hdutype, &status)) { 379 383 // We've run off the end 380 psFitsError(status, true, _("Could not find HDU with %s = '%s'"), extword, extname); 384 if (errors) { 385 psFitsError(status, true, _("Could not find HDU with %s = '%s'"), extword, extname); 386 } 381 387 return false; 382 388 } … … 406 412 } 407 413 psAbort("Should never reach here."); 414 } 415 416 417 bool psFitsMoveExtName(const psFits* fits, const char* extname) 418 { 419 return fitsMoveExtName(fits, extname, true); 420 } 421 422 bool psFitsMoveExtNameClean(const psFits* fits, const char* extname) 423 { 424 return fitsMoveExtName(fits, extname, false); 408 425 } 409 426 … … 878 895 break; 879 896 897 case PS_TYPE_U64: 898 bitpix = LONGLONG_IMG; 899 bzero = -1.0 * INT64_MIN; 900 datatype = TLONGLONG; 901 break; 902 903 case PS_TYPE_S64: 904 bitpix = LONGLONG_IMG; 905 datatype = TLONGLONG; 906 break; 907 880 908 case PS_TYPE_F32: 881 909 bitpix = FLOAT_IMG; … … 904 932 _("Specified type, %s, is not supported."), 905 933 typeStr); 934 if (bitPix) { 935 *bitPix = 0; 936 } 937 if (dataType) { 938 *dataType = 0; 939 } 940 if (bZero) { 941 *bZero = 0; 942 } 906 943 return false; 907 944 } … … 943 980 return PS_FITS_COMPRESS_NONE; 944 981 } 982 983 984 985 #if 0 986 /// Options for FITS I/O 987 typedef struct { 988 char *extword; ///< user-specified word to name extensions (NULL implies EXTNAME) 989 struct { 990 bool compression; ///< Compression convention: handling of compressed images 991 bool psBitpix; ///< Custom floating-point image 992 } conventions; ///< Conventions to honour 993 // The following options are particular to writing images; they needn't be set for anything else. 994 psFitsFloat floatType; ///< Desired custom floating-point for output images 995 int bitpix; ///< Desired BITPIX for output images; 0 to use as provided 996 psFitsScaling scaling; ///< Scaling scheme to use when quantising floating-point values 997 bool fuzz; ///< Fuzz the values when quantising floating-point values? 998 double bscale, bzero; ///< Manually specified BSCALE and BZERO (for SCALE_MANUAL) 999 double mean, stdev; ///< Mean and standard deviation of image 1000 int stdevBits; ///< Number of bits to sample a standard deviation (for SCALE_STDEV_*) 1001 float stdevNum; ///< Number of standard deviations to pad off the edge 1002 } psFitsOptions; 1003 1004 bool psFitsCopyCompression(psFits *target, psFits *source) 1005 { 1006 PS_ASSERT_FITS_NON_NULL(target, false); 1007 PS_ASSERT_FITS_NON_NULL(source, false); 1008 1009 psMetadata *header = psMetadataReadHeader(NULL, source); // Header of source file 1010 1011 bool mdok; // Status of MD lookup 1012 psString compTypeStr = psMetadataLookupStr(&mdok, header, "ZCMPTYPE"); // Compression type 1013 psFitsCompressionType compType = psFitsCompressionTypeFromString(compTypeStr); // Compression type 1014 1015 if (!target->options) { 1016 target->options = psFitsOptionsAlloc(); 1017 } 1018 1019 target->options->floatType = psFitsFloatImageCheck(source); // Custom floating-point type 1020 1021 1022 1023 1024 1025 target->options = psFitsOptionsAlloc(); 1026 target->options->scaling = PS_FITS_SCALE_MANUAL; 1027 target->options->fuzz = false; 1028 target->options->bitpix = bitpix; 1029 target->options->bscale = bscale; 1030 target->options->bzero = bzero; 1031 1032 psFitsSetCompression(sfile->fits, compType, tiles, 8, 0, 0); 1033 1034 1035 1036 1037 // Get current BITPIX, BSCALE, BZERO, EXTNAME 1038 // Probably not necessary to look the numerical values up in this 1039 // way, but guards against changes to psLib and cfitsio FITS 1040 // handling. 1041 psMetadataItem *bitpixItem = psMetadataLookup(in->header, "BITPIX"); 1042 psAssert(bitpixItem, "Every FITS image should have BITPIX"); 1043 int bitpix = psMetadataItemParseS32(bitpixItem); 1044 psMetadataItem *bscaleItem = psMetadataLookup(in->header, "BSCALE"); 1045 1046 float bscale; 1047 if (!bscaleItem) { 1048 psWarning("BSCALE isn't set; defaulting to unity"); 1049 bscale = 1.0; 1050 } else { 1051 bscale = psMetadataItemParseF32(bscaleItem); 1052 } 1053 psMetadataItem *bzeroItem = psMetadataLookup(in->header, "BZERO"); 1054 float bzero; 1055 if (!bzeroItem) { 1056 psWarning("BZERO isn't set; defaulting to zero"); 1057 bzero = 0.0; 1058 } else { 1059 bzero = psMetadataItemParseF32(bzeroItem); 1060 } 1061 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
