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
00029 #ifndef SYNTHESIS_STOKESIMAGEUTIL_H
00030 #define SYNTHESIS_STOKESIMAGEUTIL_H
00031
00032 #include <casa/aips.h>
00033 #include <casa/BasicSL/Complex.h>
00034 #include <images/Images/ImageInterface.h>
00035 #include <casa/Quanta/Quantum.h>
00036 #include <ms/MeasurementSets/MeasurementSet.h>
00037
00038 namespace casa {
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 class StokesImageUtil {
00067
00068 public:
00069
00070 enum PolRep {
00071 CIRCULAR=0,
00072 LINEAR
00073 };
00074
00075
00076 static void MakeGaussianPSF(ImageInterface<Float>& psf, Vector<Float>& beam,
00077 Bool norm=False);
00078 static void MakeGaussianPSF(ImageInterface<Float>& psf,
00079 Quantity& bmaj, Quantity& bmin, Quantity& bpa,
00080 Bool norm=False);
00081
00082
00083
00084
00085 static Bool FitGaussianPSF(ImageInterface<Float>& psf, Vector<Float>& beam);
00086 static Bool FitGaussianPSF(ImageInterface<Float>& psf, GaussianBeam& beam);
00087 static Bool FitGaussianPSF(ImageInterface<Float>& psf, ImageBeamSet& beam);
00088
00089
00090
00091
00092 static void locatePeakPSF(ImageInterface<Float>& psf, Int& xpos, Int& ypos,
00093 Float& amp, Matrix<Float>& psfplane);
00094
00095
00096
00097 static void Convolve(ImageInterface<Float>& image,
00098 ImageInterface<Float>& psf);
00099 static void Convolve(ImageInterface<Float>& image, Float bmaj,
00100 Float bmin, Float bpa, Bool normalizeVolume=False);
00101 static void Convolve(ImageInterface<Float>& image,
00102 GaussianBeam& beam,
00103 Bool normalizeVolume=False);
00104 static void Convolve(ImageInterface<Float>& image,
00105 ImageBeamSet& beams,
00106 Bool normalizeVolume=False);
00107
00108
00109
00110
00111 static void Zero(ImageInterface<Float>& image, Vector<Bool>& mask);
00112
00113
00114 static void MaskFrom(ImageInterface<Float>& mask,
00115 ImageInterface<Float>& image,
00116 const Double threshhold);
00117
00118
00119 static void MaskFrom(ImageInterface<Float>& mask,
00120 ImageInterface<Float>& image,
00121 const Quantity& threshold);
00122
00123
00124
00125 static void MaskOnStokesI(ImageInterface<Float>& image, const Quantity& threshold);
00126
00127
00128 static void BoxMask(ImageInterface<Float>& mask, const IPosition& blc,
00129 const IPosition& trc, const Float value);
00130
00131
00132 static void Constrain(ImageInterface<Float>& image);
00133
00134
00135 static void From(ImageInterface<Complex>& out,
00136 const ImageInterface<Float>& in);
00137
00138
00139 static void To(ImageInterface<Float>& out, ImageInterface<Complex>& in);
00140
00141
00142 static void directCFromR(ImageInterface<Complex>& out,
00143 const ImageInterface<Float>& in);
00144
00145
00146 static void directCToR(ImageInterface<Float>& out, ImageInterface<Complex>& in);
00147
00148
00149
00150 static void ToStokesPSF(ImageInterface<Float>& out, ImageInterface<Complex>& in);
00151
00152 static void ToStokesSumWt(Matrix<Float> sumwtStokes, Matrix<Float> sumwtCorr);
00153
00154
00155 static Int StokesPolMap(Vector<Int>& map, const CoordinateSystem& coord);
00156
00157
00158
00159 static Int CStokesPolMap(Vector<Int>& map, StokesImageUtil::PolRep& polframe,
00160 const CoordinateSystem& coord);
00161
00162
00163 static Bool StokesMap(Vector<Int>& map, const CoordinateSystem& coord);
00164
00165
00166 static CoordinateSystem StokesCoordFromMS(const IPosition& shape,
00167 Vector<Double>& deltas,
00168 MeasurementSet& ms);
00169
00170
00171 static CoordinateSystem StokesCoordFromMS(const IPosition& shape,
00172 Vector<Double>& deltas,
00173 MeasurementSet& ms,
00174 Vector<Int>& whichStokes,
00175 Bool doCStokes=False,
00176 Int fieldID=0, Int SPWID=0,
00177 Int feedID=0);
00178
00179
00180 static CoordinateSystem CStokesCoord(
00181 const CoordinateSystem& coord,
00182 Vector<Int>& whichStokes,
00183 StokesImageUtil::PolRep polRep=StokesImageUtil::CIRCULAR);
00184
00185
00186
00187
00188
00189
00190
00191 static void changeCStokesRep(ImageInterface<Complex>& image,
00192 StokesImageUtil::PolRep polRep);
00193
00194 static void changeLabelsStokesToCorrStokes(StokesCoordinate &stokesCoord,
00195 StokesImageUtil::PolRep polRep,
00196 Vector<Int>&whichStokes);
00197
00198
00199
00200
00201
00202 static Bool standardImageCoordinates(const CoordinateSystem& coords);
00203 static Bool standardImageCoordinates(const ImageInterface<Complex>& image);
00204 static Bool standardImageCoordinates(const ImageInterface<Float>& image);
00205
00206
00207 };
00208
00209 }
00210
00211 #endif
00212
00213