LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Namespaces | Classes | Enumerations | Functions
lsst::afw::coord Namespace Reference

Namespaces

 utils
 

Classes

class  Coord
 
class  IcrsCoord
 A class to handle Icrs coordinates (inherits from Coord) More...
 
class  Fk5Coord
 A class to handle Fk5 coordinates (inherits from Coord) More...
 
class  GalacticCoord
 A class to handle Galactic coordinates (inherits from Coord) More...
 
class  EclipticCoord
 A class to handle Ecliptic coordinates (inherits from Coord) More...
 
class  TopocentricCoord
 A class to handle topocentric (AltAz) coordinates (inherits from Coord) More...
 
class  Observatory
 Store information about an observatory ... lat/long, elevation. More...
 

Enumerations

enum  CoordSystem {
  FK5, ICRS, GALACTIC, ECLIPTIC,
  TOPOCENTRIC
}
 

Functions

CoordSystem makeCoordEnum (std::string const system)
 A utility function to get the enum value of a coordinate system from a string name. More...
 
Coord::Ptr makeCoord (CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
 Factory function to create a Coord of arbitrary type with decimal RA,Dec. More...
 
Coord::Ptr makeCoord (CoordSystem const system, std::string const ra, std::string const dec, double const epoch)
 Factory function to create a Coord of arbitrary type with string RA [in degrees, not hours!], Dec. More...
 
Coord::Ptr makeCoord (CoordSystem const system, lsst::afw::geom::Point2D const &p2d, lsst::afw::geom::AngleUnit unit, double const epoch)
 Factory function to create a Coord of arbitrary type with Point2D. More...
 
Coord::Ptr makeCoord (CoordSystem const system, lsst::afw::geom::Point3D const &p3d, double const epoch, bool normalize=true, lsst::afw::geom::Angle const defaultLongitude=lsst::afw::geom::Angle(0.))
 Factory function to create a Coord of arbitrary type with a Point3D. More...
 
Coord::Ptr makeCoord (CoordSystem const system)
 Lightweight factory to make an empty coord. More...
 
Coord::Ptr makeCoord (CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec)
 Factory function to create a Coord of arbitrary type with decimal RA,Dec in degrees. More...
 
Coord::Ptr makeCoord (CoordSystem const system, std::string const ra, std::string const dec)
 Factory function to create a Coord of arbitrary type with string RA [in degrees, not hours!], Dec. More...
 
Coord::Ptr makeCoord (CoordSystem const system, lsst::afw::geom::Point2D const &p2d, lsst::afw::geom::AngleUnit unit)
 Factory function to create a Coord of arbitrary type with Point2D. More...
 
Coord::Ptr makeCoord (CoordSystem const system, lsst::afw::geom::Point3D const &p3d, bool normalize=true, lsst::afw::geom::Angle const defaultLongitude=lsst::afw::geom::Angle(0.))
 Factory function to create a Coord of arbitrary type with a Point3D. More...
 
lsst::afw::geom::Angle eclipticPoleInclination (double const epoch)
 get the inclination of the ecliptic pole (obliquity) at epoch More...
 
lsst::afw::geom::Angle dmsStringToAngle (std::string const dms)
 Convert a dd:mm:ss string to Angle. More...
 
lsst::afw::geom::Angle hmsStringToAngle (std::string const hms)
 Convert a hh:mm:ss string to Angle. More...
 
std::string angleToDmsString (lsst::afw::geom::Angle const deg)
 a Function to convert a coordinate in decimal degrees to a string with form dd:mm:ss More...
 
std::string angleToHmsString (lsst::afw::geom::Angle const deg)
 a function to convert decimal degrees to a string with form hh:mm:ss.s More...
 
std::ostream & operator<< (std::ostream &os, Coord const &coord)
 
std::ostream & operator<< (std::ostream &os, Observatory const &obs)
 

Enumeration Type Documentation

Enumerator
FK5 
ICRS 
GALACTIC 
ECLIPTIC 
TOPOCENTRIC 

Definition at line 54 of file Coord.h.

Function Documentation

std::string lsst::afw::coord::angleToDmsString ( lsst::afw::geom::Angle const  deg)

a Function to convert a coordinate in decimal degrees to a string with form dd:mm:ss

Todo:
allow a user specified format

Definition at line 293 of file Coord.cc.

293  {
294  return angleToXmsString(a, afwGeom::degrees);
295 }
AngleUnit const degrees
Definition: Angle.h:92
std::string lsst::afw::coord::angleToHmsString ( lsst::afw::geom::Angle const  deg)

a function to convert decimal degrees to a string with form hh:mm:ss.s

Definition at line 300 of file Coord.cc.

300  {
301  return angleToXmsString(a, afwGeom::hours);
302 }
AngleUnit const hours
Definition: Angle.h:93
afwGeom::Angle lsst::afw::coord::dmsStringToAngle ( std::string const  dms)

Convert a dd:mm:ss string to Angle.

Parameters
dmsCoord as a string in dd:mm:ss format

Definition at line 344 of file Coord.cc.

346  {
347  return xmsStringToAngle(dms, afwGeom::degrees);
348 }
AngleUnit const degrees
Definition: Angle.h:92
afwGeom::Angle lsst::afw::coord::eclipticPoleInclination ( double const  epoch)

get the inclination of the ecliptic pole (obliquity) at epoch

Parameters
epochdesired epoch for inclination

Definition at line 354 of file Coord.cc.

356  {
357  double const T = (epoch - 2000.0)/100.0;
358  return (23.0 + 26.0/60.0 + (21.448 - 46.82*T - 0.0006*T*T - 0.0018*T*T*T)/3600.0) * afwGeom::degrees;
359 }
AngleUnit const degrees
Definition: Angle.h:92
afwGeom::Angle lsst::afw::coord::hmsStringToAngle ( std::string const  hms)

Convert a hh:mm:ss string to Angle.

Definition at line 335 of file Coord.cc.

337  {
338  return xmsStringToAngle(hms, afwGeom::hours);
339 }
AngleUnit const hours
Definition: Angle.h:93
afwCoord::Coord::Ptr lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Angle const  ra,
lsst::afw::geom::Angle const  dec,
double const  epoch 
)

