Changeset 3493 in Sophya for trunk/SophyaExt/FitsIOServer/fitsarrhand.h
- Timestamp:
- Apr 30, 2008, 3:12:10 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fitsarrhand.h
r3167 r3493 1 /* 2 --- SOPHYA software - FitsIOServer module --- 3 R. Ansari , 2005-2008 4 (C) UPS+LAL IN2P3/CNRS (C) DAPNIA-SPP/CEA 5 */ 1 6 #ifndef FITSARRHAND_H 2 7 #define FITSARRHAND_H … … 64 69 65 70 //----- Ecriture 71 //! Writes the complete array as an IMAGE HDU 66 72 virtual void Write(FitsInOutFile& os) 67 73 { 68 if ( dobj == NULL) 69 throw NullPtrError("FitsArrayHandler<T>::Write() dobj=NULL "); 74 if (( dobj == NULL) || (dobj->Size() < 1)) 75 throw NullPtrError("FitsArrayHandler<T>::Write() dobj=NULL or dobj->Size()=0"); 76 70 77 LONGLONG naxes[BASEARRAY_MAXNDIMS] = {0,0,0,0,0}; 71 78 for(int_4 id=0; id<dobj->NbDimensions(); id++) … … 81 88 82 89 //----- Lecture 90 //! Resize the array and reads the complete IMAGE HDU to the array 83 91 virtual void Read(FitsInOutFile& is) 84 92 { … … 97 105 } 98 106 sa_size_t sz[BASEARRAY_MAXNDIMS]; 99 if (naxis > BASEARRAY_MAXNDIMS) naxis = BASEARRAY_MAXNDIMS; 107 if (naxis > BASEARRAY_MAXNDIMS) { 108 cerr << "FitsArrayHandler<T>::Read()/Warning FITS NAXIS=" << naxis 109 << " > BASEARRAY_MAXNDIMS=" << BASEARRAY_MAXNDIMS << endl; 110 naxis = BASEARRAY_MAXNDIMS; 111 } 100 112 for(int_4 id=0; id<naxis; id++) sz[id] = naxes[id]; 101 113 dobj->SetSize(naxis, sz, 1, false); 102 114 FitsBlockRW<T>::ReadImageData(is, dobj->Data(), dobj->Size()); 103 115 is.GetHeaderRecords(dobj->Info()); 116 } 117 118 //----- Lecture avec specification d'offset et taille donnee par le tableau 119 /*! \brief Reads from the fits file into the array, at the specified offset 120 121 The array should be allocated and its size is used to define the number of 122 pixels to be read. 123 \warning The offset should be specified with SOPHYA/C array index convention 124 (starting at zero) - and NOT the cfitsio/fortran convention. 125 The offset should contain as many elements as the fits NAXIS keyword. 126 */ 127 virtual void ReadAtOffset(FitsInOutFile& is, sa_size_t* offset) 128 { 129 if (( dobj == NULL) || (dobj->Size() < 1)) 130 throw NullPtrError("FitsArrayHandler<T>::ReadAtOffset() dobj=NULL or dobj->Size()=0"); 131 132 LONGLONG naxes[BASEARRAY_MAXNDIMS]; 133 int naxis=BASEARRAY_MAXNDIMS; 134 is.GetImageHDUInfo(naxis, naxes); 135 LONGLONG fpix[15]; 136 int namx = (naxis < 15) ? naxis : 15; 137 for(int i=0; i<namx; i++) fpix[i] = offset[i]+1; 138 FitsBlockRW<T>::ReadImageData(is, dobj->Data(), dobj->Size(), fpix); 139 is.GetHeaderRecords(dobj->Info()); 140 } 141 142 //----- Ecriture avec specification d'offset et taille donnee par le tableau 143 /*! \brief Writes the array to the fits file, at the specified offset 144 145 The array should be allocated and its size is used to define the number of 146 pixels to be read. 147 \warning The offset should be specified with SOPHYA/C array index convention 148 (starting at zero) - and NOT the cfitsio/fortran convention. 149 The offset should contain as many elements as the fits NAXIS keyword. 150 \warning The IMAGE HDU should be already created using FitsInOutFile::CreateImageHDU(). 151 */ 152 virtual void WriteAtOffset(FitsInOutFile& os, sa_size_t* offset) 153 { 154 if (( dobj == NULL) || (dobj->Size() < 1)) 155 throw NullPtrError("FitsArrayHandler<T>::ReadAtOffset() dobj=NULL or dobj->Size()=0"); 156 157 LONGLONG naxes[BASEARRAY_MAXNDIMS]; 158 int naxis=BASEARRAY_MAXNDIMS; 159 os.GetImageHDUInfo(naxis, naxes); 160 LONGLONG fpix[15]; 161 int namx = (naxis < 15) ? naxis : 15; 162 for(int i=0; i<namx; i++) fpix[i] = offset[i]+1; 163 FitsBlockRW<T>::WriteImageData(os, dobj->Data(), dobj->Size(), fpix); 104 164 } 105 165 … … 110 170 111 171 172 //! operator << overload to write a TArray<T> to a fits IMAGE HDU 112 173 template <class T> 113 174 inline FitsInOutFile& operator << (FitsInOutFile& os, TArray<T> const & obj) 114 175 { FitsArrayHandler<T> fio(const_cast< TArray<T> &>(obj)); fio.Write(os); return os; } 115 176 177 //! operator >> overload to read a TArray<T> from a fits IMAGE HDU 116 178 template <class T> 117 179 inline FitsInOutFile& operator >> (FitsInOutFile& is, TArray<T> & obj)
Note:
See TracChangeset
for help on using the changeset viewer.