00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef IMAGES_FITSIMAGE_H
00029 #define IMAGES_FITSIMAGE_H
00030
00031
00032
00033 #include <casacore/casa/aips.h>
00034 #include <casacore/images/Images/ImageInterface.h>
00035 #include <casacore/images/Images/MaskSpecifier.h>
00036 #include <casacore/tables/DataMan/TiledFileAccess.h>
00037 #include <casacore/lattices/Lattices/TiledShape.h>
00038 #include <casacore/fits/FITS/fits.h>
00039 #include <casacore/casa/BasicSL/String.h>
00040 #include <casacore/casa/Utilities/DataType.h>
00041
00042 #ifndef WCSLIB_GETWCSTAB
00043 #define WCSLIB_GETWCSTAB
00044 #endif
00045
00046 namespace casacore {
00047
00048
00049 template <class T> class Array;
00050 template <class T> class Lattice;
00051
00052 class MaskSpecifier;
00053 class IPosition;
00054 class Slicer;
00055 class CoordinateSystem;
00056 class FITSMask;
00057 class FitsInput;
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 class FITSImage: public ImageInterface<Float>
00109 {
00110 public:
00111
00112 explicit FITSImage(const String& name, uInt whichRep=0, uInt whichHDU=0);
00113
00114
00115 FITSImage(const String& name, const MaskSpecifier& mask, uInt whichRep=0, uInt whichHDU=0);
00116
00117
00118 FITSImage(const FITSImage& other);
00119
00120
00121 virtual ~FITSImage();
00122
00123
00124 FITSImage& operator=(const FITSImage& other);
00125
00126
00127 static LatticeBase* openFITSImage (const String& name,
00128 const MaskSpecifier&);
00129
00130
00131 static void registerOpenFunction();
00132
00133
00134 static String get_fitsname(const String &fullname);
00135
00136
00137 static uInt get_hdunum(const String &fullname);
00138
00139
00140
00141
00142 virtual ImageInterface<Float>* cloneII() const;
00143
00144
00145 virtual String imageType() const;
00146
00147
00148
00149 virtual void resize(const TiledShape& newShape);
00150
00151
00152
00153
00154
00155
00156 virtual Bool isMasked() const;
00157
00158
00159 virtual Bool hasPixelMask() const;
00160
00161
00162
00163 virtual const Lattice<Bool>& pixelMask() const;
00164 virtual Lattice<Bool>& pixelMask();
00165
00166
00167
00168
00169 virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
00170
00171
00172
00173 virtual const LatticeRegion* getRegionPtr() const;
00174
00175
00176
00177
00178
00179
00180 virtual Bool doGetSlice (Array<Float>& buffer, const Slicer& theSlice);
00181
00182
00183 virtual void doPutSlice (const Array<Float>& sourceBuffer,
00184 const IPosition& where,
00185 const IPosition& stride);
00186
00187
00188
00189
00190 virtual Bool isPaged() const;
00191
00192
00193 virtual Bool isPersistent() const;
00194
00195
00196 virtual Bool isWritable() const;
00197
00198
00199 virtual String name (Bool stripPath=False) const;
00200
00201
00202 virtual IPosition shape() const;
00203
00204
00205
00206 virtual uInt advisedMaxPixels() const;
00207
00208
00209
00210
00211 virtual IPosition doNiceCursorShape (uInt maxPixels) const;
00212
00213
00214 virtual void tempClose();
00215
00216
00217 virtual void reopen();
00218
00219
00220 virtual Bool ok() const;
00221
00222
00223 virtual DataType dataType() const;
00224
00225
00226 DataType internalDataType() const
00227 { return dataType_p; }
00228
00229
00230 uInt whichHDU () const
00231 { return whichHDU_p; }
00232
00233
00234 virtual uInt maximumCacheSize() const;
00235
00236
00237 virtual void setMaximumCacheSize (uInt howManyPixels);
00238
00239
00240 virtual void setCacheSizeFromPath (const IPosition& sliceShape,
00241 const IPosition& windowStart,
00242 const IPosition& windowLength,
00243 const IPosition& axisPath);
00244
00245
00246
00247
00248
00249
00250 virtual void setCacheSizeInTiles (uInt howManyTiles);
00251
00252
00253
00254 virtual void clearCache();
00255
00256
00257 virtual void showCacheStatistics (ostream& os) const;
00258
00259 protected:
00260
00261 void setMaskZero(Bool filterZero);
00262
00263 private:
00264 String name_p;
00265 String fullname_p;
00266 MaskSpecifier maskSpec_p;
00267 CountedPtr<TiledFileAccess> pTiledFile_p;
00268 Lattice<Bool>* pPixelMask_p;
00269 TiledShape shape_p;
00270 Float scale_p;
00271 Float offset_p;
00272 Short shortMagic_p;
00273 uChar uCharMagic_p;
00274 Int longMagic_p;
00275 Bool hasBlanks_p;
00276 DataType dataType_p;
00277 Int64 fileOffset_p;
00278 Bool isClosed_p;
00279 Bool filterZeroMask_p;
00280 uInt whichRep_p;
00281 uInt whichHDU_p;
00282 Bool _hasBeamsTable;
00283
00284
00285 void reopenIfNeeded() const
00286 { if (isClosed_p) const_cast<FITSImage*>(this)->reopen(); }
00287
00288
00289 void setup();
00290
00291
00292 void open();
00293
00294
00295 void getImageAttributes (CoordinateSystem& cSys,
00296 IPosition& shape, ImageInfo& info,
00297 Unit& brightnessUnit, RecordInterface& miscInfo,
00298 Int& recsize, Int& recno,
00299 FITS::ValueType& dataType,
00300 Float& scale, Float& offset,
00301 uChar& uCharMagic, Short& shortMagic,
00302 Int& longMagic, Bool& hasBlanks, const String& name,
00303 uInt whichRep, uInt whichHDU);
00304
00305
00306 template <typename T>
00307 void crackHeader (CoordinateSystem& cSys, IPosition& shape, ImageInfo& imageInfo,
00308 Unit& brightnessUnit, RecordInterface& miscInfo,
00309 Float& scale, Float& offset, uChar& magicUChar, Short& magicShort,
00310 Int& magicLong, Bool& hasBlanks, LogIO& os, FitsInput& infile,
00311 uInt whichRep);
00312
00313
00314 template <typename T>
00315 void crackExtHeader (CoordinateSystem& cSys, IPosition& shape, ImageInfo& imageInfo,
00316 Unit& brightnessUnit, RecordInterface& miscInfo,
00317 Float& scale, Float& offset, uChar& uCharMagic,
00318 Short& magicShort,
00319 Int& magicLong, Bool& hasBlanks, LogIO& os, FitsInput& infile,
00320 uInt whichRep);
00321
00322 };
00323
00324
00325
00326 }
00327
00328 #ifndef CASACORE_NO_AUTO_TEMPLATES
00329 #include <casacore/images/Images/FITS2Image.tcc>
00330 #endif //# CASACORE_NO_AUTO_TEMPLATES
00331
00332 #endif
00333
00334