Factory function to create a Coord of arbitrary type with decimal RA,Dec.

Note
This factory allows the epoch to be specified but will throw if used with ICRS or Galactic
Most of the other factories (which accept epochs) just call this one indirectly.
Parameters
systemthe system (equ, fk5, galactic ..)
raright ascension
decdeclination
epochepoch of coordinate

Definition at line 1211 of file Coord.cc.

1216  {
1217 
1218  switch (system) {
1219  case FK5:
1220  return boost::shared_ptr<Fk5Coord>(new Fk5Coord(ra, dec, epoch));
1221  break;
1222  case ICRS:
1223  throw LSST_EXCEPT(ex::InvalidParameterError,
1224  "ICRS has no epoch, use overloaded makeCoord with args (system, ra, dec).");
1225  break;
1226  case GALACTIC:
1227  throw LSST_EXCEPT(ex::InvalidParameterError,
1228  "Galactic has no epoch, use overloaded makeCoord with (system, ra, dec).");
1229  break;
1230  case ECLIPTIC:
1231  return boost::shared_ptr<EclipticCoord>(new EclipticCoord(ra, dec, epoch));
1232  break;
1233  case TOPOCENTRIC:
1234  throw LSST_EXCEPT(ex::InvalidParameterError,
1235  "Cannot make Topocentric with makeCoord() (must also specify Observatory).\n"
1236  "Instantiate TopocentricCoord() directly.");
1237  break;
1238  default:
1239  throw LSST_EXCEPT(ex::InvalidParameterError,
1240  "Undefined CoordSystem: only FK5, ICRS, GALACTIC, ECLIPTIC, and TOPOCENTRIC allowed.");
1241  break;
1242 
1243  }
1244 
1245 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
afwCoord::Coord::Ptr lsst::afw::coord::makeCoord ( CoordSystem const  system,
std::string const  ra,
std::string const  dec,
double const  epoch 
)

Factory function to create a Coord of arbitrary type with string RA [in degrees, not hours!], Dec.

Note
This factory accepts epoch. There is an overloaded version which uses a default.
Parameters
systemthe system (equ, fk5, galactic ..)
raright ascension
decdeclination
epochepoch of coordinate

Definition at line 1363 of file Coord.cc.

1368  {
1369  return makeCoord(system, dmsStringToAngle(ra), dmsStringToAngle(dec), epoch);
1370 }
Coord::Ptr makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1211
lsst::afw::geom::Angle dmsStringToAngle(std::string const dms)
Convert a dd:mm:ss string to Angle.
Definition: Coord.cc:344
afwCoord::Coord::Ptr lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Point2D const &  p2d,
lsst::afw::geom::AngleUnit  unit,
double const  epoch 
)

Factory function to create a Coord of arbitrary type with Point2D.

Note
This factory accepts epoch. There is an overloaded version which uses a default.
Parameters
systemthe system (equ, fk5, galactic ..)
p2dthe (eg) ra,dec in a Point2D
unitthe units (eg. degrees, radians)
epochepoch of coordinate

Definition at line 1327 of file Coord.cc.

