Revision: 21169
Author: gervandiepen
Date: Wed Jan 4 00:12:25 2012
Log: Added and used function makeMDirection to create MDirection for
some standard sources
http://code.google.com/p/casacore/source/detail?r=21169
Modified:
/trunk/derivedmscal/DerivedMC/UDFMSCal.cc
/trunk/mainpage.dox
/trunk/meas/MeasUDF/DirectionEngine.cc
/trunk/measures/Measures/MDirection.cc
/trunk/measures/Measures/MDirection.h
=======================================
--- /trunk/derivedmscal/DerivedMC/UDFMSCal.cc Wed Nov 30 06:45:20 2011
+++ /trunk/derivedmscal/DerivedMC/UDFMSCal.cc Wed Jan 4 00:12:25 2012
@@ -142,12 +142,13 @@
// First try the string as a planetary object.
// In the future comets can be supported like COMET:cometname.
String str = operand->getString(0);
- MDirection::Types refType;
- Bool fnd = MDirection::getType (refType, str);
- if (fnd && refType>MDirection::N_Types &&
refType<=MDirection::N_Planets
- && refType!=MDirection::COMET) {
- itsEngine.setDirection (MDirection(refType));
- } else {
+ Bool fnd = True;
+ try {
+ itsEngine.setDirection (MDirection::makeMDirection(str));
+ } catch (std::exception&) {
+ fnd = False;
+ }
+ if (!fnd) {
// Now do it as a FIELD column name.
// Skip possible leading backslash (escape char).
if (str.size() > 0 && str[0] == '\\') {
=======================================
--- /trunk/mainpage.dox Thu Nov 24 07:36:55 2011
+++ /trunk/mainpage.dox Wed Jan 4 00:12:25 2012
@@ -201,7 +201,7 @@
/// <td>measures tables scimath casa</td>
/// </tr>
/// <tr>
-/// <td><a href="group__meas.html">measures</a></td>
+/// <td><a href="group__meas.html">meas</a></td>
/// <td>measures tables scimath casa</td>
/// </tr>
/// <tr>
=======================================
--- /trunk/meas/MeasUDF/DirectionEngine.cc Wed Nov 30 06:45:20 2011
+++ /trunk/meas/MeasUDF/DirectionEngine.cc Wed Jan 4 00:12:25 2012
@@ -152,16 +152,8 @@
}
Array<String> names = operand->getStringAS(0);
itsConstants.resize (names.shape());
- MDirection::Types refType;
for (uInt i=0; i<names.size(); ++i) {
- Bool fnd = MDirection::getType (refType, names.data()[i]);
- if (fnd && refType>MDirection::N_Types &&
refType<=MDirection::N_Planets
- && refType!=MDirection::COMET) {
- itsConstants.data()[i] = MDirection(refType);
- } else {
- throw AipsError ("An unknown object name " + names.data()[i] +
- " is given as direction in a MEAS function");
- }
+ itsConstants.data()[i] = MDirection::makeMDirection
(names.data()[i]);
}
}
=======================================
--- /trunk/measures/Measures/MDirection.cc Tue Mar 1 03:46:18 2011
+++ /trunk/measures/Measures/MDirection.cc Wed Jan 4 00:12:25 2012
@@ -86,6 +86,43 @@
//# Destructor
MDirection::~MDirection() {}
+
+MDirection MDirection::makeMDirection (const String& sourceName)
+{
+ // Look if it is a known moving source.
+ MDirection::Types refType;
+ if (MDirection::getType (refType, sourceName)) {
+ // Only planetary objects are valid.
+ if (refType > MDirection::N_Types && refType < MDirection::COMET) {
+ return MDirection(refType);
+ }
+ }
+ // Now see if it is a known standard source.
+ MVDirection mvdir;
+ // Make it case-insensitive.
+ String name(sourceName);
+ name.upcase();
+ if (name == "CASA") {
+ mvdir = MVDirection (6.123487680622104, 1.0265153995604648);
+ } else if (name == "CYGA") {
+ mvdir = MVDirection (5.233686575770755, 0.7109409582180791);
+ } else if (name == "TAUA") {
+ mvdir = MVDirection (1.4596748493730913, 0.38422502335921294);
+ } else if (name == "VIRA") {
+ mvdir = MVDirection (3.276086511413598, 0.21626589533567378);
+ } else if (name == "HERA") {
+ mvdir = MVDirection (4.4119087330382163, 0.087135562905816893);
+ } else if (name == "HYDA") {
+ mvdir = MVDirection (2.4351466, -0.21110706);
+ } else if (name == "PERA") {
+ mvdir = MVDirection (0.87180363, 0.72451580);
+ } else {
+ throw AipsError ("MDirection: " + sourceName +
+ " is an unknown source name");
+ }
+ return MDirection (mvdir, MDirection::J2000);
+}
+
//# Operators
=======================================
--- /trunk/measures/Measures/MDirection.h Mon Sep 28 18:15:15 2009
+++ /trunk/measures/Measures/MDirection.h Wed Jan 4 00:12:25 2012
@@ -287,6 +287,10 @@
//# Destructor
virtual ~MDirection();
+// Make an MDirection object given the name of a moving source (SUN, etc.)
+// or of a known standard source (CygA, etc.).
+ static MDirection makeMDirection(const String& sourceName);
+
//# Operators
//# General Member Functions