GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
GFitsImageDouble.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * GFitsImageDouble.cpp - Double precision FITS image class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2008-2018 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file GFitsImageDouble.cpp
23 * @brief Double precision FITS image class implementation
24 * @author Juergen Knoedlseder
25 */
26
27/* __ Includes ___________________________________________________________ */
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31#include "GException.hpp"
32#include "GFitsCfitsio.hpp"
33#include "GFitsImageDouble.hpp"
34
35/* __ Method name definitions ____________________________________________ */
36
37/* __ Macros _____________________________________________________________ */
38#define G_BITPIX -64 //!< Defines the number of bits per pixel
39
40/* __ Coding definitions _________________________________________________ */
41
42/* __ Debug definitions __________________________________________________ */
43
44
45
46/*==========================================================================
47 = =
48 = Constructors/destructors =
49 = =
50 ==========================================================================*/
51
52/***********************************************************************//**
53 * @brief Void constructor
54 ***************************************************************************/
56{
57 // Initialise class members
59
60 // Return
61 return;
62}
63
64
65/***********************************************************************//**
66 * @brief 1D image constructor
67 *
68 * @param[in] nx Number of pixels.
69 * @param[in] pixels Optional pointer to image pixel array
70 *
71 * Construct 1D instance by specifying the number of pixels in the image.
72 ***************************************************************************/
73GFitsImageDouble::GFitsImageDouble(const int& nx, const double* pixels) :
75{
76 // Initialise class members
78
79 // Construct data
81
82 // Return
83 return;
84}
85
86
87/***********************************************************************//**
88 * @brief 2D image constructor
89 *
90 * @param[in] nx Number of pixels in first dimension.
91 * @param[in] ny Number of pixels in second dimension.
92 * @param[in] pixels Optional pointer to image pixel array
93 *
94 * Construct 2D image by specifying the number of pixels in each dimension.
95 ***************************************************************************/
96GFitsImageDouble::GFitsImageDouble(const int& nx, const int& ny,
97 const double* pixels) :
98 GFitsImage(G_BITPIX, nx, ny)
99{
100 // Initialise class members
101 init_members();
102
103 // Construct data
105
106 // Return
107 return;
108}
109
110
111/***********************************************************************//**
112 * @brief 3D image constructor
113 *
114 * @param[in] nx Number of pixels in first dimension.
115 * @param[in] ny Number of pixels in second dimension.
116 * @param[in] nz Number of pixels in third dimension.
117 * @param[in] pixels Optional pointer to image pixel array
118 *
119 * Construct 3D image by specifying the number of pixels in each dimension.
120 ***************************************************************************/
121GFitsImageDouble::GFitsImageDouble(const int& nx, const int& ny, const int& nz,
122 const double* pixels) :
123 GFitsImage(G_BITPIX, nx, ny, nz)
124{
125 // Initialise class members
126 init_members();
127
128 // Construct data
130
131 // Return
132 return;
133}
134
135
136/***********************************************************************//**
137 * @brief 4D image constructor
138 *
139 * @param[in] nx Number of pixels in first dimension.
140 * @param[in] ny Number of pixels in second dimension.
141 * @param[in] nz Number of pixels in third dimension.
142 * @param[in] nt Number of pixels in forth dimension.
143 * @param[in] pixels Optional pointer to image pixel array
144 *
145 * Construct 4D image by specifying the number of pixels in each dimension.
146 ***************************************************************************/
147GFitsImageDouble::GFitsImageDouble(const int& nx, const int& ny, const int& nz,
148 const int& nt, const double* pixels) :
149 GFitsImage(G_BITPIX, nx, ny, nz, nt)
150{
151 // Initialise class members
152 init_members();
153
154 // Construct data
156
157 // Return
158 return;
159}
160
161
162/***********************************************************************//**
163 * @brief Pixel array constructor
164 *
165 * @param[in] naxes Vector of number of pixels in each dimension.
166 * @param[in] pixels Optional pointer to image pixel array
167 *
168 * Construct instance of GFitsImageDouble by specifying the image dimension and
169 * the number of pixels in each dimension.
170 ***************************************************************************/
171GFitsImageDouble::GFitsImageDouble(const std::vector<int>& naxes,
172 const double* pixels) :
173 GFitsImage(G_BITPIX, naxes)
174{
175 // Initialise class members
176 init_members();
177
178 // Construct data
180
181 // Return
182 return;
183}
184
185
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 double
192 * precision floating point image.
193 ***************************************************************************/
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 double[m_num_pixels];
203 for (int i = 0; i < m_num_pixels; ++i) {
204 m_pixels[i] = (double)image.pixel(i);
205 }
206 }
207
208 // Set number of bits per pixel
210
211 // Update header card
212 card("BITPIX").value(G_BITPIX);
213
214 // Return
215 return;
216}
217
218
219
220
221/***********************************************************************//**
222 * @brief Copy constructor
223 *
224 * @param[in] image FITS image.
225 ***************************************************************************/
227 GFitsImage(image)
228{
229 // Initialise class members
230 init_members();
231
232 // Copy members
233 copy_members(image);
234
235 // Return
236 return;
237}
238
239
240/***********************************************************************//**
241 * @brief Destructor
242 ***************************************************************************/
244{
245 // Free members
246 free_members();
247
248 // Return
249 return;
250}
251
252
253/*==========================================================================
254 = =
255 = Operators =
256 = =
257 ==========================================================================*/
258
259/***********************************************************************//**
260 * @brief Assignment operator
261 *
262 * @param[in] image FITS image.
263 ***************************************************************************/
265{
266 // Execute only if object is not identical
267 if (this != &image) {
268
269 // Copy base class members
270 this->GFitsImage::operator=(image);
271
272 // Free members
273 free_members();
274
275 // Initialise private members
276 init_members();
277
278 // Copy members
279 copy_members(image);
280
281 } // endif: object was not identical
282
283 // Return this object
284 return *this;
285}
286
287
288/***********************************************************************//**
289 * @brief Image pixel access operator
290 *
291 * @param[in] ix Pixel index (starting from 0).
292 *
293 * Provides access to an image pixel. No range checking is performed.
294 * Use the at(ix) method if range checking is required.
295 ***************************************************************************/
296double& GFitsImageDouble::operator()(const int& ix)
297{
298 // If image pixels are not available then fetch them now
299 load_data();
300
301 // Return image pixel
302 return m_pixels[ix];
303}
304
305
306/***********************************************************************//**
307 * @brief 2D image pixel access operator
308 *
309 * @param[in] ix Pixel index in first dimension (starting from 0).
310 * @param[in] iy Pixel index in second dimension (starting from 0).
311 *
312 * Provides access to a pixel of a 2D image. No range checking or image
313 * dimension verification is performed. Use the at(ix,iy) method if range
314 * checking and image dimension verification is required.
315 ***************************************************************************/
316double& GFitsImageDouble::operator()(const int& ix, const int& iy)
317{
318 // If image pixels are not available then allocate them now
319 load_data();
320
321 // Calculate pixel offset
322 int offset = ix + iy * m_naxes[0];
323
324 // Return image pixel
325 return m_pixels[offset];
326}
327
328
329/***********************************************************************//**
330 * @brief 3D image pixel access operator
331 *
332 * @param[in] ix Pixel index in first dimension (starting from 0).
333 * @param[in] iy Pixel index in second dimension (starting from 0).
334 * @param[in] iz Pixel index in third dimension (starting from 0).
335 *
336 * Provides access to a pixel of a 3D image. No range checking or image
337 * dimension verification is performed. Use the at(ix,iy) method if range
338 * checking and image dimension verification is required.
339 ***************************************************************************/
340double& GFitsImageDouble::operator()(const int& ix, const int& iy,
341 const int& iz)
342{
343 // If image pixels are not available then allocate them now
344 load_data();
345
346 // Calculate pixel offset
347 int offset = ix + m_naxes[0] * (iy + iz * m_naxes[1]);
348
349 // Return image pixel
350 return m_pixels[offset];
351}
352
353
354/***********************************************************************//**
355 * @brief 4D image pixel access operator
356 *
357 * @param[in] ix Pixel index in first dimension (starting from 0).
358 * @param[in] iy Pixel index in second dimension (starting from 0).
359 * @param[in] iz Pixel index in third dimension (starting from 0).
360 * @param[in] it Pixel index in forth dimension (starting from 0).
361 *
362 * Provides access to a pixel of a 4D image. No range checking or image
363 * dimension verification is performed. Use the at(ix,iy) method if range
364 * checking and image dimension verification is required.
365 ***************************************************************************/
366double& GFitsImageDouble::operator()(const int& ix, const int& iy,
367 const int& iz, const int& it)
368{
369 // If image pixels are not available then allocate them now
370 load_data();
371
372 // Calculate pixel offset
373 int offset = ix + m_naxes[0] * (iy + m_naxes[1] * (iz + it * m_naxes[2]));
374
375 // Return image pixel
376 return m_pixels[offset];
377}
378
379
380/***********************************************************************//**
381 * @brief Image pixel access operator (const variant)
382 *
383 * @param[in] ix Pixel index (starting from 0).
384 *
385 * Provides access to an image pixel. No range checking is performed.
386 * Use the at(ix) method if range checking is required.
387 ***************************************************************************/
388const double& GFitsImageDouble::operator()(const int& ix) const
389{
390 // If image pixels are not available then fetch them now
391 load_data();
392
393 // Return image pixel
394 return m_pixels[ix];
395}
396
397
398/***********************************************************************//**
399 * @brief 2D image pixel access operator (const variant)
400 *
401 * @param[in] ix Pixel index in first dimension (starting from 0).
402 * @param[in] iy Pixel index in second dimension (starting from 0).
403 *
404 * Provides access to a pixel of a 2D image. No range checking or image
405 * dimension verification is performed. Use the at(ix,iy) method if range
406 * checking and image dimension verification is required.
407 ***************************************************************************/
408const double& GFitsImageDouble::operator()(const int& ix, const int& iy) const
409{
410 // If image pixels are not available then allocate them now
411 load_data();
412
413 // Calculate pixel offset
414 int offset = ix + iy * m_naxes[0];
415
416 // Return image pixel
417 return m_pixels[offset];
418}
419
420
421/***********************************************************************//**
422 * @brief 3D image pixel access operator (const variant)
423 *
424 * @param[in] ix Pixel index in first dimension (starting from 0).
425 * @param[in] iy Pixel index in second dimension (starting from 0).
426 * @param[in] iz Pixel index in third dimension (starting from 0).
427 *
428 * Provides access to a pixel of a 3D image. No range checking or image
429 * dimension verification is performed. Use the at(ix,iy) method if range
430 * checking and image dimension verification is required.
431 ***************************************************************************/
432const double& GFitsImageDouble::operator()(const int& ix, const int& iy,
433 const int& iz) const
434{
435 // If image pixels are not available then allocate them now
436 load_data();
437
438 // Calculate pixel offset
439 int offset = ix + m_naxes[0] * (iy + iz * m_naxes[1]);
440
441 // Return image pixel
442 return m_pixels[offset];
443}
444
445
446/***********************************************************************//**
447 * @brief 4D image pixel access operator (const variant)
448 *
449 * @param[in] ix Pixel index in first dimension (starting from 0).
450 * @param[in] iy Pixel index in second dimension (starting from 0).
451 * @param[in] iz Pixel index in third dimension (starting from 0).
452 * @param[in] it Pixel index in forth dimension (starting from 0).
453 *
454 * Provides access to a pixel of a 4D image. No range checking or image
455 * dimension verification is performed. Use the at(ix,iy) method if range
456 * checking and image dimension verification is required.
457 ***************************************************************************/
458const double& GFitsImageDouble::operator()(const int& ix, const int& iy,
459 const int& iz, const int& it) const
460{
461 // If image pixels are not available then allocate them now
462 load_data();
463
464 // Calculate pixel offset
465 int offset = ix + m_naxes[0] * (iy + m_naxes[1] * (iz + it * m_naxes[2]));
466
467 // Return image pixel
468 return m_pixels[offset];
469}
470
471
472/*==========================================================================
473 = =
474 = Public methods =
475 = =
476 ==========================================================================*/
477
478/***********************************************************************//**
479 * @brief Clear instance
480 *
481 * This method properly resets the object to an initial state.
482 ***************************************************************************/
484{
485 // Free class members (base and derived classes, derived class first)
486 free_members();
489
490 // Initialise members
493 init_members();
494
495 // Return
496 return;
497}
498
499
500/***********************************************************************//**
501 * @brief Clone FITS image
502 *
503 * Cloning provides a copy of the FITS file. Cloning is used to allocate
504 * derived classes into a base class pointer.
505 ***************************************************************************/
507{
508 // Clone this image
509 return new GFitsImageDouble(*this);
510}
511
512
513/***********************************************************************//**
514 * @brief Image pixel access operator
515 *
516 * @param[in] ix Pixel index (starting from 0).
517 *
518 * Provides access to a pixel of an image including range checking. Note that
519 * this method does not necessarily restrict do 1D images but generally
520 * applies to all image dimensions.
521 ***************************************************************************/
522double& GFitsImageDouble::at(const int& ix)
523{
524 // If image pixels are not available then allocate them now
525 load_data();
526
527 // Return image pixel
528 return (m_pixels[offset(ix)]);
529}
530
531
532/***********************************************************************//**
533 * @brief 2D image pixel access operator
534 *
535 * @param[in] ix Pixel index in first dimension (starting from 0).
536 * @param[in] iy Pixel index in second dimension (starting from 0).
537 *
538 * Provides access to a pixel of an image including range checking.
539 ***************************************************************************/
540double& GFitsImageDouble::at(const int& ix, const int& iy)
541{
542 // If image pixels are not available then allocate them now
543 load_data();
544
545 // Return image pixel
546 return (m_pixels[offset(ix,iy)]);
547}
548
549
550/***********************************************************************//**
551 * @brief 3D image pixel access operator
552 *
553 * @param[in] ix Pixel index in first dimension (starting from 0).
554 * @param[in] iy Pixel index in second dimension (starting from 0).
555 * @param[in] iz Pixel index in third dimension (starting from 0).
556 *
557 * Provides access to a pixel of an image including range checking.
558 ***************************************************************************/
559double& GFitsImageDouble::at(const int& ix, const int& iy, const int& iz)
560{
561 // If image pixels are not available then allocate them now
562 load_data();
563
564 // Return image pixel
565 return (m_pixels[offset(ix,iy,iz)]);
566}
567
568
569/***********************************************************************//**
570 * @brief 4D image pixel access operator
571 *
572 * @param[in] ix Pixel index in first dimension (starting from 0).
573 * @param[in] iy Pixel index in second dimension (starting from 0).
574 * @param[in] iz Pixel index in third dimension (starting from 0).
575 * @param[in] it Pixel index in forth dimension (starting from 0).
576 *
577 * Provides access to a pixel of an image including range checking.
578 ***************************************************************************/
579double& GFitsImageDouble::at(const int& ix, const int& iy, const int& iz,
580 const int& it)
581{
582 // If image pixels are not available then allocate them now
583 load_data();
584
585 // Return image pixel
586 return (m_pixels[offset(ix,iy,iz,it)]);
587}
588
589
590/***********************************************************************//**
591 * @brief Image pixel access operator (const variant)
592 *
593 * @param[in] ix Pixel index (starting from 0).
594 *
595 * Provides access to a pixel of an image including range checking.
596 ***************************************************************************/
597const double& GFitsImageDouble::at(const int& ix) const
598{
599 // If image pixels are not available then allocate them now
600 load_data();
601
602 // Return image pixel
603 return (m_pixels[offset(ix)]);
604}
605
606
607/***********************************************************************//**
608 * @brief 2D image pixel access operator (const variant)
609 *
610 * @param[in] ix Pixel index in first dimension (starting from 0).
611 * @param[in] iy Pixel index in second dimension (starting from 0).
612 *
613 * Provides access to a pixel of an image including range checking.
614 ***************************************************************************/
615const double& GFitsImageDouble::at(const int& ix, const int& iy) const
616{
617 // If image pixels are not available then allocate them now
618 load_data();
619
620 // Return image pixel
621 return (m_pixels[offset(ix,iy)]);
622}
623
624
625/***********************************************************************//**
626 * @brief 3D image pixel access operator (const variant)
627 *
628 * @param[in] ix Pixel index in first dimension (starting from 0).
629 * @param[in] iy Pixel index in second dimension (starting from 0).
630 * @param[in] iz Pixel index in third dimension (starting from 0).
631 *
632 * Provides access to a pixel of an image including range checking.
633 ***************************************************************************/
634const double& GFitsImageDouble::at(const int& ix, const int& iy,
635 const int& iz) const
636{
637 // If image pixels are not available then allocate them now
638 load_data();
639
640 // Return image pixel
641 return (m_pixels[offset(ix,iy,iz)]);
642}
643
644
645/***********************************************************************//**
646 * @brief 4D image pixel access operator (const variant)
647 *
648 * @param[in] ix Pixel index in first dimension (starting from 0).
649 * @param[in] iy Pixel index in second dimension (starting from 0).
650 * @param[in] iz Pixel index in third dimension (starting from 0).
651 * @param[in] it Pixel index in forth dimension (starting from 0).
652 *
653 * Provides access to a pixel of an image including range checking.
654 ***************************************************************************/
655const double& GFitsImageDouble::at(const int& ix, const int& iy,
656 const int& iz, const int& it) const
657{
658 // If image pixels are not available then allocate them now
659 load_data();
660
661 // Return image pixel
662 return (m_pixels[offset(ix,iy,iz,it)]);
663}
664
665
666/***********************************************************************//**
667 * @brief Return value of image pixel
668 *
669 * @param[in] ix Pixel index (starting from 0).
670 *
671 * Returns the value of an image pixel as double precision floating point
672 * value. This method performs range checking.
673 ***************************************************************************/
674double GFitsImageDouble::pixel(const int& ix) const
675{
676 // Return pixel value
677 return (double(this->at(ix)));
678}
679
680
681/***********************************************************************//**
682 * @brief Return value of image pixel (2D version)
683 *
684 * @param[in] ix Pixel index in first dimension (starting from 0).
685 * @param[in] iy Pixel index in second dimension (starting from 0).
686 *
687 * Returns the value of an image pixel as double precision floating point
688 * value. This method performs range checking.
689 ***************************************************************************/
690double GFitsImageDouble::pixel(const int& ix, const int& iy) const
691{
692 // Return pixel value
693 return (double(this->at(ix,iy)));
694}
695
696
697/***********************************************************************//**
698 * @brief Return value of image pixel (3D version)
699 *
700 * @param[in] ix Pixel index in first dimension (starting from 0).
701 * @param[in] iy Pixel index in second dimension (starting from 0).
702 * @param[in] iz Pixel index in third dimension (starting from 0).
703 *
704 * Returns the value of an image pixel as double precision floating point
705 * value. This method performs range checking.
706 ***************************************************************************/
707double GFitsImageDouble::pixel(const int& ix, const int& iy, const int& iz) const
708{
709 // Return pixel value
710 return (double(this->at(ix,iy,iz)));
711}
712
713
714/***********************************************************************//**
715 * @brief Return value of image pixel (4D version)
716 *
717 * @param[in] ix Pixel index in first dimension (starting from 0).
718 * @param[in] iy Pixel index in second dimension (starting from 0).
719 * @param[in] iz Pixel index in third dimension (starting from 0).
720 * @param[in] it Pixel index in forth dimension (starting from 0).
721 *
722 * Returns the value of an image pixel as double precision floating point
723 * value. This method performs range checking.
724 ***************************************************************************/
725double GFitsImageDouble::pixel(const int& ix, const int& iy, const int& iz,
726 const int& it) const
727{
728 // Return pixel value
729 return (double(this->at(ix,iy,iz,it)));
730}
731
732
733/***********************************************************************//**
734 * @brief Return pointer to image pixel
735 ***************************************************************************/
737{
738 // If image pixels are not available then allocate them now
739 load_data();
740
741 // Return
742 return m_pixels;
743}
744
745
746/***********************************************************************//**
747 * @brief Return image type
748 ***************************************************************************/
750{
751 // Return type
752 return __TDOUBLE;
753}
754
755
756/*==========================================================================
757 = =
758 = Private methods =
759 = =
760 ==========================================================================*/
761
762/***********************************************************************//**
763 * @brief Initialise class members
764 ***************************************************************************/
766{
767 // Initialise members
769 m_pixels = NULL;
770 m_nulval = NULL;
771
772 // Return
773 return;
774}
775
776
777/***********************************************************************//**
778 * @brief Copy class members
779 *
780 * @param image FITS image to copy
781 *
782 * Copy class members. If the pixel array is linked the pointer to the array
783 * is copied. Otherwise a copy of the image pixels will be created.
784 ***************************************************************************/
786{
787 // Fetch column data if not yet fetched. The casting circumvents the
788 // const correctness
789 bool not_loaded = (image.m_pixels == NULL);
790 if (not_loaded) {
791 const_cast<GFitsImageDouble*>(&image)->fetch_data();
792 }
793
794 // Copy pixels
795 if (m_num_pixels > 0 && image.m_pixels != NULL) {
796 m_pixels = new double[m_num_pixels];
797 for (int i = 0; i < m_num_pixels; ++i) {
798 m_pixels[i] = image.m_pixels[i];
799 }
800 }
801
802 // Copy NULL value
803 alloc_nulval(image.m_nulval);
804
805 // Small memory option: release image if it was fetched above
806 #if defined(G_SMALL_MEMORY)
807 if (not_loaded) {
808 const_cast<GFitsImageDouble*>(&image)->release_data();
809 }
810 #endif
811
812 // Return
813 return;
814}
815
816
817/***********************************************************************//**
818 * @brief Delete class members
819 ***************************************************************************/
821{
822 // Free memory
823 if (m_pixels != NULL) delete [] m_pixels;
824 if (m_nulval != NULL) delete m_nulval;
825
826 // Mark memory as free
827 m_pixels = NULL;
828 m_nulval = NULL;
829
830 // Return
831 return;
832}
833
834
835/***********************************************************************//**
836 * @brief Allocate data
837 ***************************************************************************/
839{
840 // Release any existing data
841 release_data();
842
843 // Allocate new data
844 if (m_num_pixels > 0) {
845 m_pixels = new double[m_num_pixels];
846 }
847
848 // Return
849 return;
850}
851
852
853/***********************************************************************//**
854 * @brief Initialise data
855 ***************************************************************************/
857{
858 // Initialise data if they exist
859 if (m_pixels != NULL) {
860 for (int i = 0; i < m_num_pixels; ++i) {
861 m_pixels[i] = 0.0;
862 }
863 }
864
865 // Return
866 return;
867}
868
869
870/***********************************************************************//**
871 * @brief Release data
872 ***************************************************************************/
874{
875 // Free any existing memory
876 if (m_pixels != NULL) delete [] m_pixels;
877
878 // Mark pointer as free
879 m_pixels = NULL;
880
881 // Return
882 return;
883}
884
885
886/***********************************************************************//**
887 * @brief Construct data from array
888 *
889 * @param[in] pixels Optional pointer to pixel array.
890 *
891 * Initialise pixel data from an optional pixel array. If the pointer is
892 * NULL the image is simply initialised. This method supports all
893 * constructors.
894 ***************************************************************************/
895void GFitsImageDouble::construct_data(const double* pixels)
896{
897 // If there are pixels then allocate array
898 if (m_num_pixels > 0) {
899
900 // Allocate data
901 alloc_data();
902
903 // If no pixel array has been specified then simply initialise data
904 if (pixels == NULL) {
905 init_data();
906 }
907
908 // ... otherwise copy pixels
909 else {
910 for (int i = 0; i < m_num_pixels; ++i) {
911 m_pixels[i] = pixels[i];
912 }
913 }
914
915 } // endif: there are pixels in image
916
917 // Return
918 return;
919}
920
921
922/***********************************************************************//**
923 * @brief Load data
924 *
925 * Load the image data if no pixels have been allocated.
926 ***************************************************************************/
928{
929 // If image pixels are not available then fetch them now.
930 if (m_pixels == NULL) {
931 const_cast<GFitsImageDouble*>(this)->fetch_data();
932 }
933
934 // Return
935 return;
936}
937
938
939/***********************************************************************//**
940 * @brief Allocates nul value
941 *
942 * @param[in] value Nul value.
943 ***************************************************************************/
944void GFitsImageDouble::alloc_nulval(const void* value)
945{
946 // Free any existing memory
947 if (m_nulval != NULL) delete m_nulval;
948
949 // Mark pointer as free
950 m_nulval = NULL;
951
952 // If we have valid value, allocate and set nul value
953 if (value != NULL) {
954 m_nulval = new double;
955 *m_nulval = *((double*)value);
956 }
957
958 // Return
959 return;
960}
Exception handler interface definition.
CFITSIO interface header.
#define __TDOUBLE
#define G_BITPIX
Defines the number of bits per pixel.
#define G_BITPIX
Defines the number of bits per pixel.
Double precision FITS image class definition.
void free_members(void)
Delete class members.
Definition GFitsHDU.cpp:505
void init_members(void)
Initialise class members.
Definition GFitsHDU.cpp:462
GFitsHeaderCard & card(const int &cardno)
Return header card.
Definition GFitsHDU.hpp:259
void value(const std::string &value)
Set string value of header card.
Double precision FITS image class.
GFitsImageDouble(void)
Void constructor.
GFitsImageDouble * clone(void) const
Clone FITS image.
virtual ~GFitsImageDouble(void)
Destructor.
void init_members(void)
Initialise class members.
void alloc_data(void)
Allocate data.
double * m_nulval
NULL value.
void copy_members(const GFitsImageDouble &image)
Copy class members.
void * pixels(void)
Return pointer to image pixel.
void alloc_nulval(const void *value)
Allocates nul value.
double pixel(const int &ix) const
Return value of image pixel.
double & at(const int &ix)
Image pixel access operator.
void load_data(void) const
Load data.
void clear(void)
Clear instance.
double * m_pixels
Pixels.
void release_data(void)
Release data.
double & operator()(const int &ix)
Image pixel access operator.
GFitsImageDouble & operator=(const GFitsImageDouble &image)
Assignment operator.
void construct_data(const double *pixels)
Construct data from array.
void init_data(void)
Initialise data.
void free_members(void)
Delete class members.
int type(void) const
Return image type.
Abstract FITS image base class.
virtual double pixel(const int &ix) const =0
int offset(const int &ix) const
Return pixel offset.
void free_members(void)
Delete class members.
void fetch_data(void)
Fetch image pixels.
long * m_naxes
Number of pixels in each dimension.
int m_bitpix
Number of Bits/pixel.
int m_num_pixels
Number of image pixels.
GFitsImage & operator=(const GFitsImage &image)
Assignment operator.
void init_members(void)
Initialise class members.