summaryrefslogtreecommitdiffstats
path: root/tksao/fitsy++
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2017-08-16 19:36:46 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2017-08-16 19:36:46 (GMT)
commit71d7ecdf091e45f2119a12e879dfbfa64caba8f8 (patch)
tree36ec9b72d80fcb0cc135f33fb8b1bfcd7014926f /tksao/fitsy++
parent3c6296742a7a916b8306390cb929f81f9c59da24 (diff)
downloadblt-71d7ecdf091e45f2119a12e879dfbfa64caba8f8.zip
blt-71d7ecdf091e45f2119a12e879dfbfa64caba8f8.tar.gz
blt-71d7ecdf091e45f2119a12e879dfbfa64caba8f8.tar.bz2
FITS compression- fixed a problem with ZQUANTIZ=NO_DITHER
Diffstat (limited to 'tksao/fitsy++')
-rw-r--r--tksao/fitsy++/compress.C58
-rw-r--r--tksao/fitsy++/compress.h2
-rw-r--r--tksao/fitsy++/gzip.C8
3 files changed, 23 insertions, 45 deletions
diff --git a/tksao/fitsy++/compress.C b/tksao/fitsy++/compress.C
index 6d6febb..b1b01ac 100644
--- a/tksao/fitsy++/compress.C
+++ b/tksao/fitsy++/compress.C
@@ -28,7 +28,7 @@ FitsCompress::FitsCompress(FitsFile* fits)
if (fits->find(keyword)) {
char* which = fits->getString(keyword);
if (!strncmp(which,"NONE",4))
- quantize_ = NODITHER;
+ quantize_ = NONE;
if (!strncmp(which,"NO_DITHER",4))
quantize_ = NODITHER;
else if (!strncmp(which,"SUBTRACTIVE_DITHER_1",20))
@@ -627,45 +627,39 @@ template <class T> T FitsCompressm<T>::getValue(char* ptr, double zs,
template <> float FitsCompressm<float>::getValue(char* ptr, double zs,
double zz, int blank)
{
- if (!hasBlank_ && !hasScaling_ &&
- quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2)
+ if (!hasBlank_ && !hasScaling_ && quantize_==NONE)
return *ptr;
if (hasBlank_ && *ptr == blank)
return NAN;
switch (quantize_) {
+ case NONE:
case NODITHER:
return hasScaling_ ? (*ptr)*zs + zz : *ptr;
case SUBDITHER1:
case SUBDITHER2:
return unquantize(*ptr,zs,zz);
}
-
- // so compiler will not complain
- return hasScaling_ ? (*ptr)*zs + zz : *ptr;
}
template <> double FitsCompressm<double>::getValue(char* ptr, double zs,
double zz, int blank)
{
- if (!hasBlank_ && !hasScaling_ &&
- quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2)
+ if (!hasBlank_ && !hasScaling_ && quantize_==NONE)
return *ptr;
if (hasBlank_ && *ptr == blank)
return NAN;
switch (quantize_) {
+ case NONE:
case NODITHER:
return hasScaling_ ? (*ptr)*zs + zz : *ptr;
case SUBDITHER1:
case SUBDITHER2:
return unquantize(*ptr,zs,zz);
}
-
- // so compiler will not complain
- return hasScaling_ ? (*ptr)*zs + zz : *ptr;
}
// getValue short
@@ -679,45 +673,39 @@ template <class T> T FitsCompressm<T>::getValue(short* ptr, double zs,
template <> float FitsCompressm<float>::getValue(short* ptr, double zs,
double zz, int blank)
{
- if (!hasBlank_ && !hasScaling_ &&
- quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2)
+ if (!hasBlank_ && !hasScaling_ && quantize_==NONE)
return *ptr;
if (hasBlank_ && *ptr == blank)
return NAN;
switch (quantize_) {
+ case NONE:
case NODITHER:
return hasScaling_ ? (*ptr)*zs + zz : *ptr;
case SUBDITHER1:
case SUBDITHER2:
return unquantize(*ptr,zs,zz);
}
-
- // so compiler will not complain
- return hasScaling_ ? (*ptr)*zs + zz : *ptr;
}
template <> double FitsCompressm<double>::getValue(short* ptr, double zs,
double zz, int blank)
{
- if (!hasBlank_ && !hasScaling_ &&
- quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2)
+ if (!hasBlank_ && !hasScaling_ && quantize_==NONE)
return *ptr;
if (hasBlank_ && *ptr == blank)
return NAN;
switch (quantize_) {
+ case NONE:
case NODITHER:
return hasScaling_ ? (*ptr)*zs + zz : *ptr;
case SUBDITHER1:
case SUBDITHER2:
return unquantize(*ptr,zs,zz);
}
-
- // so compiler will not complain
- return hasScaling_ ? (*ptr)*zs + zz : *ptr;
}
// getValue int
@@ -731,14 +719,14 @@ template <class T> T FitsCompressm<T>::getValue(int* ptr, double zs,
template <> float FitsCompressm<float>::getValue(int* ptr, double zs,
double zz, int blank)
{
- if (!hasBlank_ && !hasScaling_ &&
- quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2)
+ if (!hasBlank_ && !hasScaling_ && quantize_==NONE)
return *ptr;
if (hasBlank_ && *ptr == blank)
return NAN;
switch (quantize_) {
+ case NONE:
case NODITHER:
return hasScaling_ ? (*ptr)*zs + zz : *ptr;
case SUBDITHER1:
@@ -746,22 +734,19 @@ template <> float FitsCompressm<float>::getValue(int* ptr, double zs,
case SUBDITHER2:
return unquantizeZero(*ptr,zs,zz);
}
-
- // so compiler will not complain
- return hasScaling_ ? (*ptr)*zs + zz : *ptr;
}
template <> double FitsCompressm<double>::getValue(int* ptr, double zs,
double zz, int blank)
{
- if (!hasBlank_ && !hasScaling_ &&
- quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2)
+ if (!hasBlank_ && !hasScaling_ && quantize_==NONE)
return *ptr;
if (hasBlank_ && *ptr == blank)
return NAN;
switch (quantize_) {
+ case NONE:
case NODITHER:
return hasScaling_ ? (*ptr)*zs + zz : *ptr;
case SUBDITHER1:
@@ -769,9 +754,6 @@ template <> double FitsCompressm<double>::getValue(int* ptr, double zs,
case SUBDITHER2:
return unquantizeZero(*ptr,zs,zz);
}
-
- // so compiler will not complain
- return hasScaling_ ? (*ptr)*zs + zz : *ptr;
}
// getValue long long
@@ -785,14 +767,14 @@ template <class T> T FitsCompressm<T>::getValue(long long* ptr, double zs,
template <> float FitsCompressm<float>::getValue(long long* ptr, double zs,
double zz, int blank)
{
- if (!hasBlank_ && !hasScaling_ &&
- quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2)
+ if (!hasBlank_ && !hasScaling_ && quantize_==NONE)
return *ptr;
if (hasBlank_ && *ptr == blank)
return NAN;
switch (quantize_) {
+ case NONE:
case NODITHER:
return hasScaling_ ? (*ptr)*zs + zz : *ptr;
case SUBDITHER1:
@@ -800,22 +782,19 @@ template <> float FitsCompressm<float>::getValue(long long* ptr, double zs,
case SUBDITHER2:
return unquantizeZero(*ptr,zs,zz);
}
-
- // so compiler will not complain
- return hasScaling_ ? (*ptr)*zs + zz : *ptr;
}
template <> double FitsCompressm<double>::getValue(long long* ptr, double zs,
double zz, int blank)
{
- if (!hasBlank_ && !hasScaling_ &&
- quantize_ != SUBDITHER1 && quantize_ != SUBDITHER2)
+ if (!hasBlank_ && !hasScaling_ && quantize_==NONE)
return *ptr;
if (hasBlank_ && *ptr == blank)
return NAN;
switch (quantize_) {
+ case NONE:
case NODITHER:
return hasScaling_ ? (*ptr)*zs + zz : *ptr;
case SUBDITHER1:
@@ -823,9 +802,6 @@ template <> double FitsCompressm<double>::getValue(long long* ptr, double zs,
case SUBDITHER2:
return unquantizeZero(*ptr,zs,zz);
}
-
- // so compiler will not complain
- return hasScaling_ ? (*ptr)*zs + zz : *ptr;
}
// getValue float
diff --git a/tksao/fitsy++/compress.h b/tksao/fitsy++/compress.h
index 350ee61..67088ef 100644
--- a/tksao/fitsy++/compress.h
+++ b/tksao/fitsy++/compress.h
@@ -9,7 +9,7 @@
class FitsCompress : public FitsFile {
public:
- enum QuantMethod {NODITHER,SUBDITHER1,SUBDITHER2};
+ enum QuantMethod {NONE,NODITHER,SUBDITHER1,SUBDITHER2};
protected:
int bitpix_;
diff --git a/tksao/fitsy++/gzip.C b/tksao/fitsy++/gzip.C
index f62cafb..05effdf 100644
--- a/tksao/fitsy++/gzip.C
+++ b/tksao/fitsy++/gzip.C
@@ -267,14 +267,15 @@ template <class T> int FitsGzipm<T>::compressed(T* dest, char* sptr,
size_t id = kk*FitsCompressm<T>::width_*FitsCompressm<T>::height_ + jj*FitsCompressm<T>::width_ + ii;
T val =0;
switch (FitsCompressm<T>::quantize_) {
- case FitsCompress::NODITHER:
+ case FitsCompress::NONE:
val = FitsCompressm<T>::getValue((float*)obuf+ll,zs,zz,blank);
break;
+ case FitsCompress::NODITHER:
case FitsCompress::SUBDITHER1:
case FitsCompress::SUBDITHER2:
val = FitsCompressm<T>::getValue((int*)obuf+ll,zs,zz,blank);
break;
- }
+ }
dest[id] = val;
}
break;
@@ -305,9 +306,10 @@ template <class T> int FitsGzipm<T>::compressed(T* dest, char* sptr,
size_t id = kk*FitsCompressm<T>::width_*FitsCompressm<T>::height_ + jj*FitsCompressm<T>::width_ + ii;
T val =0;
switch (FitsCompressm<T>::quantize_) {
- case FitsCompress::NODITHER:
+ case FitsCompress::NONE:
val = FitsCompressm<T>::getValue((double*)obuf+ll,zs,zz,blank);
break;
+ case FitsCompress::NODITHER:
case FitsCompress::SUBDITHER1:
case FitsCompress::SUBDITHER2:
val = FitsCompressm<T>::getValue((long long*)obuf+ll,zs,zz,blank);