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 IMAGEANALYSIS_IMAGEFACTORY_H
00029 #define IMAGEANALYSIS_IMAGEFACTORY_H
00030
00031 #include <imageanalysis/ImageTypedefs.h>
00032
00033 #include <casa/Arrays/Array.h>
00034 #include <casa/BasicSL/String.h>
00035 #include <casa/Containers/Record.h>
00036 #include <casa/Logging/LogOrigin.h>
00037 #include <casa/namespace.h>
00038 #include <lattices/Lattices/LatticeBase.h>
00039 #include <utility>
00040 #include <vector>
00041
00042 namespace casa {
00043
00044 class CoordinateSystem;
00045 class IPosition;
00046 class Record;
00047 template <class T> class TempImage;
00048 template <class T> class Vector;
00049
00050 class ImageFactory {
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 public:
00068
00069 enum ComplexToFloatFunction {
00070 REAL,
00071 IMAG
00072 };
00073
00074 ImageFactory() = delete;
00075
00076 ~ImageFactory() {};
00077
00078
00079
00080
00081 template <class T> static SPIIT createImage(
00082 const String& outfile,
00083 const CoordinateSystem& cSys, const IPosition& shape,
00084 Bool log, Bool overwrite,
00085 const std::vector<std::pair<LogOrigin, String> > *const &msgs
00086 );
00087
00088 static String className() { static const String s = "ImageFactory"; return s; }
00089
00090
00091
00092
00093
00094
00095
00096 static SPIIF floatImageFromShape(
00097 const String& outfile, const Vector<Int>& shape,
00098 const Record& csys, Bool linear=True,
00099 Bool overwrite=False, Bool verbose=True,
00100 const std::vector<std::pair<LogOrigin, String> > *const &msgs=0
00101 );
00102
00103 static SPIIC complexImageFromShape(
00104 const String& outfile, const Vector<Int>& shape,
00105 const Record& csys, Bool linear=True,
00106 Bool overwrite=False, Bool verbose=True,
00107 const std::vector<std::pair<LogOrigin, String> > *const &msgs=0
00108 );
00109
00110
00111
00112 static std::pair<SPIIF, SPIIC> fromImage(
00113 const String& outfile, const String& infile,
00114 const Record& region, const String& mask,
00115 Bool dropdeg=False,
00116 Bool overwrite=False
00117 );
00118
00119 template <class T> static SPIIT imageFromArray(
00120 const String& outfile, const Array<T>& pixels,
00121 const Record& csys, Bool linear=False,
00122 Bool overwrite=False, Bool verbose=True,
00123 const vector<std::pair<LogOrigin, String> > *const &msgs=0
00124 );
00125
00126 static SPIIF fromASCII(
00127 const String& outfile, const String& infile,
00128 const IPosition& shape, const String& sep, const Record& csys,
00129 const Bool linear, const Bool overwrite
00130 );
00131
00132
00133
00134 static SHARED_PTR<TempImage<Float> > floatFromComplex(
00135 SPCIIC complexImage, ComplexToFloatFunction func
00136 );
00137
00138
00139
00140
00141 static SHARED_PTR<TempImage<Complex> > complexFromFloat(
00142 SPCIIF realPart, const Array<Float>& imagPart
00143 );
00144
00145
00146
00147
00148 static SPIIC makeComplex(
00149 SPCIIF realPart, SPCIIF imagPart, const String& outfile,
00150 const Record& region, Bool overwrite = False
00151 );
00152
00153
00154
00155 static std::pair<SPIIF, SPIIC> fromFile(const String& filename);
00156
00157 static SPIIF fromFITS(
00158 const String& outfile, const String& fitsfile,
00159 const Int whichrep, const Int whichhdu,
00160 const Bool zeroBlanks, const Bool overwrite
00161 );
00162
00163 static std::pair<SPIIF, SPIIC> fromRecord(
00164 const RecordInterface& rec, const String& imagename=""
00165 );
00166
00167 template <class T> static void remove(SPIIT& image, Bool verbose);
00168
00169
00170 static void rename(
00171 SPIIF& image, const String& name, const Bool overwrite
00172 );
00173
00174 static void rename(
00175 SPIIC& image, const String& name, const Bool overwrite
00176 );
00177
00178
00179 static SPIIF testImage(
00180 const String& outfile, const Bool overwrite,
00181 const String& imagetype="2d"
00182 );
00183
00184 static void toASCII(
00185 SPCIIF image,
00186 const String& outfile, Record& region, const String& mask,
00187 const String& sep=" ", const String& format="%e",
00188 Double maskvalue=-999, Bool overwrite=False,
00189 Bool extendMask=False
00190 );
00191
00192 static void toFITS(
00193 SPCIIF image, const String& outfile, Bool velocity,
00194 Bool optical, Int bitpix, Double minpix, Double maxpix,
00195 const Record& region, const String& mask,
00196 Bool overwrite=False, Bool dropdeg=False, Bool deglast=False,
00197 Bool dropstokes=False, Bool stokeslast=False,
00198 Bool wavelength=False, Bool airWavelength=False,
00199 const String& origin="", Bool stretch=False, Bool history=True
00200 );
00201
00202 private:
00203
00204 template <class T> static SPIIT _fromShape(
00205 const String& outfile, const Vector<Int>& shape,
00206 const Record& csys, Bool linear,
00207 Bool overwrite, Bool verbose,
00208 const std::vector<std::pair<LogOrigin, String> > *const &msgs
00209 );
00210
00211 template <class T> static SPIIT _fromRecord(
00212 const RecordInterface& rec, const String& name
00213 );
00214
00215 static void _centerRefPix(
00216 CoordinateSystem& csys, const IPosition& shape
00217 );
00218
00219 static void _checkInfile(const String& infile);
00220
00221
00222 static CoordinateSystem* _makeCoordinateSystem(
00223 const casa::Record& cSys,
00224 const casa::IPosition& shape
00225 );
00226
00227 static void _checkOutfile(const String& outfile, Bool overwrite);
00228
00229 static std::pair<SPIIF, SPIIC> _fromLatticeBase(std::unique_ptr<LatticeBase>& latt);
00230
00231
00232
00233 template <class T> static std::pair<SPIIF, SPIIC> _rename(
00234 SPIIT& image, const String& name, const Bool overwrite
00235 );
00236
00237 };
00238 }
00239
00240 #ifndef AIPS_NO_TEMPLATE_SRC
00241 #include <imageanalysis/ImageAnalysis/ImageFactory.tcc>
00242 #endif
00243
00244 #endif