Commit 9c23d585d50aab2f0d0dada5021eabef4fb9d15e
1 parent
dd0d5053
Add FITS image type conversion constructors (#1986)
Showing
30 changed files
with
457 additions
and
96 deletions
ChangeLog
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | * Version 1.3.0 released |
| 4 | 4 | ========================= |
| 5 | 5 | |
| 6 | + Added FITS image conversion operators (#1986) | |
| 6 | 7 | If code originates from Git, always compile the Python bindings (#1985) |
| 7 | 8 | Raise exception instead of exiting with return code in Python tests (#1983) |
| 8 | 9 | Enhance precision of GCTAEdisp2D::compute_ebounds_src | ... | ... |
NEWS
include/GFitsImageByte.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageByte.hpp - FITS Byte image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -46,6 +46,7 @@ public: |
| 46 | 46 | GFitsImageByte(const int& nx, const int& ny, const int& nz, const unsigned char* pixels = NULL); |
| 47 | 47 | GFitsImageByte(const int& nx, const int& ny, const int& nz, const int& nt, const unsigned char* pixels = NULL); |
| 48 | 48 | GFitsImageByte(const std::vector<int>& naxes, const unsigned char* pixels = NULL); |
| 49 | + GFitsImageByte(const GFitsImage& image); | |
| 49 | 50 | GFitsImageByte(const GFitsImageByte& image); |
| 50 | 51 | virtual ~GFitsImageByte(void); |
| 51 | 52 | ... | ... |
include/GFitsImageDouble.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageDouble.hpp - Double precision FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -46,6 +46,7 @@ public: |
| 46 | 46 | GFitsImageDouble(const int& nx, const int& ny, const int& nz, const double* pixels = NULL); |
| 47 | 47 | GFitsImageDouble(const int& nx, const int& ny, const int& nz, const int& nt, const double* pixels = NULL); |
| 48 | 48 | GFitsImageDouble(const std::vector<int>& naxes, const double* pixels = NULL); |
| 49 | + GFitsImageDouble(const GFitsImage& image); | |
| 49 | 50 | GFitsImageDouble(const GFitsImageDouble& image); |
| 50 | 51 | virtual ~GFitsImageDouble(void); |
| 51 | 52 | ... | ... |
include/GFitsImageFloat.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageFloat.hpp - Single precision FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -46,6 +46,7 @@ public: |
| 46 | 46 | GFitsImageFloat(const int& nx, const int& ny, const int& nz, const float* pixels = NULL); |
| 47 | 47 | GFitsImageFloat(const int& nx, const int& ny, const int& nz, const int& nt, const float* pixels = NULL); |
| 48 | 48 | GFitsImageFloat(const std::vector<int>& naxes, const float* pixels = NULL); |
| 49 | + GFitsImageFloat(const GFitsImage& image); | |
| 49 | 50 | GFitsImageFloat(const GFitsImageFloat& image); |
| 50 | 51 | virtual ~GFitsImageFloat(void); |
| 51 | 52 | ... | ... |
include/GFitsImageLong.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageLong.hpp - Long integer FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -46,6 +46,7 @@ public: |
| 46 | 46 | GFitsImageLong(const int& nx, const int& ny, const int& nz, const long* pixels = NULL); |
| 47 | 47 | GFitsImageLong(const int& nx, const int& ny, const int& nz, const int& nt, const long* pixels = NULL); |
| 48 | 48 | GFitsImageLong(const std::vector<int>& naxes, const long* pixels = NULL); |
| 49 | + GFitsImageLong(const GFitsImage& image); | |
| 49 | 50 | GFitsImageLong(const GFitsImageLong& image); |
| 50 | 51 | virtual ~GFitsImageLong(void); |
| 51 | 52 | ... | ... |
include/GFitsImageLongLong.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageLongLong.hpp - Long long integer FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -46,6 +46,7 @@ public: |
| 46 | 46 | GFitsImageLongLong(const int& nx, const int& ny, const int& nz, const long long* pixels = NULL); |
| 47 | 47 | GFitsImageLongLong(const int& nx, const int& ny, const int& nz, const int& nt, const long long* pixels = NULL); |
| 48 | 48 | GFitsImageLongLong(const std::vector<int>& naxes, const long long* pixels = NULL); |
| 49 | + GFitsImageLongLong(const GFitsImage& image); | |
| 49 | 50 | GFitsImageLongLong(const GFitsImageLongLong& image); |
| 50 | 51 | virtual ~GFitsImageLongLong(void); |
| 51 | 52 | ... | ... |
include/GFitsImageSByte.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageSByte.hpp - Signed Byte FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -46,6 +46,7 @@ public: |
| 46 | 46 | GFitsImageSByte(const int& nx, const int& ny, const int& nz, const char* pixels = NULL); |
| 47 | 47 | GFitsImageSByte(const int& nx, const int& ny, const int& nz, const int& nt, const char* pixels = NULL); |
| 48 | 48 | GFitsImageSByte(const std::vector<int>& naxes, const char* pixels = NULL); |
| 49 | + GFitsImageSByte(const GFitsImage& image); | |
| 49 | 50 | GFitsImageSByte(const GFitsImageSByte& image); |
| 50 | 51 | virtual ~GFitsImageSByte(void); |
| 51 | 52 | ... | ... |
include/GFitsImageShort.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageShort.hpp - Short integer FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -46,6 +46,7 @@ public: |
| 46 | 46 | GFitsImageShort(const int& nx, const int& ny, const int& nz, const short* pixels = NULL); |
| 47 | 47 | GFitsImageShort(const int& nx, const int& ny, const int& nz, const int& nt, const short* pixels = NULL); |
| 48 | 48 | GFitsImageShort(const std::vector<int>& naxes, const short* pixels = NULL); |
| 49 | + GFitsImageShort(const GFitsImage& image); | |
| 49 | 50 | GFitsImageShort(const GFitsImageShort& image); |
| 50 | 51 | virtual ~GFitsImageShort(void); |
| 51 | 52 | ... | ... |
include/GFitsImageULong.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageULong.hpp - Unsigned long image FITS class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -46,6 +46,7 @@ public: |
| 46 | 46 | GFitsImageULong(const int& nx, const int& ny, const int& nz, const unsigned long* pixels = NULL); |
| 47 | 47 | GFitsImageULong(const int& nx, const int& ny, const int& nz, const int& nt, const unsigned long* pixels = NULL); |
| 48 | 48 | GFitsImageULong(const std::vector<int>& naxes, const unsigned long* pixels = NULL); |
| 49 | + GFitsImageULong(const GFitsImage& image); | |
| 49 | 50 | GFitsImageULong(const GFitsImageULong& image); |
| 50 | 51 | virtual ~GFitsImageULong(void); |
| 51 | 52 | ... | ... |
include/GFitsImageUShort.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageUShort.hpp - Unsigned short FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -46,6 +46,7 @@ public: |
| 46 | 46 | GFitsImageUShort(const int& nx, const int& ny, const int& nz, const unsigned short* pixels = NULL); |
| 47 | 47 | GFitsImageUShort(const int& nx, const int& ny, const int& nz, const int& nt, const unsigned short* pixels = NULL); |
| 48 | 48 | GFitsImageUShort(const std::vector<int>& naxes, const unsigned short* pixels = NULL); |
| 49 | + GFitsImageUShort(const GFitsImage& image); | |
| 49 | 50 | GFitsImageUShort(const GFitsImageUShort& image); |
| 50 | 51 | virtual ~GFitsImageUShort(void); |
| 51 | 52 | ... | ... |
pyext/GFitsImageByte.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageByte.i - FITS Byte image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -44,6 +44,7 @@ public: |
| 44 | 44 | GFitsImageByte(const int& nx, const int& ny, const int& nz, const unsigned char* pixels = NULL); |
| 45 | 45 | GFitsImageByte(const int& nx, const int& ny, const int& nz, const int& nt, const unsigned char* pixels = NULL); |
| 46 | 46 | GFitsImageByte(const std::vector<int>& naxes, const unsigned char* pixels = NULL); |
| 47 | + GFitsImageByte(const GFitsImage& image); | |
| 47 | 48 | GFitsImageByte(const GFitsImageByte& image); |
| 48 | 49 | virtual ~GFitsImageByte(void); |
| 49 | 50 | ... | ... |
pyext/GFitsImageDouble.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageDouble.i - Double precision FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -44,6 +44,7 @@ public: |
| 44 | 44 | GFitsImageDouble(const int& nx, const int& ny, const int& nz, const double* pixels = NULL); |
| 45 | 45 | GFitsImageDouble(const int& nx, const int& ny, const int& nz, const int& nt, const double* pixels = NULL); |
| 46 | 46 | GFitsImageDouble(const std::vector<int>& naxes, const double* pixels = NULL); |
| 47 | + GFitsImageDouble(const GFitsImage& image); | |
| 47 | 48 | GFitsImageDouble(const GFitsImageDouble& image); |
| 48 | 49 | virtual ~GFitsImageDouble(void); |
| 49 | 50 | ... | ... |
pyext/GFitsImageFloat.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageFloat.i - Single precision FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -44,6 +44,7 @@ public: |
| 44 | 44 | GFitsImageFloat(const int& nx, const int& ny, const int& nz, const float* pixels = NULL); |
| 45 | 45 | GFitsImageFloat(const int& nx, const int& ny, const int& nz, const int& nt, const float* pixels = NULL); |
| 46 | 46 | GFitsImageFloat(const std::vector<int>& naxes, const float* pixels = NULL); |
| 47 | + GFitsImageFloat(const GFitsImage& image); | |
| 47 | 48 | GFitsImageFloat(const GFitsImageFloat& image); |
| 48 | 49 | virtual ~GFitsImageFloat(void); |
| 49 | 50 | ... | ... |
pyext/GFitsImageLong.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageLong.i - Long integer FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -44,6 +44,7 @@ public: |
| 44 | 44 | GFitsImageLong(const int& nx, const int& ny, const int& nz, const long* pixels = NULL); |
| 45 | 45 | GFitsImageLong(const int& nx, const int& ny, const int& nz, const int& nt, const long* pixels = NULL); |
| 46 | 46 | GFitsImageLong(const std::vector<int>& naxes, const long* pixels = NULL); |
| 47 | + GFitsImageLong(const GFitsImage& image); | |
| 47 | 48 | GFitsImageLong(const GFitsImageLong& image); |
| 48 | 49 | virtual ~GFitsImageLong(void); |
| 49 | 50 | ... | ... |
pyext/GFitsImageLongLong.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageLongLong.i - Long long integer FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -44,6 +44,7 @@ public: |
| 44 | 44 | GFitsImageLongLong(const int& nx, const int& ny, const int& nz, const long long* pixels = NULL); |
| 45 | 45 | GFitsImageLongLong(const int& nx, const int& ny, const int& nz, const int& nt, const long long* pixels = NULL); |
| 46 | 46 | GFitsImageLongLong(const std::vector<int>& naxes, const long long* pixels = NULL); |
| 47 | + GFitsImageLongLong(const GFitsImage& image); | |
| 47 | 48 | GFitsImageLongLong(const GFitsImageLongLong& image); |
| 48 | 49 | virtual ~GFitsImageLongLong(void); |
| 49 | 50 | ... | ... |
pyext/GFitsImageSByte.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageSByte.i - Signed Byte FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -44,6 +44,7 @@ public: |
| 44 | 44 | GFitsImageSByte(const int& nx, const int& ny, const int& nz, const char* pixels = NULL); |
| 45 | 45 | GFitsImageSByte(const int& nx, const int& ny, const int& nz, const int& nt, const char* pixels = NULL); |
| 46 | 46 | GFitsImageSByte(const std::vector<int>& naxes, const char* pixels = NULL); |
| 47 | + GFitsImageSByte(const GFitsImage& image); | |
| 47 | 48 | GFitsImageSByte(const GFitsImageSByte& image); |
| 48 | 49 | virtual ~GFitsImageSByte(void); |
| 49 | 50 | ... | ... |
pyext/GFitsImageShort.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageShort.i - Short integer FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -44,6 +44,7 @@ public: |
| 44 | 44 | GFitsImageShort(const int& nx, const int& ny, const int& nz, const short* pixels = NULL); |
| 45 | 45 | GFitsImageShort(const int& nx, const int& ny, const int& nz, const int& nt, const short* pixels = NULL); |
| 46 | 46 | GFitsImageShort(const std::vector<int>& naxes, const short* pixels = NULL); |
| 47 | + GFitsImageShort(const GFitsImage& image); | |
| 47 | 48 | GFitsImageShort(const GFitsImageShort& image); |
| 48 | 49 | virtual ~GFitsImageShort(void); |
| 49 | 50 | ... | ... |
pyext/GFitsImageULong.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageULong.i - Unsigned long image FITS class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -44,6 +44,7 @@ public: |
| 44 | 44 | GFitsImageULong(const int& nx, const int& ny, const int& nz, const unsigned long* pixels = NULL); |
| 45 | 45 | GFitsImageULong(const int& nx, const int& ny, const int& nz, const int& nt, const unsigned long* pixels = NULL); |
| 46 | 46 | GFitsImageULong(const std::vector<int>& naxes, const unsigned long* pixels = NULL); |
| 47 | + GFitsImageULong(const GFitsImage& image); | |
| 47 | 48 | GFitsImageULong(const GFitsImageULong& image); |
| 48 | 49 | virtual ~GFitsImageULong(void); |
| 49 | 50 | ... | ... |
pyext/GFitsImageUShort.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageUShort.i - Unsigned short FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -45,6 +45,7 @@ public: |
| 45 | 45 | GFitsImageUShort(const int& nx, const int& ny, const int& nz, const unsigned short* pixels = NULL); |
| 46 | 46 | GFitsImageUShort(const int& nx, const int& ny, const int& nz, const int& nt, const unsigned short* pixels = NULL); |
| 47 | 47 | GFitsImageUShort(const std::vector<int>& naxes, const unsigned short* pixels = NULL); |
| 48 | + GFitsImageUShort(const GFitsImage& image); | |
| 48 | 49 | GFitsImageUShort(const GFitsImageUShort& image); |
| 49 | 50 | virtual ~GFitsImageUShort(void); |
| 50 | 51 | ... | ... |
src/fits/GFitsImageByte.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageByte.cpp - FITS Byte image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | ***************************************************************************/ |
| 55 | 55 | GFitsImageByte::GFitsImageByte(void) : GFitsImage() |
| 56 | 56 | { |
| 57 | - // Initialise class members for clean destruction | |
| 57 | + // Initialise class members | |
| 58 | 58 | init_members(); |
| 59 | 59 | |
| 60 | 60 | // Return |
| ... | ... | @@ -73,7 +73,7 @@ GFitsImageByte::GFitsImageByte(void) : GFitsImage() |
| 73 | 73 | GFitsImageByte::GFitsImageByte(const int& nx, const unsigned char* pixels) : |
| 74 | 74 | GFitsImage(G_BITPIX, nx) |
| 75 | 75 | { |
| 76 | - // Initialise class members for clean destruction | |
| 76 | + // Initialise class members | |
| 77 | 77 | init_members(); |
| 78 | 78 | |
| 79 | 79 | // Construct data |
| ... | ... | @@ -97,7 +97,7 @@ GFitsImageByte::GFitsImageByte(const int& nx, const int& ny, |
| 97 | 97 | const unsigned char* pixels) : |
| 98 | 98 | GFitsImage(G_BITPIX, nx, ny) |
| 99 | 99 | { |
| 100 | - // Initialise class members for clean destruction | |
| 100 | + // Initialise class members | |
| 101 | 101 | init_members(); |
| 102 | 102 | |
| 103 | 103 | // Construct data |
| ... | ... | @@ -122,7 +122,7 @@ GFitsImageByte::GFitsImageByte(const int& nx, const int& ny, const int& nz, |
| 122 | 122 | const unsigned char* pixels) : |
| 123 | 123 | GFitsImage(G_BITPIX, nx, ny, nz) |
| 124 | 124 | { |
| 125 | - // Initialise class members for clean destruction | |
| 125 | + // Initialise class members | |
| 126 | 126 | init_members(); |
| 127 | 127 | |
| 128 | 128 | // Construct data |
| ... | ... | @@ -148,7 +148,7 @@ GFitsImageByte::GFitsImageByte(const int& nx, const int& ny, const int& nz, |
| 148 | 148 | const int& nt, const unsigned char* pixels) : |
| 149 | 149 | GFitsImage(G_BITPIX, nx, ny, nz, nt) |
| 150 | 150 | { |
| 151 | - // Initialise class members for clean destruction | |
| 151 | + // Initialise class members | |
| 152 | 152 | init_members(); |
| 153 | 153 | |
| 154 | 154 | // Construct data |
| ... | ... | @@ -173,7 +173,7 @@ GFitsImageByte::GFitsImageByte(const std::vector<int>& naxes, |
| 173 | 173 | const unsigned char* pixels) : |
| 174 | 174 | GFitsImage(G_BITPIX, naxes) |
| 175 | 175 | { |
| 176 | - // Initialise class members for clean destruction | |
| 176 | + // Initialise class members | |
| 177 | 177 | init_members(); |
| 178 | 178 | |
| 179 | 179 | // Construct data |
| ... | ... | @@ -185,6 +185,39 @@ GFitsImageByte::GFitsImageByte(const std::vector<int>& naxes, |
| 185 | 185 | |
| 186 | 186 | |
| 187 | 187 | /***********************************************************************//** |
| 188 | + * @brief Type conversion constructor | |
| 189 | + * | |
| 190 | + * @param[in] image FITS image. | |
| 191 | + * | |
| 192 | + * This constructor performs the conversion of any image type into a byte | |
| 193 | + * image. | |
| 194 | + ***************************************************************************/ | |
| 195 | +GFitsImageByte::GFitsImageByte(const GFitsImage& image) : | |
| 196 | + GFitsImage(image) | |
| 197 | +{ | |
| 198 | + // Initialise class members | |
| 199 | + init_members(); | |
| 200 | + | |
| 201 | + // Copy pixels | |
| 202 | + if (m_num_pixels > 0) { | |
| 203 | + m_pixels = new unsigned char[m_num_pixels]; | |
| 204 | + for (int i = 0; i < m_num_pixels; ++i) { | |
| 205 | + m_pixels[i] = (unsigned char)image.pixel(i); | |
| 206 | + } | |
| 207 | + } | |
| 208 | + | |
| 209 | + // Set number of bits per pixel | |
| 210 | + m_bitpix = G_BITPIX; | |
| 211 | + | |
| 212 | + // Update header card | |
| 213 | + header()["BITPIX"].value(G_BITPIX); | |
| 214 | + | |
| 215 | + // Return | |
| 216 | + return; | |
| 217 | +} | |
| 218 | + | |
| 219 | + | |
| 220 | +/***********************************************************************//** | |
| 188 | 221 | * @brief Copy constructor |
| 189 | 222 | * |
| 190 | 223 | * @param[in] image FITS image. |
| ... | ... | @@ -192,7 +225,7 @@ GFitsImageByte::GFitsImageByte(const std::vector<int>& naxes, |
| 192 | 225 | GFitsImageByte::GFitsImageByte(const GFitsImageByte& image) : |
| 193 | 226 | GFitsImage(image) |
| 194 | 227 | { |
| 195 | - // Initialise class members for clean destruction | |
| 228 | + // Initialise class members | |
| 196 | 229 | init_members(); |
| 197 | 230 | |
| 198 | 231 | // Copy members |
| ... | ... | @@ -239,7 +272,7 @@ GFitsImageByte& GFitsImageByte::operator=(const GFitsImageByte& image) |
| 239 | 272 | // Free members |
| 240 | 273 | free_members(); |
| 241 | 274 | |
| 242 | - // Initialise private members for clean destruction | |
| 275 | + // Initialise private members | |
| 243 | 276 | init_members(); |
| 244 | 277 | |
| 245 | 278 | // Copy members | ... | ... |
src/fits/GFitsImageDouble.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageDouble.cpp - Double precision FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | ***************************************************************************/ |
| 55 | 55 | GFitsImageDouble::GFitsImageDouble(void) : GFitsImage() |
| 56 | 56 | { |
| 57 | - // Initialise class members for clean destruction | |
| 57 | + // Initialise class members | |
| 58 | 58 | init_members(); |
| 59 | 59 | |
| 60 | 60 | // Return |
| ... | ... | @@ -73,7 +73,7 @@ GFitsImageDouble::GFitsImageDouble(void) : GFitsImage() |
| 73 | 73 | GFitsImageDouble::GFitsImageDouble(const int& nx, const double* pixels) : |
| 74 | 74 | GFitsImage(G_BITPIX, nx) |
| 75 | 75 | { |
| 76 | - // Initialise class members for clean destruction | |
| 76 | + // Initialise class members | |
| 77 | 77 | init_members(); |
| 78 | 78 | |
| 79 | 79 | // Construct data |
| ... | ... | @@ -97,7 +97,7 @@ GFitsImageDouble::GFitsImageDouble(const int& nx, const int& ny, |
| 97 | 97 | const double* pixels) : |
| 98 | 98 | GFitsImage(G_BITPIX, nx, ny) |
| 99 | 99 | { |
| 100 | - // Initialise class members for clean destruction | |
| 100 | + // Initialise class members | |
| 101 | 101 | init_members(); |
| 102 | 102 | |
| 103 | 103 | // Construct data |
| ... | ... | @@ -122,7 +122,7 @@ GFitsImageDouble::GFitsImageDouble(const int& nx, const int& ny, const int& nz, |
| 122 | 122 | const double* pixels) : |
| 123 | 123 | GFitsImage(G_BITPIX, nx, ny, nz) |
| 124 | 124 | { |
| 125 | - // Initialise class members for clean destruction | |
| 125 | + // Initialise class members | |
| 126 | 126 | init_members(); |
| 127 | 127 | |
| 128 | 128 | // Construct data |
| ... | ... | @@ -148,7 +148,7 @@ GFitsImageDouble::GFitsImageDouble(const int& nx, const int& ny, const int& nz, |
| 148 | 148 | const int& nt, const double* pixels) : |
| 149 | 149 | GFitsImage(G_BITPIX, nx, ny, nz, nt) |
| 150 | 150 | { |
| 151 | - // Initialise class members for clean destruction | |
| 151 | + // Initialise class members | |
| 152 | 152 | init_members(); |
| 153 | 153 | |
| 154 | 154 | // Construct data |
| ... | ... | @@ -173,7 +173,7 @@ GFitsImageDouble::GFitsImageDouble(const std::vector<int>& naxes, |
| 173 | 173 | const double* pixels) : |
| 174 | 174 | GFitsImage(G_BITPIX, naxes) |
| 175 | 175 | { |
| 176 | - // Initialise class members for clean destruction | |
| 176 | + // Initialise class members | |
| 177 | 177 | init_members(); |
| 178 | 178 | |
| 179 | 179 | // Construct data |
| ... | ... | @@ -185,6 +185,41 @@ GFitsImageDouble::GFitsImageDouble(const std::vector<int>& naxes, |
| 185 | 185 | |
| 186 | 186 | |
| 187 | 187 | /***********************************************************************//** |
| 188 | + * @brief Type conversion constructor | |
| 189 | + * | |
| 190 | + * @param[in] image FITS image. | |
| 191 | + * | |
| 192 | + * This constructor performs the conversion of any image type into a double | |
| 193 | + * precision floating point image. | |
| 194 | + ***************************************************************************/ | |
| 195 | +GFitsImageDouble::GFitsImageDouble(const GFitsImage& image) : | |
| 196 | + GFitsImage(image) | |
| 197 | +{ | |
| 198 | + // Initialise class members | |
| 199 | + init_members(); | |
| 200 | + | |
| 201 | + // Copy pixels | |
| 202 | + if (m_num_pixels > 0) { | |
| 203 | + m_pixels = new double[m_num_pixels]; | |
| 204 | + for (int i = 0; i < m_num_pixels; ++i) { | |
| 205 | + m_pixels[i] = (double)image.pixel(i); | |
| 206 | + } | |
| 207 | + } | |
| 208 | + | |
| 209 | + // Set number of bits per pixel | |
| 210 | + m_bitpix = G_BITPIX; | |
| 211 | + | |
| 212 | + // Update header card | |
| 213 | + header()["BITPIX"].value(G_BITPIX); | |
| 214 | + | |
| 215 | + // Return | |
| 216 | + return; | |
| 217 | +} | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | +/***********************************************************************//** | |
| 188 | 223 | * @brief Copy constructor |
| 189 | 224 | * |
| 190 | 225 | * @param[in] image FITS image. |
| ... | ... | @@ -192,7 +227,7 @@ GFitsImageDouble::GFitsImageDouble(const std::vector<int>& naxes, |
| 192 | 227 | GFitsImageDouble::GFitsImageDouble(const GFitsImageDouble& image) : |
| 193 | 228 | GFitsImage(image) |
| 194 | 229 | { |
| 195 | - // Initialise class members for clean destruction | |
| 230 | + // Initialise class members | |
| 196 | 231 | init_members(); |
| 197 | 232 | |
| 198 | 233 | // Copy members |
| ... | ... | @@ -238,7 +273,7 @@ GFitsImageDouble& GFitsImageDouble::operator=(const GFitsImageDouble& image) |
| 238 | 273 | // Free members |
| 239 | 274 | free_members(); |
| 240 | 275 | |
| 241 | - // Initialise private members for clean destruction | |
| 276 | + // Initialise private members | |
| 242 | 277 | init_members(); |
| 243 | 278 | |
| 244 | 279 | // Copy members | ... | ... |
src/fits/GFitsImageFloat.cpp
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | ***************************************************************************/ |
| 55 | 55 | GFitsImageFloat::GFitsImageFloat(void) : GFitsImage() |
| 56 | 56 | { |
| 57 | - // Initialise class members for clean destruction | |
| 57 | + // Initialise class members | |
| 58 | 58 | init_members(); |
| 59 | 59 | |
| 60 | 60 | // Return |
| ... | ... | @@ -73,7 +73,7 @@ GFitsImageFloat::GFitsImageFloat(void) : GFitsImage() |
| 73 | 73 | GFitsImageFloat::GFitsImageFloat(const int& nx, const float* pixels) : |
| 74 | 74 | GFitsImage(G_BITPIX, nx) |
| 75 | 75 | { |
| 76 | - // Initialise class members for clean destruction | |
| 76 | + // Initialise class members | |
| 77 | 77 | init_members(); |
| 78 | 78 | |
| 79 | 79 | // Construct data |
| ... | ... | @@ -97,7 +97,7 @@ GFitsImageFloat::GFitsImageFloat(const int& nx, const int& ny, |
| 97 | 97 | const float* pixels) : |
| 98 | 98 | GFitsImage(G_BITPIX, nx, ny) |
| 99 | 99 | { |
| 100 | - // Initialise class members for clean destruction | |
| 100 | + // Initialise class members | |
| 101 | 101 | init_members(); |
| 102 | 102 | |
| 103 | 103 | // Construct data |
| ... | ... | @@ -122,7 +122,7 @@ GFitsImageFloat::GFitsImageFloat(const int& nx, const int& ny, const int& nz, |
| 122 | 122 | const float* pixels) : |
| 123 | 123 | GFitsImage(G_BITPIX, nx, ny, nz) |
| 124 | 124 | { |
| 125 | - // Initialise class members for clean destruction | |
| 125 | + // Initialise class members | |
| 126 | 126 | init_members(); |
| 127 | 127 | |
| 128 | 128 | // Construct data |
| ... | ... | @@ -148,7 +148,7 @@ GFitsImageFloat::GFitsImageFloat(const int& nx, const int& ny, const int& nz, |
| 148 | 148 | const int& nt, const float* pixels) : |
| 149 | 149 | GFitsImage(G_BITPIX, nx, ny, nz, nt) |
| 150 | 150 | { |
| 151 | - // Initialise class members for clean destruction | |
| 151 | + // Initialise class members | |
| 152 | 152 | init_members(); |
| 153 | 153 | |
| 154 | 154 | // Construct data from pixels |
| ... | ... | @@ -173,7 +173,7 @@ GFitsImageFloat::GFitsImageFloat(const std::vector<int>& naxes, |
| 173 | 173 | const float* pixels) : |
| 174 | 174 | GFitsImage(G_BITPIX, naxes) |
| 175 | 175 | { |
| 176 | - // Initialise class members for clean destruction | |
| 176 | + // Initialise class members | |
| 177 | 177 | init_members(); |
| 178 | 178 | |
| 179 | 179 | // Construct data from pixels |
| ... | ... | @@ -185,6 +185,39 @@ GFitsImageFloat::GFitsImageFloat(const std::vector<int>& naxes, |
| 185 | 185 | |
| 186 | 186 | |
| 187 | 187 | /***********************************************************************//** |
| 188 | + * @brief Type conversion constructor | |
| 189 | + * | |
| 190 | + * @param[in] image FITS image. | |
| 191 | + * | |
| 192 | + * This constructor performs the conversion of any image type into a single | |
| 193 | + * precision floating point image. | |
| 194 | + ***************************************************************************/ | |
| 195 | +GFitsImageFloat::GFitsImageFloat(const GFitsImage& image) : | |
| 196 | + GFitsImage(image) | |
| 197 | +{ | |
| 198 | + // Initialise class members | |
| 199 | + init_members(); | |
| 200 | + | |
| 201 | + // Copy pixels | |
| 202 | + if (m_num_pixels > 0) { | |
| 203 | + m_pixels = new float[m_num_pixels]; | |
| 204 | + for (int i = 0; i < m_num_pixels; ++i) { | |
| 205 | + m_pixels[i] = (float)image.pixel(i); | |
| 206 | + } | |
| 207 | + } | |
| 208 | + | |
| 209 | + // Set number of bits per pixel | |
| 210 | + m_bitpix = G_BITPIX; | |
| 211 | + | |
| 212 | + // Update header card | |
| 213 | + header()["BITPIX"].value(G_BITPIX); | |
| 214 | + | |
| 215 | + // Return | |
| 216 | + return; | |
| 217 | +} | |
| 218 | + | |
| 219 | + | |
| 220 | +/***********************************************************************//** | |
| 188 | 221 | * @brief Copy constructor |
| 189 | 222 | * |
| 190 | 223 | * @param[in] image FITS image. |
| ... | ... | @@ -192,7 +225,7 @@ GFitsImageFloat::GFitsImageFloat(const std::vector<int>& naxes, |
| 192 | 225 | GFitsImageFloat::GFitsImageFloat(const GFitsImageFloat& image) : |
| 193 | 226 | GFitsImage(image) |
| 194 | 227 | { |
| 195 | - // Initialise class members for clean destruction | |
| 228 | + // Initialise class members | |
| 196 | 229 | init_members(); |
| 197 | 230 | |
| 198 | 231 | // Copy members | ... | ... |
src/fits/GFitsImageLong.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageLong.cpp - Long integer FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | ***************************************************************************/ |
| 55 | 55 | GFitsImageLong::GFitsImageLong(void) : GFitsImage() |
| 56 | 56 | { |
| 57 | - // Initialise class members for clean destruction | |
| 57 | + // Initialise class members | |
| 58 | 58 | init_members(); |
| 59 | 59 | |
| 60 | 60 | // Return |
| ... | ... | @@ -73,7 +73,7 @@ GFitsImageLong::GFitsImageLong(void) : GFitsImage() |
| 73 | 73 | GFitsImageLong::GFitsImageLong(const int& nx, const long* pixels) : |
| 74 | 74 | GFitsImage(G_BITPIX, nx) |
| 75 | 75 | { |
| 76 | - // Initialise class members for clean destruction | |
| 76 | + // Initialise class members | |
| 77 | 77 | init_members(); |
| 78 | 78 | |
| 79 | 79 | // Construct data |
| ... | ... | @@ -96,7 +96,7 @@ GFitsImageLong::GFitsImageLong(const int& nx, const long* pixels) : |
| 96 | 96 | GFitsImageLong::GFitsImageLong(const int& nx, const int& ny, const long* pixels) : |
| 97 | 97 | GFitsImage(G_BITPIX, nx, ny) |
| 98 | 98 | { |
| 99 | - // Initialise class members for clean destruction | |
| 99 | + // Initialise class members | |
| 100 | 100 | init_members(); |
| 101 | 101 | |
| 102 | 102 | // Construct data |
| ... | ... | @@ -121,7 +121,7 @@ GFitsImageLong::GFitsImageLong(const int& nx, const int& ny, const int& nz, |
| 121 | 121 | const long* pixels) : |
| 122 | 122 | GFitsImage(G_BITPIX, nx, ny, nz) |
| 123 | 123 | { |
| 124 | - // Initialise class members for clean destruction | |
| 124 | + // Initialise class members | |
| 125 | 125 | init_members(); |
| 126 | 126 | |
| 127 | 127 | // Construct data |
| ... | ... | @@ -147,7 +147,7 @@ GFitsImageLong::GFitsImageLong(const int& nx, const int& ny, const int& nz, |
| 147 | 147 | const int& nt, const long* pixels) : |
| 148 | 148 | GFitsImage(G_BITPIX, nx, ny, nz, nt) |
| 149 | 149 | { |
| 150 | - // Initialise class members for clean destruction | |
| 150 | + // Initialise class members | |
| 151 | 151 | init_members(); |
| 152 | 152 | |
| 153 | 153 | // Construct data |
| ... | ... | @@ -172,7 +172,7 @@ GFitsImageLong::GFitsImageLong(const std::vector<int>& naxes, |
| 172 | 172 | const long* pixels) : |
| 173 | 173 | GFitsImage(G_BITPIX, naxes) |
| 174 | 174 | { |
| 175 | - // Initialise class members for clean destruction | |
| 175 | + // Initialise class members | |
| 176 | 176 | init_members(); |
| 177 | 177 | |
| 178 | 178 | // Construct data |
| ... | ... | @@ -184,6 +184,39 @@ GFitsImageLong::GFitsImageLong(const std::vector<int>& naxes, |
| 184 | 184 | |
| 185 | 185 | |
| 186 | 186 | /***********************************************************************//** |
| 187 | + * @brief Type conversion constructor | |
| 188 | + * | |
| 189 | + * @param[in] image FITS image. | |
| 190 | + * | |
| 191 | + * This constructor performs the conversion of any image type into a long | |
| 192 | + * integer image. | |
| 193 | + ***************************************************************************/ | |
| 194 | +GFitsImageLong::GFitsImageLong(const GFitsImage& image) : | |
| 195 | + GFitsImage(image) | |
| 196 | +{ | |
| 197 | + // Initialise class members | |
| 198 | + init_members(); | |
| 199 | + | |
| 200 | + // Copy pixels | |
| 201 | + if (m_num_pixels > 0) { | |
| 202 | + m_pixels = new long[m_num_pixels]; | |
| 203 | + for (int i = 0; i < m_num_pixels; ++i) { | |
| 204 | + m_pixels[i] = (long)image.pixel(i); | |
| 205 | + } | |
| 206 | + } | |
| 207 | + | |
| 208 | + // Set number of bits per pixel | |
| 209 | + m_bitpix = G_BITPIX; | |
| 210 | + | |
| 211 | + // Update header card | |
| 212 | + header()["BITPIX"].value(G_BITPIX); | |
| 213 | + | |
| 214 | + // Return | |
| 215 | + return; | |
| 216 | +} | |
| 217 | + | |
| 218 | + | |
| 219 | +/***********************************************************************//** | |
| 187 | 220 | * @brief Copy constructor |
| 188 | 221 | * |
| 189 | 222 | * @param[in] image FITS image. |
| ... | ... | @@ -191,7 +224,7 @@ GFitsImageLong::GFitsImageLong(const std::vector<int>& naxes, |
| 191 | 224 | GFitsImageLong::GFitsImageLong(const GFitsImageLong& image) : |
| 192 | 225 | GFitsImage(image) |
| 193 | 226 | { |
| 194 | - // Initialise class members for clean destruction | |
| 227 | + // Initialise class members | |
| 195 | 228 | init_members(); |
| 196 | 229 | |
| 197 | 230 | // Copy members |
| ... | ... | @@ -237,7 +270,7 @@ GFitsImageLong& GFitsImageLong::operator=(const GFitsImageLong& image) |
| 237 | 270 | // Free members |
| 238 | 271 | free_members(); |
| 239 | 272 | |
| 240 | - // Initialise private members for clean destruction | |
| 273 | + // Initialise private members | |
| 241 | 274 | init_members(); |
| 242 | 275 | |
| 243 | 276 | // Copy members | ... | ... |
src/fits/GFitsImageLongLong.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageLongLong.cpp - Long long integer FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | ***************************************************************************/ |
| 55 | 55 | GFitsImageLongLong::GFitsImageLongLong(void) : GFitsImage() |
| 56 | 56 | { |
| 57 | - // Initialise class members for clean destruction | |
| 57 | + // Initialise class members | |
| 58 | 58 | init_members(); |
| 59 | 59 | |
| 60 | 60 | // Return |
| ... | ... | @@ -73,7 +73,7 @@ GFitsImageLongLong::GFitsImageLongLong(void) : GFitsImage() |
| 73 | 73 | GFitsImageLongLong::GFitsImageLongLong(const int& nx, const long long* pixels) : |
| 74 | 74 | GFitsImage(G_BITPIX, nx) |
| 75 | 75 | { |
| 76 | - // Initialise class members for clean destruction | |
| 76 | + // Initialise class members | |
| 77 | 77 | init_members(); |
| 78 | 78 | |
| 79 | 79 | // Construct data |
| ... | ... | @@ -97,7 +97,7 @@ GFitsImageLongLong::GFitsImageLongLong(const int& nx, const int& ny, |
| 97 | 97 | const long long* pixels) : |
| 98 | 98 | GFitsImage(G_BITPIX, nx, ny) |
| 99 | 99 | { |
| 100 | - // Initialise class members for clean destruction | |
| 100 | + // Initialise class members | |
| 101 | 101 | init_members(); |
| 102 | 102 | |
| 103 | 103 | // Construct data |
| ... | ... | @@ -123,7 +123,7 @@ GFitsImageLongLong::GFitsImageLongLong(const int& nx, const int& ny, |
| 123 | 123 | const long long* pixels) : |
| 124 | 124 | GFitsImage(G_BITPIX, nx, ny, nz) |
| 125 | 125 | { |
| 126 | - // Initialise class members for clean destruction | |
| 126 | + // Initialise class members | |
| 127 | 127 | init_members(); |
| 128 | 128 | |
| 129 | 129 | // Construct data |
| ... | ... | @@ -150,7 +150,7 @@ GFitsImageLongLong::GFitsImageLongLong(const int& nx, const int& ny, |
| 150 | 150 | const long long* pixels) : |
| 151 | 151 | GFitsImage(G_BITPIX, nx, ny, nz, nt) |
| 152 | 152 | { |
| 153 | - // Initialise class members for clean destruction | |
| 153 | + // Initialise class members | |
| 154 | 154 | init_members(); |
| 155 | 155 | |
| 156 | 156 | // Construct data |
| ... | ... | @@ -175,7 +175,7 @@ GFitsImageLongLong::GFitsImageLongLong(const std::vector<int>& naxes, |
| 175 | 175 | const long long* pixels) : |
| 176 | 176 | GFitsImage(G_BITPIX, naxes) |
| 177 | 177 | { |
| 178 | - // Initialise class members for clean destruction | |
| 178 | + // Initialise class members | |
| 179 | 179 | init_members(); |
| 180 | 180 | |
| 181 | 181 | // Construct data |
| ... | ... | @@ -187,6 +187,39 @@ GFitsImageLongLong::GFitsImageLongLong(const std::vector<int>& naxes, |
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | /***********************************************************************//** |
| 190 | + * @brief Type conversion constructor | |
| 191 | + * | |
| 192 | + * @param[in] image FITS image. | |
| 193 | + * | |
| 194 | + * This constructor performs the conversion of any image type into a long | |
| 195 | + * long integer image. | |
| 196 | + ***************************************************************************/ | |
| 197 | +GFitsImageLongLong::GFitsImageLongLong(const GFitsImage& image) : | |
| 198 | + GFitsImage(image) | |
| 199 | +{ | |
| 200 | + // Initialise class members | |
| 201 | + init_members(); | |
| 202 | + | |
| 203 | + // Copy pixels | |
| 204 | + if (m_num_pixels > 0) { | |
| 205 | + m_pixels = new long long[m_num_pixels]; | |
| 206 | + for (int i = 0; i < m_num_pixels; ++i) { | |
| 207 | + m_pixels[i] = (long long)image.pixel(i); | |
| 208 | + } | |
| 209 | + } | |
| 210 | + | |
| 211 | + // Set number of bits per pixel | |
| 212 | + m_bitpix = G_BITPIX; | |
| 213 | + | |
| 214 | + // Update header card | |
| 215 | + header()["BITPIX"].value(G_BITPIX); | |
| 216 | + | |
| 217 | + // Return | |
| 218 | + return; | |
| 219 | +} | |
| 220 | + | |
| 221 | + | |
| 222 | +/***********************************************************************//** | |
| 190 | 223 | * @brief Copy constructor |
| 191 | 224 | * |
| 192 | 225 | * @param[in] image FITS image. |
| ... | ... | @@ -194,7 +227,7 @@ GFitsImageLongLong::GFitsImageLongLong(const std::vector<int>& naxes, |
| 194 | 227 | GFitsImageLongLong::GFitsImageLongLong(const GFitsImageLongLong& image) : |
| 195 | 228 | GFitsImage(image) |
| 196 | 229 | { |
| 197 | - // Initialise class members for clean destruction | |
| 230 | + // Initialise class members | |
| 198 | 231 | init_members(); |
| 199 | 232 | |
| 200 | 233 | // Copy members |
| ... | ... | @@ -240,7 +273,7 @@ GFitsImageLongLong& GFitsImageLongLong::operator=(const GFitsImageLongLong& imag |
| 240 | 273 | // Free members |
| 241 | 274 | free_members(); |
| 242 | 275 | |
| 243 | - // Initialise private members for clean destruction | |
| 276 | + // Initialise private members | |
| 244 | 277 | init_members(); |
| 245 | 278 | |
| 246 | 279 | // Copy members | ... | ... |
src/fits/GFitsImageSByte.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageSByte.cpp - Signed Byte FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | ***************************************************************************/ |
| 55 | 55 | GFitsImageSByte::GFitsImageSByte(void) : GFitsImage() |
| 56 | 56 | { |
| 57 | - // Initialise class members for clean destruction | |
| 57 | + // Initialise class members | |
| 58 | 58 | init_members(); |
| 59 | 59 | |
| 60 | 60 | // Return |
| ... | ... | @@ -73,7 +73,7 @@ GFitsImageSByte::GFitsImageSByte(void) : GFitsImage() |
| 73 | 73 | GFitsImageSByte::GFitsImageSByte(const int& nx, const char* pixels) : |
| 74 | 74 | GFitsImage(G_BITPIX, nx) |
| 75 | 75 | { |
| 76 | - // Initialise class members for clean destruction | |
| 76 | + // Initialise class members | |
| 77 | 77 | init_members(); |
| 78 | 78 | |
| 79 | 79 | // Construct data |
| ... | ... | @@ -97,7 +97,7 @@ GFitsImageSByte::GFitsImageSByte(const int& nx, const int& ny, |
| 97 | 97 | const char* pixels) : |
| 98 | 98 | GFitsImage(G_BITPIX, nx, ny) |
| 99 | 99 | { |
| 100 | - // Initialise class members for clean destruction | |
| 100 | + // Initialise class members | |
| 101 | 101 | init_members(); |
| 102 | 102 | |
| 103 | 103 | // Construct data |
| ... | ... | @@ -122,7 +122,7 @@ GFitsImageSByte::GFitsImageSByte(const int& nx, const int& ny, const int& nz, |
| 122 | 122 | const char* pixels) : |
| 123 | 123 | GFitsImage(G_BITPIX, nx, ny, nz) |
| 124 | 124 | { |
| 125 | - // Initialise class members for clean destruction | |
| 125 | + // Initialise class members | |
| 126 | 126 | init_members(); |
| 127 | 127 | |
| 128 | 128 | // Construct data |
| ... | ... | @@ -149,7 +149,7 @@ GFitsImageSByte::GFitsImageSByte(const int& nx, const int& ny, const int& nz, |
| 149 | 149 | const char* pixels) : |
| 150 | 150 | GFitsImage(G_BITPIX, nx, ny, nz, nt) |
| 151 | 151 | { |
| 152 | - // Initialise class members for clean destruction | |
| 152 | + // Initialise class members | |
| 153 | 153 | init_members(); |
| 154 | 154 | |
| 155 | 155 | // Construct data |
| ... | ... | @@ -174,7 +174,7 @@ GFitsImageSByte::GFitsImageSByte(const std::vector<int>& naxes, |
| 174 | 174 | const char* pixels) : |
| 175 | 175 | GFitsImage(G_BITPIX, naxes) |
| 176 | 176 | { |
| 177 | - // Initialise class members for clean destruction | |
| 177 | + // Initialise class members | |
| 178 | 178 | init_members(); |
| 179 | 179 | |
| 180 | 180 | // Construct data |
| ... | ... | @@ -186,6 +186,39 @@ GFitsImageSByte::GFitsImageSByte(const std::vector<int>& naxes, |
| 186 | 186 | |
| 187 | 187 | |
| 188 | 188 | /***********************************************************************//** |
| 189 | + * @brief Type conversion constructor | |
| 190 | + * | |
| 191 | + * @param[in] image FITS image. | |
| 192 | + * | |
| 193 | + * This constructor performs the conversion of any image type into a signed | |
| 194 | + * byte image. | |
| 195 | + ***************************************************************************/ | |
| 196 | +GFitsImageSByte::GFitsImageSByte(const GFitsImage& image) : | |
| 197 | + GFitsImage(image) | |
| 198 | +{ | |
| 199 | + // Initialise class members | |
| 200 | + init_members(); | |
| 201 | + | |
| 202 | + // Copy pixels | |
| 203 | + if (m_num_pixels > 0) { | |
| 204 | + m_pixels = new char[m_num_pixels]; | |
| 205 | + for (int i = 0; i < m_num_pixels; ++i) { | |
| 206 | + m_pixels[i] = (char)image.pixel(i); | |
| 207 | + } | |
| 208 | + } | |
| 209 | + | |
| 210 | + // Set number of bits per pixel | |
| 211 | + m_bitpix = G_BITPIX; | |
| 212 | + | |
| 213 | + // Update header card | |
| 214 | + header()["BITPIX"].value(G_BITPIX); | |
| 215 | + | |
| 216 | + // Return | |
| 217 | + return; | |
| 218 | +} | |
| 219 | + | |
| 220 | + | |
| 221 | +/***********************************************************************//** | |
| 189 | 222 | * @brief Copy constructor |
| 190 | 223 | * |
| 191 | 224 | * @param[in] image FITS image. |
| ... | ... | @@ -193,7 +226,7 @@ GFitsImageSByte::GFitsImageSByte(const std::vector<int>& naxes, |
| 193 | 226 | GFitsImageSByte::GFitsImageSByte(const GFitsImageSByte& image) : |
| 194 | 227 | GFitsImage(image) |
| 195 | 228 | { |
| 196 | - // Initialise class members for clean destruction | |
| 229 | + // Initialise class members | |
| 197 | 230 | init_members(); |
| 198 | 231 | |
| 199 | 232 | // Copy members |
| ... | ... | @@ -239,7 +272,7 @@ GFitsImageSByte& GFitsImageSByte::operator=(const GFitsImageSByte& image) |
| 239 | 272 | // Free members |
| 240 | 273 | free_members(); |
| 241 | 274 | |
| 242 | - // Initialise private members for clean destruction | |
| 275 | + // Initialise private members | |
| 243 | 276 | init_members(); |
| 244 | 277 | |
| 245 | 278 | // Copy members | ... | ... |
src/fits/GFitsImageShort.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageShort.cpp - Short integer FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | ***************************************************************************/ |
| 55 | 55 | GFitsImageShort::GFitsImageShort(void) : GFitsImage() |
| 56 | 56 | { |
| 57 | - // Initialise class members for clean destruction | |
| 57 | + // Initialise class members | |
| 58 | 58 | init_members(); |
| 59 | 59 | |
| 60 | 60 | // Return |
| ... | ... | @@ -73,7 +73,7 @@ GFitsImageShort::GFitsImageShort(void) : GFitsImage() |
| 73 | 73 | GFitsImageShort::GFitsImageShort(const int& nx, const short* pixels) : |
| 74 | 74 | GFitsImage(G_BITPIX, nx) |
| 75 | 75 | { |
| 76 | - // Initialise class members for clean destruction | |
| 76 | + // Initialise class members | |
| 77 | 77 | init_members(); |
| 78 | 78 | |
| 79 | 79 | // Construct data |
| ... | ... | @@ -97,7 +97,7 @@ GFitsImageShort::GFitsImageShort(const int& nx, const int& ny, |
| 97 | 97 | const short* pixels) : |
| 98 | 98 | GFitsImage(G_BITPIX, nx, ny) |
| 99 | 99 | { |
| 100 | - // Initialise class members for clean destruction | |
| 100 | + // Initialise class members | |
| 101 | 101 | init_members(); |
| 102 | 102 | |
| 103 | 103 | // Construct data |
| ... | ... | @@ -122,7 +122,7 @@ GFitsImageShort::GFitsImageShort(const int& nx, const int& ny, const int& nz, |
| 122 | 122 | const short* pixels) : |
| 123 | 123 | GFitsImage(G_BITPIX, nx, ny, nz) |
| 124 | 124 | { |
| 125 | - // Initialise class members for clean destruction | |
| 125 | + // Initialise class members | |
| 126 | 126 | init_members(); |
| 127 | 127 | |
| 128 | 128 | // Construct data |
| ... | ... | @@ -148,7 +148,7 @@ GFitsImageShort::GFitsImageShort(const int& nx, const int& ny, const int& nz, |
| 148 | 148 | const int& nt, const short* pixels) : |
| 149 | 149 | GFitsImage(G_BITPIX, nx, ny, nz, nt) |
| 150 | 150 | { |
| 151 | - // Initialise class members for clean destruction | |
| 151 | + // Initialise class members | |
| 152 | 152 | init_members(); |
| 153 | 153 | |
| 154 | 154 | // Construct data |
| ... | ... | @@ -173,7 +173,7 @@ GFitsImageShort::GFitsImageShort(const std::vector<int>& naxes, |
| 173 | 173 | const short* pixels) : |
| 174 | 174 | GFitsImage(G_BITPIX, naxes) |
| 175 | 175 | { |
| 176 | - // Initialise class members for clean destruction | |
| 176 | + // Initialise class members | |
| 177 | 177 | init_members(); |
| 178 | 178 | |
| 179 | 179 | // Construct data |
| ... | ... | @@ -185,6 +185,39 @@ GFitsImageShort::GFitsImageShort(const std::vector<int>& naxes, |
| 185 | 185 | |
| 186 | 186 | |
| 187 | 187 | /***********************************************************************//** |
| 188 | + * @brief Type conversion constructor | |
| 189 | + * | |
| 190 | + * @param[in] image FITS image. | |
| 191 | + * | |
| 192 | + * This constructor performs the conversion of any image type into a short | |
| 193 | + * integer image. | |
| 194 | + ***************************************************************************/ | |
| 195 | +GFitsImageShort::GFitsImageShort(const GFitsImage& image) : | |
| 196 | + GFitsImage(image) | |
| 197 | +{ | |
| 198 | + // Initialise class members | |
| 199 | + init_members(); | |
| 200 | + | |
| 201 | + // Copy pixels | |
| 202 | + if (m_num_pixels > 0) { | |
| 203 | + m_pixels = new short[m_num_pixels]; | |
| 204 | + for (int i = 0; i < m_num_pixels; ++i) { | |
| 205 | + m_pixels[i] = (short)image.pixel(i); | |
| 206 | + } | |
| 207 | + } | |
| 208 | + | |
| 209 | + // Set number of bits per pixel | |
| 210 | + m_bitpix = G_BITPIX; | |
| 211 | + | |
| 212 | + // Update header card | |
| 213 | + header()["BITPIX"].value(G_BITPIX); | |
| 214 | + | |
| 215 | + // Return | |
| 216 | + return; | |
| 217 | +} | |
| 218 | + | |
| 219 | + | |
| 220 | +/***********************************************************************//** | |
| 188 | 221 | * @brief Copy constructor |
| 189 | 222 | * |
| 190 | 223 | * @param[in] image FITS image. |
| ... | ... | @@ -192,7 +225,7 @@ GFitsImageShort::GFitsImageShort(const std::vector<int>& naxes, |
| 192 | 225 | GFitsImageShort::GFitsImageShort(const GFitsImageShort& image) : |
| 193 | 226 | GFitsImage(image) |
| 194 | 227 | { |
| 195 | - // Initialise class members for clean destruction | |
| 228 | + // Initialise class members | |
| 196 | 229 | init_members(); |
| 197 | 230 | |
| 198 | 231 | // Copy members | ... | ... |
src/fits/GFitsImageULong.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageULong.cpp - Unsigned long image FITS class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | ***************************************************************************/ |
| 55 | 55 | GFitsImageULong::GFitsImageULong(void) : GFitsImage() |
| 56 | 56 | { |
| 57 | - // Initialise class members for clean destruction | |
| 57 | + // Initialise class members | |
| 58 | 58 | init_members(); |
| 59 | 59 | |
| 60 | 60 | // Return |
| ... | ... | @@ -73,7 +73,7 @@ GFitsImageULong::GFitsImageULong(void) : GFitsImage() |
| 73 | 73 | GFitsImageULong::GFitsImageULong(const int& nx, const unsigned long* pixels) : |
| 74 | 74 | GFitsImage(G_BITPIX, nx) |
| 75 | 75 | { |
| 76 | - // Initialise class members for clean destruction | |
| 76 | + // Initialise class members | |
| 77 | 77 | init_members(); |
| 78 | 78 | |
| 79 | 79 | // Construct data |
| ... | ... | @@ -97,7 +97,7 @@ GFitsImageULong::GFitsImageULong(const int& nx, const int& ny, |
| 97 | 97 | const unsigned long* pixels) : |
| 98 | 98 | GFitsImage(G_BITPIX, nx, ny) |
| 99 | 99 | { |
| 100 | - // Initialise class members for clean destruction | |
| 100 | + // Initialise class members | |
| 101 | 101 | init_members(); |
| 102 | 102 | |
| 103 | 103 | // Construct data |
| ... | ... | @@ -122,7 +122,7 @@ GFitsImageULong::GFitsImageULong(const int& nx, const int& ny, const int& nz, |
| 122 | 122 | const unsigned long* pixels) : |
| 123 | 123 | GFitsImage(G_BITPIX, nx, ny, nz) |
| 124 | 124 | { |
| 125 | - // Initialise class members for clean destruction | |
| 125 | + // Initialise class members | |
| 126 | 126 | init_members(); |
| 127 | 127 | |
| 128 | 128 | // Construct data |
| ... | ... | @@ -149,7 +149,7 @@ GFitsImageULong::GFitsImageULong(const int& nx, const int& ny, const int& nz, |
| 149 | 149 | const unsigned long* pixels) : |
| 150 | 150 | GFitsImage(G_BITPIX, nx, ny, nz, nt) |
| 151 | 151 | { |
| 152 | - // Initialise class members for clean destruction | |
| 152 | + // Initialise class members | |
| 153 | 153 | init_members(); |
| 154 | 154 | |
| 155 | 155 | // Construct data |
| ... | ... | @@ -174,7 +174,7 @@ GFitsImageULong::GFitsImageULong(const std::vector<int>& naxes, |
| 174 | 174 | const unsigned long* pixels) : |
| 175 | 175 | GFitsImage(G_BITPIX, naxes) |
| 176 | 176 | { |
| 177 | - // Initialise class members for clean destruction | |
| 177 | + // Initialise class members | |
| 178 | 178 | init_members(); |
| 179 | 179 | |
| 180 | 180 | // Construct data |
| ... | ... | @@ -186,6 +186,39 @@ GFitsImageULong::GFitsImageULong(const std::vector<int>& naxes, |
| 186 | 186 | |
| 187 | 187 | |
| 188 | 188 | /***********************************************************************//** |
| 189 | + * @brief Type conversion constructor | |
| 190 | + * | |
| 191 | + * @param[in] image FITS image. | |
| 192 | + * | |
| 193 | + * This constructor performs the conversion of any image type into an | |
| 194 | + * unsigned long integer image. | |
| 195 | + ***************************************************************************/ | |
| 196 | +GFitsImageULong::GFitsImageULong(const GFitsImage& image) : | |
| 197 | + GFitsImage(image) | |
| 198 | +{ | |
| 199 | + // Initialise class members | |
| 200 | + init_members(); | |
| 201 | + | |
| 202 | + // Copy pixels | |
| 203 | + if (m_num_pixels > 0) { | |
| 204 | + m_pixels = new unsigned long[m_num_pixels]; | |
| 205 | + for (int i = 0; i < m_num_pixels; ++i) { | |
| 206 | + m_pixels[i] = (unsigned long)image.pixel(i); | |
| 207 | + } | |
| 208 | + } | |
| 209 | + | |
| 210 | + // Set number of bits per pixel | |
| 211 | + m_bitpix = G_BITPIX; | |
| 212 | + | |
| 213 | + // Update header card | |
| 214 | + header()["BITPIX"].value(G_BITPIX); | |
| 215 | + | |
| 216 | + // Return | |
| 217 | + return; | |
| 218 | +} | |
| 219 | + | |
| 220 | + | |
| 221 | +/***********************************************************************//** | |
| 189 | 222 | * @brief Copy constructor |
| 190 | 223 | * |
| 191 | 224 | * @param[in] image FITS image. |
| ... | ... | @@ -193,7 +226,7 @@ GFitsImageULong::GFitsImageULong(const std::vector<int>& naxes, |
| 193 | 226 | GFitsImageULong::GFitsImageULong(const GFitsImageULong& image) : |
| 194 | 227 | GFitsImage(image) |
| 195 | 228 | { |
| 196 | - // Initialise class members for clean destruction | |
| 229 | + // Initialise class members | |
| 197 | 230 | init_members(); |
| 198 | 231 | |
| 199 | 232 | // Copy members | ... | ... |
src/fits/GFitsImageUShort.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageUShort.cpp - Unsigned short FITS image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | ***************************************************************************/ |
| 55 | 55 | GFitsImageUShort::GFitsImageUShort(void) : GFitsImage() |
| 56 | 56 | { |
| 57 | - // Initialise class members for clean destruction | |
| 57 | + // Initialise class members | |
| 58 | 58 | init_members(); |
| 59 | 59 | |
| 60 | 60 | // Return |
| ... | ... | @@ -74,7 +74,7 @@ GFitsImageUShort::GFitsImageUShort(const int& nx, |
| 74 | 74 | const unsigned short* pixels) : |
| 75 | 75 | GFitsImage(G_BITPIX, nx) |
| 76 | 76 | { |
| 77 | - // Initialise class members for clean destruction | |
| 77 | + // Initialise class members | |
| 78 | 78 | init_members(); |
| 79 | 79 | |
| 80 | 80 | // Construct data |
| ... | ... | @@ -98,7 +98,7 @@ GFitsImageUShort::GFitsImageUShort(const int& nx, const int& ny, |
| 98 | 98 | const unsigned short* pixels) : |
| 99 | 99 | GFitsImage(G_BITPIX, nx, ny) |
| 100 | 100 | { |
| 101 | - // Initialise class members for clean destruction | |
| 101 | + // Initialise class members | |
| 102 | 102 | init_members(); |
| 103 | 103 | |
| 104 | 104 | // Construct data |
| ... | ... | @@ -123,7 +123,7 @@ GFitsImageUShort::GFitsImageUShort(const int& nx, const int& ny, const int& nz, |
| 123 | 123 | const unsigned short* pixels) : |
| 124 | 124 | GFitsImage(G_BITPIX, nx, ny, nz) |
| 125 | 125 | { |
| 126 | - // Initialise class members for clean destruction | |
| 126 | + // Initialise class members | |
| 127 | 127 | init_members(); |
| 128 | 128 | |
| 129 | 129 | // Construct data |
| ... | ... | @@ -150,7 +150,7 @@ GFitsImageUShort::GFitsImageUShort(const int& nx, const int& ny, |
| 150 | 150 | const unsigned short* pixels) : |
| 151 | 151 | GFitsImage(G_BITPIX, nx, ny, nz, nt) |
| 152 | 152 | { |
| 153 | - // Initialise class members for clean destruction | |
| 153 | + // Initialise class members | |
| 154 | 154 | init_members(); |
| 155 | 155 | |
| 156 | 156 | // Construct data |
| ... | ... | @@ -175,7 +175,7 @@ GFitsImageUShort::GFitsImageUShort(const std::vector<int>& naxes, |
| 175 | 175 | const unsigned short* pixels) : |
| 176 | 176 | GFitsImage(G_BITPIX, naxes) |
| 177 | 177 | { |
| 178 | - // Initialise class members for clean destruction | |
| 178 | + // Initialise class members | |
| 179 | 179 | init_members(); |
| 180 | 180 | |
| 181 | 181 | // Construct data |
| ... | ... | @@ -187,6 +187,39 @@ GFitsImageUShort::GFitsImageUShort(const std::vector<int>& naxes, |
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | /***********************************************************************//** |
| 190 | + * @brief Type conversion constructor | |
| 191 | + * | |
| 192 | + * @param[in] image FITS image. | |
| 193 | + * | |
| 194 | + * This constructor performs the conversion of any image type into an | |
| 195 | + * unsigned short integer image. | |
| 196 | + ***************************************************************************/ | |
| 197 | +GFitsImageUShort::GFitsImageUShort(const GFitsImage& image) : | |
| 198 | + GFitsImage(image) | |
| 199 | +{ | |
| 200 | + // Initialise class members | |
| 201 | + init_members(); | |
| 202 | + | |
| 203 | + // Copy pixels | |
| 204 | + if (m_num_pixels > 0) { | |
| 205 | + m_pixels = new unsigned short[m_num_pixels]; | |
| 206 | + for (int i = 0; i < m_num_pixels; ++i) { | |
| 207 | + m_pixels[i] = (unsigned short)image.pixel(i); | |
| 208 | + } | |
| 209 | + } | |
| 210 | + | |
| 211 | + // Set number of bits per pixel | |
| 212 | + m_bitpix = G_BITPIX; | |
| 213 | + | |
| 214 | + // Update header card | |
| 215 | + header()["BITPIX"].value(G_BITPIX); | |
| 216 | + | |
| 217 | + // Return | |
| 218 | + return; | |
| 219 | +} | |
| 220 | + | |
| 221 | + | |
| 222 | +/***********************************************************************//** | |
| 190 | 223 | * @brief Copy constructor |
| 191 | 224 | * |
| 192 | 225 | * @param[in] image FITS image. |
| ... | ... | @@ -194,7 +227,7 @@ GFitsImageUShort::GFitsImageUShort(const std::vector<int>& naxes, |
| 194 | 227 | GFitsImageUShort::GFitsImageUShort(const GFitsImageUShort& image) : |
| 195 | 228 | GFitsImage(image) |
| 196 | 229 | { |
| 197 | - // Initialise class members for clean destruction | |
| 230 | + // Initialise class members | |
| 198 | 231 | init_members(); |
| 199 | 232 | |
| 200 | 233 | // Copy members | ... | ... |
test/test_GFits.py
| ... | ... | @@ -148,6 +148,17 @@ class Test(gammalib.GPythonTestSuite): |
| 148 | 148 | img8.extname("ULong") |
| 149 | 149 | img9.extname("UShort") |
| 150 | 150 | |
| 151 | + # Test image types by checking the bitpix values | |
| 152 | + self.test_value(img1.bitpix(), 8) | |
| 153 | + self.test_value(img2.bitpix(), -64) | |
| 154 | + self.test_value(img3.bitpix(), -32) | |
| 155 | + self.test_value(img4.bitpix(), 32) | |
| 156 | + self.test_value(img5.bitpix(), 64) | |
| 157 | + self.test_value(img6.bitpix(), 10) | |
| 158 | + self.test_value(img7.bitpix(), 16) | |
| 159 | + self.test_value(img8.bitpix(), 40) | |
| 160 | + self.test_value(img9.bitpix(), 20) | |
| 161 | + | |
| 151 | 162 | # Append images to FITS file |
| 152 | 163 | fits.append(img1) |
| 153 | 164 | fits.append(img2) |
| ... | ... | @@ -174,6 +185,17 @@ class Test(gammalib.GPythonTestSuite): |
| 174 | 185 | # Re-open FITS file |
| 175 | 186 | fits = gammalib.GFits(file1) |
| 176 | 187 | |
| 188 | + # Test image types by checking the bitpix values | |
| 189 | + self.test_value(fits[0].bitpix(), 8) | |
| 190 | + self.test_value(fits[1].bitpix(), -64) | |
| 191 | + self.test_value(fits[2].bitpix(), -32) | |
| 192 | + self.test_value(fits[3].bitpix(), 32) | |
| 193 | + self.test_value(fits[4].bitpix(), 64) | |
| 194 | + #self.test_value(fits[5].bitpix(), 10) # Not supported in older cfitsio | |
| 195 | + self.test_value(fits[5].bitpix(), 16) | |
| 196 | + self.test_value(fits[6].bitpix(), 40) | |
| 197 | + self.test_value(fits[7].bitpix(), 20) | |
| 198 | + | |
| 177 | 199 | # Get double precision image, take square root of pixel and save in |
| 178 | 200 | # another file |
| 179 | 201 | img_double = fits.image("Double") |
| ... | ... | @@ -187,6 +209,26 @@ class Test(gammalib.GPythonTestSuite): |
| 187 | 209 | # Close FITS file |
| 188 | 210 | fits.close() |
| 189 | 211 | |
| 212 | + # Test type conversion constructors | |
| 213 | + img = gammalib.GFitsImageByte(img6) | |
| 214 | + self.test_value(img.bitpix(), 8) | |
| 215 | + img = gammalib.GFitsImageDouble(img1) | |
| 216 | + self.test_value(img.bitpix(), -64) | |
| 217 | + img = gammalib.GFitsImageFloat(img1) | |
| 218 | + self.test_value(img.bitpix(), -32) | |
| 219 | + img = gammalib.GFitsImageLong(img1) | |
| 220 | + self.test_value(img.bitpix(), 32) | |
| 221 | + img = gammalib.GFitsImageLongLong(img1) | |
| 222 | + self.test_value(img.bitpix(), 64) | |
| 223 | + img = gammalib.GFitsImageSByte(img1) | |
| 224 | + self.test_value(img.bitpix(), 10) | |
| 225 | + img = gammalib.GFitsImageShort(img1) | |
| 226 | + self.test_value(img.bitpix(), 16) | |
| 227 | + img = gammalib.GFitsImageULong(img1) | |
| 228 | + self.test_value(img.bitpix(), 40) | |
| 229 | + img = gammalib.GFitsImageUShort(img1) | |
| 230 | + self.test_value(img.bitpix(), 20) | |
| 231 | + | |
| 190 | 232 | # Return |
| 191 | 233 | return |
| 192 | 234 | |
| ... | ... | @@ -355,4 +397,4 @@ class Test(gammalib.GPythonTestSuite): |
| 355 | 397 | |
| 356 | 398 | # Return |
| 357 | 399 | return |
| 358 | - | |
| 359 | 400 | \ No newline at end of file |
| 401 | + | ... | ... |