diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2018-11-09 19:17:45 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2018-11-09 19:17:45 (GMT) |
commit | 230ef6d812fc698695a7742f1ddce1d437f31fb4 (patch) | |
tree | 4b22e29ed9f10fa3b57f2cdd90f624e420bb8cfa /tksao/fitsy++ | |
parent | 82f796251e759a6cd7886a56b6631f2229545c5e (diff) | |
download | blt-230ef6d812fc698695a7742f1ddce1d437f31fb4.zip blt-230ef6d812fc698695a7742f1ddce1d437f31fb4.tar.gz blt-230ef6d812fc698695a7742f1ddce1d437f31fb4.tar.bz2 |
add convert to mask
Diffstat (limited to 'tksao/fitsy++')
-rw-r--r-- | tksao/fitsy++/analysis.C | 71 | ||||
-rw-r--r-- | tksao/fitsy++/analysis.h | 2 |
2 files changed, 55 insertions, 18 deletions
diff --git a/tksao/fitsy++/analysis.C b/tksao/fitsy++/analysis.C index 8207175..6f93fe3 100644 --- a/tksao/fitsy++/analysis.C +++ b/tksao/fitsy++/analysis.C @@ -4,7 +4,7 @@ #include "analysis.h" -FitsAnalysis::FitsAnalysis(FitsFile* src) +FitsAnalysis::FitsAnalysis(FitsFile* src, int bitpix) { primary_ = src->primary(); managePrimary_ = 0; @@ -15,8 +15,58 @@ FitsAnalysis::FitsAnalysis(FitsFile* src) ext_ = src->ext(); inherit_ = src->inherit(); - // change bitpix to double - head_->setInteger("BITPIX", -64, ""); + int width = head_->naxis(0); + int height = head_->naxis(1); + size_t size = (size_t)width*height; + + switch (bitpix) { + case 8: + head_->setInteger("BITPIX", 8, ""); + data_ = new unsigned char[size]; + if (data_) + memset(data_, 0, size*sizeof(unsigned char)); + break; + case 16: + head_->setInteger("BITPIX", 16, ""); + data_ = new short[size]; + if (data_) + memset(data_, 0, size*sizeof(short)); + break; + case -16: + head_->setInteger("BITPIX", -16, ""); + data_ = new unsigned short[size]; + if (data_) + memset(data_, 0, size*sizeof(unsigned short)); + break; + case 32: + head_->setInteger("BITPIX", 32, ""); + data_ = new int[size]; + if (data_) + memset(data_, 0, size*sizeof(int)); + break; + case 64: + head_->setInteger("BITPIX", 64, ""); + data_ = new long long[size]; + if (data_) + memset(data_, 0, size*sizeof(long long)); + break; + case -32: + head_->setInteger("BITPIX", -32, ""); + data_ = new float[size]; + if (data_) + memset(data_, 0, size*sizeof(float)); + break; + case -64: + head_->setInteger("BITPIX", -64, ""); + data_ = new double[size]; + if (data_) + memset(data_, 0, size*sizeof(double)); + break; + } + + // alloc memory + if (!data_) + return; // unset BZERO/BSCALE if present if (head_->find("BZERO")) @@ -27,22 +77,9 @@ FitsAnalysis::FitsAnalysis(FitsFile* src) head_->updateHDU(); - int width = head_->naxis(0); - int height = head_->naxis(1); - - // alloc memory - size_t size = (size_t)width*height; - data_ = new double[size]; - if (!data_) - return; - + // made it this far, must be valid dataSize_ = size; dataSkip_ = 0; - - // clear memory - memset(data_, 0, size*sizeof(double)); - - // made it this far, must be valid byteswap_ = 0; endian_ = lsb() ? LITTLE : BIG; valid_ = 1; diff --git a/tksao/fitsy++/analysis.h b/tksao/fitsy++/analysis.h index ed297b8..402f4c8 100644 --- a/tksao/fitsy++/analysis.h +++ b/tksao/fitsy++/analysis.h @@ -9,7 +9,7 @@ class FitsAnalysis : public FitsFile { public: - FitsAnalysis(FitsFile*); + FitsAnalysis(FitsFile*, int); ~FitsAnalysis(); }; |