1332  {
1333  if (unit == afwGeom::hours) {
1334  return makeCoord(system, afwGeom::Angle(p2d.getX(), afwGeom::hours), afwGeom::Angle(p2d.getY(), afwGeom::degrees), epoch);
1335  } else {
1336  return makeCoord(system, afwGeom::Angle(p2d.getX(), unit), afwGeom::Angle(p2d.getY(), unit), epoch);
1337  }
1338 }
AngleUnit const hours
Definition: Angle.h:93
Coord::Ptr makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1211
AngleUnit const degrees
Definition: Angle.h:92
afwCoord::Coord::Ptr lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Point3D const &  p3d,
double const  epoch,
bool  normalize = true,
lsst::afw::geom::Angle const  defaultLongitude = lsst::afw::geom::Angle(0.) 
)

Factory function to create a Coord of arbitrary type with a Point3D.

Note
This factory accepts epoch. There is an overloaded version which uses a default.
Parameters
systemthe system (equ, fk5, galactic ..)
p3dthe coord in Point3D format
epochepoch of coordinate
normalizenormalize the p3d provided
defaultLongitudelongitude to use if x=y=0

Definition at line 1296 of file Coord.cc.

1302  {
1303  Coord c(p3d, 2000.0, normalize, defaultLongitude);
1304  return makeCoord(system, c.getLongitude(), c.getLatitude(), epoch);
1305 }
lsst::afw::coord::Coord Coord
Definition: misc.h:36
Coord::Ptr makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1211
afwCoord::Coord::Ptr lsst::afw::coord::makeCoord ( CoordSystem const  system)

Lightweight factory to make an empty coord.

Parameters
systemthe system (FK5, ICRS, etc)

Definition at line 1389 of file Coord.cc.

1391  {
1392  switch (system) {
1393  case FK5:
1394  return boost::shared_ptr<Fk5Coord>(new Fk5Coord());
1395  break;
1396  case ICRS:
1397  return boost::shared_ptr<IcrsCoord>(new IcrsCoord());
1398  break;
1399  case GALACTIC:
1400  return boost::shared_ptr<GalacticCoord>(new GalacticCoord());
1401  break;
1402  case ECLIPTIC:
1403  return boost::shared_ptr<EclipticCoord>(new EclipticCoord());
1404  break;
1405  case TOPOCENTRIC:
1406  throw LSST_EXCEPT(ex::InvalidParameterError,
1407  "Cannot make Topocentric with makeCoord() (must also specify Observatory).\n"
1408  "Instantiate TopocentricCoord() directly.");
1409  break;
1410  default:
1411  throw LSST_EXCEPT(ex::InvalidParameterError,
1412  "Undefined CoordSystem: only FK5, ICRS, GALACTIC, ECLIPTIC, allowed.");
1413  break;
1414 
1415  }
1416 }
lsst::afw::coord::IcrsCoord IcrsCoord
Definition: misc.h:38
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
afwCoord::Coord::Ptr lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Angle const  ra,
lsst::afw::geom::Angle const  dec 
)

Factory function to create a Coord of arbitrary type with decimal RA,Dec in degrees.

Note
This factory assumes a default epoch
Most of the other factories (which don't accept epoch) call this one.
Parameters
systemthe system (equ, fk5, galactic ..)
raright ascension
decdeclination

Definition at line 1255 of file Coord.cc.

1259  {
1260 
1261  switch (system) {
1262  case FK5:
1263  return boost::shared_ptr<Fk5Coord>(new Fk5Coord(ra, dec, 2000.0));
1264  break;
1265  case ICRS:
1266  return boost::shared_ptr<IcrsCoord>(new IcrsCoord(ra, dec));
1267  break;
1268  case GALACTIC:
1269  return boost::shared_ptr<GalacticCoord>(new GalacticCoord(ra, dec));
1270  break;
1271  case ECLIPTIC:
1272  return boost::shared_ptr<EclipticCoord>(new EclipticCoord(ra, dec, 2000.0));
1273  break;
1274  case TOPOCENTRIC:
1275  throw LSST_EXCEPT(ex::InvalidParameterError,
1276  "Cannot make Topocentric with makeCoord() (must also specify Observatory).\n"
1277  "Instantiate TopocentricCoord() directly.");
1278  break;
1279  default:
1280  throw LSST_EXCEPT(ex::InvalidParameterError,
1281  "Undefined CoordSystem: only FK5, ICRS, GALACTIC, ECLIPTIC, and TOPOCENTRIC allowed.");
1282  break;
1283 
1284  }
1285 
1286 }
lsst::afw::coord::IcrsCoord IcrsCoord
Definition: misc.h:38
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
afwCoord::Coord::Ptr lsst::afw::coord::makeCoord ( CoordSystem const  system,
std::string const  ra,
std::string const  dec 
)

Factory function to create a Coord of arbitrary type with string RA [in degrees, not hours!], Dec.

Note
This factory uses a default epoch. There is an overloaded version which accepts an epoch.
Parameters
systemthe system (equ, fk5, galactic ..)
raright ascension
decdeclination

Definition at line 1376 of file Coord.cc.

1380  {
1381  return makeCoord(system, dmsStringToAngle(ra), dmsStringToAngle(dec));
1382 }
Coord::Ptr makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1211
lsst::afw::geom::Angle dmsStringToAngle(std::string const dms)
Convert a dd:mm:ss string to Angle.
Definition: Coord.cc:344
afwCoord::Coord::Ptr lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Point2D const &  p2d,
lsst::afw::geom::AngleUnit  unit 
)

