Commits

David Mehringer authored 1d22be78739
refactor
No tags

code/imageanalysis/ImageAnalysis/ImagePolarimetry.cc

Modified
1056 1056 for (uInt i=0; i<4; ++i) {
1057 1057 delete _stokes[i];
1058 1058 _stokes[i] = nullptr;
1059 1059 delete _stokesStats[i];
1060 1060 _stokesStats[i] = nullptr;
1061 1061 }
1062 1062 delete _fitter;
1063 1063 _fitter = nullptr;
1064 1064 }
1065 1065
1066 -void ImagePolarimetry::_findFrequencyAxis (Int& spectralCoord, Int& fAxis,
1067 - const CoordinateSystem& cSys, Int spectralAxis) const
1068 -{
1069 - LogIO os(LogOrigin("ImagePolarimetry", __func__, WHERE));
1070 - spectralCoord = -1;
1071 - fAxis = -1;
1072 - if (spectralAxis >=0) {
1073 - if (spectralAxis < Int(cSys.nPixelAxes())) {
1074 - fAxis = spectralAxis;
1075 - Int axisInCoordinate;
1076 - cSys.findPixelAxis(spectralCoord, axisInCoordinate, fAxis);
1077 -
1078 -// Check coordinate type is one of expected types
1079 -
1080 - Bool ok = cSys.type(spectralCoord)==Coordinate::TABULAR ||
1081 - cSys.type(spectralCoord)==Coordinate::LINEAR ||
1082 - cSys.type(spectralCoord)==Coordinate::SPECTRAL;
1083 - if (!ok) {
1084 - os << "The specified axis of type " << cSys.showType(spectralCoord)
1085 - << " cannot be a frequency axis" << LogIO::EXCEPTION;
1086 - }
1087 - } else {
1088 - os << "Illegal spectral axis " << spectralAxis+1 << " given" << LogIO::EXCEPTION;
1089 - }
1090 - } else {
1091 - spectralCoord = _findSpectralCoordinate(cSys, os, false);
1092 - if (spectralCoord < 0) {
1093 - for (uInt i=0; i<cSys.nCoordinates(); i++) {
1094 - if (cSys.type(i)==Coordinate::TABULAR ||
1095 - cSys.type(i)==Coordinate::LINEAR) {
1096 - Vector<String> axisNames = cSys.coordinate(i).worldAxisNames();
1097 - String tmp = axisNames(0);
1098 - tmp.upcase();
1099 - if (tmp.contains(String("FREQ"))) {
1100 - spectralCoord = i;
1101 - break;
1102 - }
1066 +void ImagePolarimetry::_findFrequencyAxis(
1067 + Int& spectralCoord, Int& fAxis, const CoordinateSystem& cSys,
1068 + Int spectralAxis
1069 +) const {
1070 + LogIO os(LogOrigin("ImagePolarimetry", __func__, WHERE));
1071 + spectralCoord = -1;
1072 + fAxis = -1;
1073 + if (spectralAxis >= 0) {
1074 + ThrowIf(
1075 + spectralAxis >= Int(cSys.nPixelAxes()),
1076 + "Illegal spectral axis " + String::toString(spectralAxis) +" given"
1077 + );
1078 + fAxis = spectralAxis;
1079 + Int axisInCoordinate;
1080 + cSys.findPixelAxis(spectralCoord, axisInCoordinate, fAxis);
1081 + // Check coordinate type is one of expected types
1082 + ThrowIf(
1083 + ! (
1084 + cSys.type(spectralCoord)==Coordinate::TABULAR
1085 + || cSys.type(spectralCoord)==Coordinate::LINEAR
1086 + || cSys.type(spectralCoord)==Coordinate::SPECTRAL
1087 + ),
1088 + "The specified axis of type " + cSys.showType(spectralCoord)
1089 + + " cannot be a frequency axis"
1090 + );
1091 + }
1092 + else {
1093 + spectralCoord = _findSpectralCoordinate(cSys, os, false);
1094 + if (spectralCoord < 0) {
1095 + for (uInt i=0; i<cSys.nCoordinates(); ++i) {
1096 + if (
1097 + cSys.type(i)==Coordinate::TABULAR
1098 + || cSys.type(i)==Coordinate::LINEAR
1099 + ) {
1100 + const auto axisNames = cSys.coordinate(i).worldAxisNames();
1101 + String tmp = axisNames[0];
1102 + tmp.upcase();
1103 + if (tmp.contains(String("FREQ"))) {
1104 + spectralCoord = i;
1105 + break;
1106 + }
1107 + }
1103 1108 }
1104 - }
1105 - }
1106 - if (spectralCoord < 0) {
1107 - os << "Cannot find SpectralCoordinate in this image" << LogIO::EXCEPTION;
1108 - } else {
1109 - Vector<Int> pixelAxes = cSys.pixelAxes(spectralCoord);
1110 - fAxis = pixelAxes(0);
1111 - }
1112 - }
1109 + }
1110 + ThrowIf(
1111 + spectralCoord < 0,
1112 + "Cannot find SpectralCoordinate in this image"
1113 + );
1114 + fAxis = cSys.pixelAxes(spectralCoord)[0];
1115 + }
1113 1116 }
1114 1117
1115 -
1116 1118 void ImagePolarimetry::_findStokes()
1117 1119 {
1118 1120 LogIO os(LogOrigin("ImagePolarimetry", __func__, WHERE));
1119 1121
1120 1122 // Do we have any Stokes ?
1121 1123
1122 1124 const CoordinateSystem& cSys = _image->coordinates();
1123 1125 Int afterCoord = -1;
1124 1126 Int iStokes = cSys.findCoordinate(Coordinate::STOKES, afterCoord);
1125 1127 if (iStokes<0) {

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut