Changeset 25478
- Timestamp:
- Sep 22, 2009, 1:03:37 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/fits/psFits.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fits/psFits.c
r25383 r25478 895 895 break; 896 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 897 908 case PS_TYPE_F32: 898 909 bitpix = FLOAT_IMG; … … 921 932 _("Specified type, %s, is not supported."), 922 933 typeStr); 934 if (bitPix) { 935 *bitPix = 0; 936 } 937 if (dataType) { 938 *dataType = 0; 939 } 940 if (bZero) { 941 *bZero = 0; 942 } 923 943 return false; 924 944 } … … 960 980 return PS_FITS_COMPRESS_NONE; 961 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.
