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 COORDINATES_FITSCOORDINATEUTIL_H
00030 #define COORDINATES_FITSCOORDINATEUTIL_H
00031
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/measures/Measures/MDirection.h>
00034 #include <casacore/measures/Measures/MFrequency.h>
00035 #include <casacore/coordinates/Coordinates/ObsInfo.h>
00036
00037
00038 struct wcsprm;
00039
00040 namespace casacore {
00041
00042 class Coordinate;
00043 class CoordinateSystem;
00044 class StokesCoordinate;
00045 class Projection;
00046 class IPosition;
00047 class LogIO;
00048 class Record;
00049
00050
00051
00052
00053
00054
00055
00056
00057
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 class FITSCoordinateUtil
00090 {
00091 public:
00092
00093
00094 FITSCoordinateUtil() {;};
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 Bool toFITSHeader(RecordInterface &header,
00113 IPosition &shape,
00114 const CoordinateSystem& cSys,
00115 Bool oneRelative,
00116 Char prefix = 'c', Bool writeWCS=True,
00117 Bool preferVelocity=True,
00118 Bool opticalVelocity=True,
00119 Bool preferWavelength=False,
00120 Bool airWavelength=False) const;
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 Bool fromFITSHeader(Int& stokesFITSValue,
00134 CoordinateSystem& coordsys,
00135 RecordInterface& recHeader,
00136 const Vector<String>& header,
00137 const IPosition& shape,
00138 uInt which=0) const;
00139
00140
00141
00142
00143
00144 static Vector<String> cTypeFromDirection (Bool& isNCP, const Projection& proj,
00145 const Vector<String>& axisNames,
00146 Double refLat, Bool printError);
00147 static Vector<String> cTypeFromDirection (const Projection& proj,
00148 const Vector<String>& axisNames,
00149 Bool printError);
00150
00151 private:
00152
00153 Bool generateFITSKeywords (LogIO& os, Bool& isNCP,
00154 Double& longPole, Double& latPole,
00155 Vector<Double>& crval,
00156 Vector<Double>& crpix,
00157 Vector<Double>& cdelt,
00158
00159
00160 Vector<Double>& pvi_ma,
00161 Vector<String>& ctype,
00162 Vector<String>& cunit,
00163 Matrix<Double>& pc,
00164 const CoordinateSystem& cSys,
00165 Int skyCoord, Int longAxis, Int latAxis,
00166 Int specAxis, Int stokesAxis,
00167 Bool writeWCS, Double offset,
00168 const String& sprefix) const;
00169
00170
00171 Bool toFITSHeaderStokes(Vector<Double>& crval,
00172 Vector<Double>& crpix,
00173 Vector<Double>& cdelt,
00174 LogIO& os,
00175 const CoordinateSystem& coordsys,
00176 Int stokesAxis, Int stokesCoord) const;
00177
00178
00179
00180 Bool addDirectionCoordinate (CoordinateSystem& cSys, Vector<Int>& axes,
00181 const wcsprm& wcs, LogIO& os) const;
00182 Bool addSpectralCoordinate (CoordinateSystem& cSys, Int& axis,
00183 const wcsprm& wcs, const IPosition& shape,
00184 LogIO& os) const;
00185 Bool addStokesCoordinate (CoordinateSystem& cSys, Int& axis, Int& stokesFITSValue,
00186 const wcsprm& wcs, const IPosition& shape,
00187 LogIO& os) const;
00188 Bool addLinearCoordinate (CoordinateSystem& cSys, Vector<Int>& axes,
00189 const wcsprm& wcs, LogIO& os) const;
00190
00191
00192
00193
00194 Bool directionSystemFromWCS (LogIO& os, MDirection::Types& type, String& errMsg,
00195 const wcsprm& wcs) const;
00196 Bool frequencySystemFromWCS (LogIO& os, MFrequency::Types& type, String& errMsg,
00197 const wcsprm& wcs) const;
00198 Bool stokesCoordinateFromWCS (LogIO& os, StokesCoordinate& coord,
00199 Int& stokesFITSValue, String& errMSg,
00200 const wcsprm& wcs, uInt shape, Bool warnStokes) const;
00201
00202
00203
00204 ObsInfo getObsInfo(LogIO& os, RecordInterface& header, const wcsprm& wcs) const;
00205
00206
00207 void setWCS (wcsprm& wcs) const;
00208
00209
00210 Bool getCDFromHeader(Matrix<Double>& cd, uInt n, const RecordInterface& header);
00211
00212
00213 void getPCFromHeader(LogIO& os, Int& rotationAxis, Matrix<Double>& pc,
00214 uInt n, const RecordInterface& header,
00215 const String& sprefix);
00216
00217
00218
00219 void cardsToRecord (LogIO& os, RecordInterface& rec, char* pHeader) const;
00220
00221
00222
00223 void fixCoordinate(Coordinate& c, LogIO& os) const;
00224
00225
00226
00227
00228 static void wcsInit (::wcsprm& wcsDest);
00229 };
00230
00231 }
00232
00233 #endif
00234