Factory function to create a Coord of arbitrary type with Point2D.

Note
This factory uses a default epoch. There is an overloaded version which accepts an epoch.
Parameters
systemthe system (equ, fk5, galactic ..)
p2dthe (eg) ra,dec in a Point2D
unitthe units (eg. degrees, radians)

Definition at line 1346 of file Coord.cc.

1350  {
1351  if (unit == afwGeom::hours) {
1352  return makeCoord(system, afwGeom::Angle(p2d.getX(), afwGeom::hours), afwGeom::Angle(p2d.getY(), afwGeom::degrees));
1353  } else {
1354  return makeCoord(system, afwGeom::Angle(p2d.getX(), unit), afwGeom::Angle(p2d.getY(), unit));
1355  }
1356 }
AngleUnit const hours
Definition: Angle.h:93
Coord::Ptr makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1211
AngleUnit const degrees
Definition: Angle.h:92
afwCoord::Coord::Ptr lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Point3D const &  p3d,
bool  normalize = true,
lsst::afw::geom::Angle const  defaultLongitude = lsst::afw::geom::Angle(0.) 
)

Factory function to create a Coord of arbitrary type with a Point3D.

Note
This factory uses a default epoch. There is an overloaded version which accepts an epoch.
Parameters
systemthe system (equ, fk5, galactic ..)
p3dthe coord in Point3D format
normalizenormalize the p3d provided
defaultLongitudelongitude to use if x=y=0

Definition at line 1312 of file Coord.cc.

1317  {
1318  Coord c(p3d, 2000.0, normalize, defaultLongitude);
1319  return makeCoord(system, c.getLongitude(), c.getLatitude());
1320 }
lsst::afw::coord::Coord Coord
Definition: misc.h:36
Coord::Ptr makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1211
afwCoord::CoordSystem lsst::afw::coord::makeCoordEnum ( std::string const  system)

A utility function to get the enum value of a coordinate system from a string name.

Definition at line 117 of file Coord.cc.

117  {
118  static CoordSystemMap idmap = getCoordSystemMap();
119  if (idmap.find(system) != idmap.end()) {
120  return idmap[system];
121  } else {
122  throw LSST_EXCEPT(ex::InvalidParameterError, "System " + system + " not defined.");
123  }
124 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
std::ostream & lsst::afw::coord::operator<< ( std::ostream &  os,
coord::Observatory const &  obs 
)

Print an Observatory to the stream

Parameters
osStream to print to
obsthe Observatory to print

Definition at line 158 of file Observatory.cc.

161 {
162  return os << (boost::format("%gW, %gN %g")
163  % obs.getLatitude().asDegrees()
164  % obs.getLongitude().asDegrees()
165  % obs.getElevation()).str();
166 }
std::ostream & lsst::afw::coord::operator<< ( std::ostream &  os,
afwCoord::Coord const &  coord 
)

Definition at line 1418 of file Coord.cc.

1418  {
1419  auto const className = coord.getClassName();
1420  os << (boost::format("%s(%.7f, %.7f")
1421  % className
1422  % coord[0].asDegrees()
1423  % coord[1].asDegrees()).str();
1424  if (className == "TopocentricCoord") {
1425  os << (boost::format(", %.12f, (%s)")
1426  % coord.getEpoch()
1427  % dynamic_cast<afwCoord::TopocentricCoord const &>(coord).getObservatory()).str();
1428  } else if (className != "IcrsCoord" && className != "GalacticCoord") {
1429  os << (boost::format(", %.2f") % coord.getEpoch()).str();
1430  }
1431  os << ")";
1432  return os;
1433 }
A class to handle topocentric (AltAz) coordinates (inherits from Coord)
Definition: Coord.h:329