GammaLib 2.2.0.dev
Loading...
Searching...
No Matches
GFitsImageLong.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * GFitsImageLong.cpp - Long integer FITS image class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2010-2026 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 GFitsImageLong.cpp
23 * @brief Long integer 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 "GFitsImageLong.hpp"
34
35/* __ Method name definitions ____________________________________________ */
36
37/* __ Macros _____________________________________________________________ */
38#define G_BITPIX 32 //!< 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 ***************************************************************************/
73GFitsImageLong::GFitsImageLong(const int& nx, const long* 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 ***************************************************************************/
96GFitsImageLong::GFitsImageLong(const int& nx, const int& ny, const long* pixels) :
97 GFitsImage(G_BITPIX, nx, ny)
98{
99 // Initialise class members
100 init_members();
101
102 // Construct data
104
105 // Return
106 return;
107}
108
109
110/***********************************************************************//**
111 * @brief 3D image constructor
112 *
113 * @param[in] nx Number of pixels in first dimension.
114 * @param[in] ny Number of pixels in second dimension.
115 * @param[in] nz Number of pixels in third dimension.
116 * @param[in] pixels Optional pointer to image pixel array
117 *
118 * Construct 3D image by specifying the number of pixels in each dimension.
119 ***************************************************************************/
120GFitsImageLong::GFitsImageLong(const int& nx, const int& ny, const int& nz,
121 const long* pixels) :
122 GFitsImage(G_BITPIX, nx, ny, nz)
123{
124 // Initialise class members
125 init_members();
126
127 // Construct data
129
130 // Return
131 return;
132}
133
134
135/***********************************************************************//**
136 * @brief 4D image constructor
137 *
138 * @param[in] nx Number of pixels in first dimension.
139 * @param[in] ny Number of pixels in second dimension.
140 * @param[in] nz Number of pixels in third dimension.
141 * @param[in] nt Number of pixels in forth dimension.
142 * @param[in] pixels Optional pointer to image pixel array
143 *
144 * Construct 4D image by specifying the number of pixels in each dimension.
145 ***************************************************************************/
146GFitsImageLong::GFitsImageLong(const int& nx, const int& ny, const int& nz,
147 const int& nt, const long* pixels) :
148 GFitsImage(G_BITPIX, nx, ny, nz, nt)
149{
150 // Initialise class members
151 init_members();
152
153 // Construct data
155
156 // Return
157 return;
158}
159
160
161/***********************************************************************//**
162 * @brief Pixel array constructor
163 *
164 * @param[in] naxes Vector of number of pixels in each dimension.
165 * @param[in] pixels Optional pointer to image pixel array
166 *
167 * Construct instance of GFitsImageLong by specifying the image dimension and
168 * the number of pixels in each dimension.
169 ***************************************************************************/
170GFitsImageLong::GFitsImageLong(const std::vector<int>& naxes,
171 const long* pixels) :
172 GFitsImage(G_BITPIX, naxes)
173{
174 // Initialise class members
175 init_members();
176
177 // Construct data
179
180 // Return
181 return;
182}
183
184
185/***********************************************************************//**
186 * @brief Type conversion constructor
187 *
188 * @param[in] image FITS image.
189 *
190 * This constructor performs the conversion of any image type into a long
191 * integer image.
192 ***************************************************************************/
194 GFitsImage(image)
195{
196 // Initialise class members
197 init_members();
198
199 // Copy pixels
200 if (m_num_pixels > 0) {
201 m_pixels = new long[m_num_pixels];
202 for (int i = 0; i < m_num_pixels; ++i) {
203 m_pixels[i] = (long)image.pixel(i);
204 }
205 }
206
207 // Set number of bits per pixel
209
210 // Update header card
211 card("BITPIX").value(G_BITPIX);
212
213 // Return
214 return;
215}
216
217
218/***********************************************************************//**
219 * @brief Copy constructor
220 *
221 * @param[in] image FITS image.
222 ***************************************************************************/
224 GFitsImage(image)
225{
226 // Initialise class members
227 init_members();
228
229 // Copy members
230 copy_members(image);
231
232 // Return
233 return;
234}
235
236
237/***********************************************************************//**
238 * @brief Destructor
239 ***************************************************************************/
241{
242 // Free members
243 free_members();
244
245 // Return
246 return;
247}
248
249
250/*==========================================================================
251 = =
252 = Operators =
253 = =
254 ==========================================================================*/
255
256/***********************************************************************//**
257 * @brief Assignment operator
258 *
259 * @param[in] image FITS image.
260 ***************************************************************************/
262{
263 // Execute only if object is not identical
264 if (this != &image) {
265
266 // Copy base class members
267 this->GFitsImage::operator=(image);
268
269 // Free members
270 free_members();
271
272 // Initialise private members
273 init_members();
274
275 // Copy members
276 copy_members(image);
277
278 } // endif: object was not identical
279
280 // Return this object
281 return *this;
282}
283
284
285/***********************************************************************//**
286 * @brief Image pixel access operator
287 *
288 * @param[in] ix Pixel index (starting from 0).
289 *
290 * Provides access to an image pixel. No range checking is performed.
291 * Use the at(ix) method if range checking is required.
292 ***************************************************************************/
293long& GFitsImageLong::operator()(const int& ix)
294{
295 // Load data
296 load_data();
297
298 // Return image pixel
299 return m_pixels[ix];
300}
301
302
303/***********************************************************************//**
304 * @brief 2D image pixel access operator
305 *
306 * @param[in] ix Pixel index in first dimension (starting from 0).
307 * @param[in] iy Pixel index in second dimension (starting from 0).
308 *
309 * Provides access to a pixel of a 2D image. No range checking or image
310 * dimension verification is performed. Use the at(ix,iy) method if range
311 * checking and image dimension verification is required.
312 ***************************************************************************/
313long& GFitsImageLong::operator()(const int& ix, const int& iy)
314{
315 // Load data
316 load_data();
317
318 // Calculate pixel offset
319 int offset = ix + iy * m_naxes[0];
320
321 // Return image pixel
322 return m_pixels[offset];
323}
324
325
326/***********************************************************************//**
327 * @brief 3D image pixel access operator
328 *
329 * @param[in] ix Pixel index in first dimension (starting from 0).
330 * @param[in] iy Pixel index in second dimension (starting from 0).
331 * @param[in] iz Pixel index in third dimension (starting from 0).
332 *
333 * Provides access to a pixel of a 3D image. No range checking or image
334 * dimension verification is performed. Use the at(ix,iy) method if range
335 * checking and image dimension verification is required.
336 ***************************************************************************/
337long& GFitsImageLong::operator()(const int& ix, const int& iy, const int& iz)
338{
339 // Load data
340 load_data();
341
342 // Calculate pixel offset
343 int offset = ix + m_naxes[0] * (iy + iz * m_naxes[1]);
344
345 // Return image pixel
346 return m_pixels[offset];
347}
348
349
350/***********************************************************************//**
351 * @brief 4D image pixel access operator
352 *
353 * @param[in] ix Pixel index in first dimension (starting from 0).
354 * @param[in] iy Pixel index in second dimension (starting from 0).
355 * @param[in] iz Pixel index in third dimension (starting from 0).
356 * @param[in] it Pixel index in forth dimension (starting from 0).
357 *
358 * Provides access to a pixel of a 4D image. No range checking or image
359 * dimension verification is performed. Use the at(ix,iy) method if range
360 * checking and image dimension verification is required.
361 ***************************************************************************/
362long& GFitsImageLong::operator()(const int& ix, const int& iy,
363 const int& iz, const int& it)
364{
365 // Load data
366 load_data();
367
368 // Calculate pixel offset
369 int offset = ix + m_naxes[0] * (iy + m_naxes[1] * (iz + it * m_naxes[2]));
370
371 // Return image pixel
372 return m_pixels[offset];
373}
374
375
376/***********************************************************************//**
377 * @brief Image pixel access operator (const variant)
378 *
379 * @param[in] ix Pixel index (starting from 0).
380 *
381 * Provides access to an image pixel. No range checking is performed.
382 * Use the at(ix) method if range checking is required.
383 ***************************************************************************/
384const long& GFitsImageLong::operator()(const int& ix) const
385{
386 // Load data
387 load_data();
388
389 // Return image pixel
390 return m_pixels[ix];
391}
392
393
394/***********************************************************************//**
395 * @brief 2D image pixel access operator (const variant)
396 *
397 * @param[in] ix Pixel index in first dimension (starting from 0).
398 * @param[in] iy Pixel index in second dimension (starting from 0).
399 *
400 * Provides access to a pixel of a 2D image. No range checking or image
401 * dimension verification is performed. Use the at(ix,iy) method if range
402 * checking and image dimension verification is required.
403 ***************************************************************************/
404const long& GFitsImageLong::operator()(const int& ix, const int& iy) const
405{
406 // Load data
407 load_data();
408
409 // Calculate pixel offset
410 int offset = ix + iy * m_naxes[0];
411
412 // Return image pixel
413 return m_pixels[offset];
414}
415
416
417/***********************************************************************//**
418 * @brief 3D image pixel access operator (const variant)
419 *
420 * @param[in] ix Pixel index in first dimension (starting from 0).
421 * @param[in] iy Pixel index in second dimension (starting from 0).
422 * @param[in] iz Pixel index in third dimension (starting from 0).
423 *
424 * Provides access to a pixel of a 3D image. No range checking or image
425 * dimension verification is performed. Use the at(ix,iy) method if range
426 * checking and image dimension verification is required.
427 ***************************************************************************/
428const long& GFitsImageLong::operator()(const int& ix, const int& iy,
429 const int& iz) const
430{
431 // Load data
432 load_data();
433
434 // Calculate pixel offset
435 int offset = ix + m_naxes[0] * (iy + iz * m_naxes[1]);
436
437 // Return image pixel
438 return m_pixels[offset];
439}
440
441
442/***********************************************************************//**
443 * @brief 4D image pixel access operator (const variant)
444 *
445 * @param[in] ix Pixel index in first dimension (starting from 0).
446 * @param[in] iy Pixel index in second dimension (starting from 0).
447 * @param[in] iz Pixel index in third dimension (starting from 0).
448 * @param[in] it Pixel index in forth dimension (starting from 0).
449 *
450 * Provides access to a pixel of a 4D image. No range checking or image
451 * dimension verification is performed. Use the at(ix,iy) method if range
452 * checking and image dimension verification is required.
453 ***************************************************************************/
454const long& GFitsImageLong::operator()(const int& ix, const int& iy,
455 const int& iz, const int& it) const
456{
457 // Load data
458 load_data();
459
460 // Calculate pixel offset
461 int offset = ix + m_naxes[0] * (iy + m_naxes[1] * (iz + it * m_naxes[2]));
462
463 // Return image pixel
464 return m_pixels[offset];
465}
466
467
468/*==========================================================================
469 = =
470 = Public methods =
471 = =
472 ==========================================================================*/
473
474/***********************************************************************//**
475 * @brief Clear instance
476 *
477 * This method properly resets the object to an initial state.
478 ***************************************************************************/
480{
481 // Free class members (base and derived classes, derived class first)
482 free_members();
485
486 // Initialise members
489 init_members();
490
491 // Return
492 return;
493}
494
495
496/***********************************************************************//**
497 * @brief Clone FITS image
498 *
499 * Cloning provides a copy of the FITS file. Cloning is used to allocate
500 * derived classes into a base class pointer.
501 ***************************************************************************/
503{
504 // Clone this image
505 return new GFitsImageLong(*this);
506}
507
508
509/***********************************************************************//**
510 * @brief Image pixel access operator
511 *
512 * @param[in] ix Pixel index (starting from 0).
513 *
514 * Provides access to a pixel of an image including range checking. Note that
515 * this method does not necessarily restrict do 1D images but generally
516 * applies to all image dimensions.
517 ***************************************************************************/
518long& GFitsImageLong::at(const int& ix)
519{
520 // Load data
521 load_data();
522
523 // Return image pixel
524 return (m_pixels[offset(ix)]);
525}
526
527
528/***********************************************************************//**
529 * @brief 2D image pixel access operator
530 *
531 * @param[in] ix Pixel index in first dimension (starting from 0).
532 * @param[in] iy Pixel index in second dimension (starting from 0).
533 *
534 * Provides access to a pixel of an image including range checking.
535 ***************************************************************************/
536long& GFitsImageLong::at(const int& ix, const int& iy)
537{
538 // Load data
539 load_data();
540
541 // Return image pixel
542 return (m_pixels[offset(ix,iy)]);
543}
544
545
546/***********************************************************************//**
547 * @brief 3D image pixel access operator
548 *
549 * @param[in] ix Pixel index in first dimension (starting from 0).
550 * @param[in] iy Pixel index in second dimension (starting from 0).
551 * @param[in] iz Pixel index in third dimension (starting from 0).
552 *
553 * Provides access to a pixel of an image including range checking.
554 ***************************************************************************/
555long& GFitsImageLong::at(const int& ix, const int& iy, const int& iz)
556{
557 // Load data
558 load_data();
559
560 // Return image pixel
561 return (m_pixels[offset(ix,iy,iz)]);
562}
563
564
565/***********************************************************************//**
566 * @brief 4D image pixel access operator
567 *
568 * @param[in] ix Pixel index in first dimension (starting from 0).
569 * @param[in] iy Pixel index in second dimension (starting from 0).
570 * @param[in] iz Pixel index in third dimension (starting from 0).
571 * @param[in] it Pixel index in forth dimension (starting from 0).
572 *
573 * Provides access to a pixel of an image including range checking.
574 ***************************************************************************/
575long& GFitsImageLong::at(const int& ix, const int& iy, const int& iz,
576 const int& it)
577{
578 // Load data
579 load_data();
580
581 // Return image pixel
582 return (m_pixels[offset(ix,iy,iz,it)]);
583}
584
585
586/***********************************************************************//**
587 * @brief Image pixel access operator (const variant)
588 *
589 * @param[in] ix Pixel index (starting from 0).
590 *
591 * Provides access to a pixel of an image including range checking.
592 ***************************************************************************/
593const long& GFitsImageLong::at(const int& ix) const
594{
595 // Load data
596 load_data();
597
598 // Return image pixel
599 return (m_pixels[offset(ix)]);
600}
601
602
603/***********************************************************************//**
604 * @brief 2D image pixel access operator (const variant)
605 *
606 * @param[in] ix Pixel index in first dimension (starting from 0).
607 * @param[in] iy Pixel index in second dimension (starting from 0).
608 *
609 * Provides access to a pixel of an image including range checking.
610 ***************************************************************************/
611const long& GFitsImageLong::at(const int& ix, const int& iy) const
612{
613 // Load data
614 load_data();
615
616 // Return image pixel
617 return (m_pixels[offset(ix,iy)]);
618}
619
620
621/***********************************************************************//**
622 * @brief 3D image pixel access operator (const variant)
623 *
624 * @param[in] ix Pixel index in first dimension (starting from 0).
625 * @param[in] iy Pixel index in second dimension (starting from 0).
626 * @param[in] iz Pixel index in third dimension (starting from 0).
627 *
628 * Provides access to a pixel of an image including range checking.
629 ***************************************************************************/
630const long& GFitsImageLong::at(const int& ix, const int& iy,
631 const int& iz) const
632{
633 // Load data
634 load_data();
635
636 // Return image pixel
637 return (m_pixels[offset(ix,iy,iz)]);
638}
639
640
641/***********************************************************************//**
642 * @brief 4D image pixel access operator (const variant)
643 *
644 * @param[in] ix Pixel index in first dimension (starting from 0).
645 * @param[in] iy Pixel index in second dimension (starting from 0).
646 * @param[in] iz Pixel index in third dimension (starting from 0).
647 * @param[in] it Pixel index in forth dimension (starting from 0).
648 *
649 * Provides access to a pixel of an image including range checking.
650 ***************************************************************************/
651const long& GFitsImageLong::at(const int& ix, const int& iy,
652 const int& iz, const int& it) const
653{
654 // Load data
655 load_data();
656
657 // Return image pixel
658 return (m_pixels[offset(ix,iy,iz,it)]);
659}
660
661
662/***********************************************************************//**
663 * @brief Return value of image pixel
664 *
665 * @param[in] ix Pixel index (starting from 0).
666 *
667 * Returns the value of an image pixel as double precision floating point
668 * value. This method performs range checking and converts raw into true
669 * pixel values using the BSCALE and BZERO keywords, if supplied.
670 ***************************************************************************/
671double GFitsImageLong::pixel(const int& ix) const
672{
673 // Return pixel value
674 return (raw2true(double(this->at(ix))));
675}
676
677
678/***********************************************************************//**
679 * @brief Return value of image pixel (2D version)
680 *
681 * @param[in] ix Pixel index in first dimension (starting from 0).
682 * @param[in] iy Pixel index in second dimension (starting from 0).
683 *
684 * Returns the value of an image pixel as double precision floating point
685 * value. This method performs range checking and converts raw into true
686 * pixel values using the BSCALE and BZERO keywords, if supplied.
687 ***************************************************************************/
688double GFitsImageLong::pixel(const int& ix, const int& iy) const
689{
690 // Return pixel value
691 return (raw2true(double(this->at(ix,iy))));
692}
693
694
695/***********************************************************************//**
696 * @brief Return value of image pixel (3D version)
697 *
698 * @param[in] ix Pixel index in first dimension (starting from 0).
699 * @param[in] iy Pixel index in second dimension (starting from 0).
700 * @param[in] iz Pixel index in third dimension (starting from 0).
701 *
702 * Returns the value of an image pixel as double precision floating point
703 * value. This method performs range checking and converts raw into true
704 * pixel values using the BSCALE and BZERO keywords, if supplied.
705 ***************************************************************************/
706double GFitsImageLong::pixel(const int& ix, const int& iy, const int& iz) const
707{
708 // Return pixel value
709 return (raw2true(double(this->at(ix,iy,iz))));
710}
711
712
713/***********************************************************************//**
714 * @brief Return value of image pixel (4D version)
715 *
716 * @param[in] ix Pixel index in first dimension (starting from 0).
717 * @param[in] iy Pixel index in second dimension (starting from 0).
718 * @param[in] iz Pixel index in third dimension (starting from 0).
719 * @param[in] it Pixel index in forth dimension (starting from 0).
720 *
721 * Returns the value of an image pixel as double precision floating point
722 * value. This method performs range checking and converts raw into true
723 * pixel values using the BSCALE and BZERO keywords, if supplied.
724 ***************************************************************************/
725double GFitsImageLong::pixel(const int& ix, const int& iy, const int& iz,
726 const int& it) const
727{
728 // Return pixel value
729 return (raw2true(double(this->at(ix,iy,iz,it))));
730}
731
732
733/***********************************************************************//**
734 * @brief Return pointer to image pixel
735 ***************************************************************************/
737{
738 // Load data
739 load_data();
740
741 // Return
742 return m_pixels;
743}
744
745
746/***********************************************************************//**
747 * @brief Return image type
748 ***************************************************************************/
749int GFitsImageLong::type(void) const
750{
751 // Return type
752 return __TLONG;
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<GFitsImageLong*>(&image)->fetch_data();
792 }
793
794 // Copy pixels
795 if (m_num_pixels > 0 && image.m_pixels != NULL) {
796 m_pixels = new long[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 column if it was fetch above
806 #if defined(G_SMALL_MEMORY)
807 if (not_loaded) {
808 const_cast<GFitsImageLong*>(&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 long[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;
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 GFitsImageLong::construct_data(const long* 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<GFitsImageLong*>(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 GFitsImageLong::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 long;
955 *m_nulval = *((long*)value);
956 }
957
958 // Return
959 return;
960}
Exception handler interface definition.
CFITSIO interface header.
#define __TLONG
#define G_BITPIX
Defines the number of bits per pixel.
#define G_BITPIX
Defines the number of bits per pixel.
Long integer 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.
Long integer FITS image class.
long & at(const int &ix)
Image pixel access operator.
void copy_members(const GFitsImageLong &image)
Copy class members.
void free_members(void)
Delete class members.
int type(void) const
Return image type.
void * pixels(void)
Return pointer to image pixel.
GFitsImageLong * clone(void) const
Clone FITS image.
void init_data(void)
Initialise data.
virtual ~GFitsImageLong(void)
Destructor.
void alloc_data(void)
Allocate data.
long & operator()(const int &ix)
Image pixel access operator.
void construct_data(const long *pixels)
Construct data from array.
double pixel(const int &ix) const
Return value of image pixel.
GFitsImageLong & operator=(const GFitsImageLong &image)
Assignment operator.
void load_data(void) const
Load data.
void release_data(void)
Release data.
void init_members(void)
Initialise class members.
long * m_nulval
NULL value.
void clear(void)
Clear instance.
GFitsImageLong(void)
Void constructor.
long * m_pixels
Pixels.
void alloc_nulval(const void *value)
Allocates nul value.
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.
double raw2true(const double &raw) const
Convert raw to true pixel value by applying BSCALE and BZERO.
void init_members(void)
Initialise class members.